
My history with Forth and stack machines (2010) - pmoriarty
http://yosefk.com/blog/my-history-with-forth-stack-machines.html#
======
lukego
Hacking for the latest and greatest Xeon CPUs feels a lot like Forth on small
machines to me. Each core has only 256KB of fast private memory (L2 cache).
Squeezing the working set into that memory means fast execution that is
independent of the other cores. That is really worth spending some brain
cycles on when optimizing for 36+ core servers.

The more things change, the more they stay the same?

~~~
detaro
Do you know any interesting links about these kinds of optimizations?

~~~
lukego
Sure:

Intel optimization reference manual:
[http://www.intel.com/content/dam/www/public/us/en/documents/...](http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-
optimization-manual.pdf)

Agner Fog's Software optimization resources:
[http://www.agner.org/optimize/](http://www.agner.org/optimize/)

I don't think it starts making sense until the 5th reading or so :).

------
chipsy
I'm among those who have enjoyed the satisfaction of making my own Forth-like,
and I've even used it only to find the same kinds of difficulties as author.
Aiming for less is always a valid approach, but it's hard to reconcile with
this era of software and the benefits of sheer magnitude. It might have been
less true in the early 70's when software was less of an "ecosystem."

But on re-reading this for the n'th time I think the lede of this one is in
the comments. Like any guru who is selling a "right way of doing," Chuck Moore
has always had a business interest in selling snowflake Forth services of some
kind. He, and other Forth followers, may well believe the pitch fervently. It
is, at least, a relatively self-consistent ideology, and it discards the messy
aspect of building any kind of institutional presence. But it also has a kind
of dogmatic quality.

~~~
hyc_symas
I also wrote my own Forth implementation, in 6502asm, back in high school. Was
great fun and a great learning experience. I later wrote a Star Trek space
battle game in it. As for aiming for less is hard to reconcile - that's where
you and the majority of programmers in the industry go wrong. You should have
said "aiming for less is always a valid approach." \- full stop.

My LMDB database engine is the world's smallest/fastest/most reliable full
ACID transactional data store. The core of the engine is less than 32KB of
x86-64 object code - it can execute entirely within a CPU's L1 instruction
cache. It blows away other DB engines that are several times bulkier in size.
It's only 6kloc of C. It does what it does precisely by following the Forth
philosophy - do what you need, throw everything else away.
[http://symas.com/mdb/](http://symas.com/mdb/)

Efficiency always matters, even today with CPUs whose L2 cache is larger than
entire computer systems of 30 years ago. Efficiency always matters because all
of these compute resources have a cost - electricity isn't free, and time
spent is irreplaceable.

I have other ongoing projects in Forth because it can handle some cases easily
that are awkward in other languages. (E.g., an ASN.1 parser for dynamically
adding new syntaxes to the OpenLDAP server. Forth is the perfect tool for the
job because it's inherently a language designed for extension.)

~~~
sitkack
Forth has good affordances for compact solutions. Compactness is the is the
single most important metric in robust solutions. Tractable, low inertia,
retargetable and emulatable are all qualities that come with compactness.

One would do well I think to explore through old code bases and algorithms for
stuff that ran well on those old systems. Because memory is plentiful doesn't
mean we need to waste memory bandwidth or cache locality.

------
andolanra
Various past comment threads:

* [https://news.ycombinator.com/item?id=1680149](https://news.ycombinator.com/item?id=1680149)

* [https://news.ycombinator.com/item?id=8146306](https://news.ycombinator.com/item?id=8146306)

* [https://news.ycombinator.com/item?id=3963896](https://news.ycombinator.com/item?id=3963896)

* [https://news.ycombinator.com/item?id=2985601](https://news.ycombinator.com/item?id=2985601)

* [a handful of zero-comment and one-comment reposts I've elided]

This is a very popular repost—as it should be, because it's a very good and
well-thought-out article, and a surprisingly well-reasoned and well-written
example of the "meditation on a programming language" genre of blog post—and
each of the past comment threads is also worth consulting.

------
agumonkey
Eric LaForest did a nice course on stack machines :
[http://csclub.uwaterloo.ca/media/Eric%20LaForest:%20Next%20G...](http://csclub.uwaterloo.ca/media/Eric%20LaForest:%20Next%20Generation%20Stack%20Computing)

------
SixSigma
I'm building a Javascript based Forth-like that uses JS values (including
functions) rather than bytes.

[http://github.com/lawless-m/North](http://github.com/lawless-m/North)

Stack based is fun.

~~~
detaro
Smalltalk bytecode also works on a VM with a stack that accepts random objects

~~~
SixSigma
That's interesting. I am looking for things to write in my new language. The
itch was to make a Forth, coming up with an application of it is the next
problem.

------
jacquesm
I love Forth.

It's quirky but extremely elegant.

Either its time has long gone or its time hasn't come yet, hard to decide
which.

~~~
maaku
FYI, bitcoin's programmable signature language is Forth. Variants of Forth are
used on many NASA spacecraft and rovers. Forth is doing quite well, thank you
:)

~~~
jacquesm
> Forth is doing quite well, thank you :)

I know. But I feel that it still has not reached anywhere near its potential
and I'm not sure if it ever will.

First time I worked with it was in the 1980's, I've been only an observer
since then but the bug never left me. It's a language for the equivalent of
software jewelers.

~~~
mud_dauber
I used Forth professionally in an industrial single-board computer product in
the late 1980s. But I haven't see it "in the wild" since, with the exception
of the occasional mention in spacecraft control.

~~~
jacquesm
There's a good chance that one of the embedded systems in your car uses it.
Especially the really small ones (too small to run RTOS).

------
pointfree
I was just discussing Forth metacompilers a moment ago:

[http://www.reddit.com/r/tinycode/comments/2rzuwp/da_here_h_2...](http://www.reddit.com/r/tinycode/comments/2rzuwp/da_here_h_2_h_da_h_2_the_metacompiler_of_cmforth/)

[http://www.reddit.com/r/Forth/comments/2s0g4a/da_here_h_2_h_...](http://www.reddit.com/r/Forth/comments/2s0g4a/da_here_h_2_h_da_h_2_the_metacompiler_of_cmforth/)

I think there is an opening again for Forth in the Internet of Things. That's
many low-power (and thus) small computers.

------
vram22
At one period, there was a lot of interest in stack machines; IIRC, there was
a BYTE issue that either covered it in many articles, or was dedicated to that
topic. Can't remember the month and year.

