Hacker News new | ask | show | jobs
by Hendrikto 34 days ago
Some sorely needed context:

> [Gforth is] a free, fast, featureful and portable implementation of the Forth 2012 language.

> Gforth runs under GNU, BSD, and similar systems, MS Windows and MacOS X and should not be hard to port to other systems supported by GCC.

1 comments

If you love HP-RPN calculators, you may love Forth as well. Forth is a very interesting language, I find it a bit too complex for my little brain but give it a spin if, you have 2 free hours
For me, the most interesting thing about Forth is it's "thin-ness". Getting from machine code to a Forth REPL can take about 4 kilobytes.
Same, people often described it as the lisp of assembly. You get a lot of freedom of abstraction over almost direct bare metal.
Yes. Or "Lisp for hardware nerds." ;)
Exactly, and if you build your inner interpreter properly it is wicked fast.
It's not complex, it is just that it requires a different mental model because of the lack of named parameters. Stack offsets are harder to remember than things with names, more so because they change all the time as you push and pull data.
Like many languages, Forth can get complicated if you really get into the weeds. These 2 papers [0][1] (both by one of Gforth's creators) illustrate the sorts of intricacies you can run into. The trickier subtleties have to do with Forth concepts like interpretation and compilation (which have their own meanings in Forth), and have little to do with Forth's use of stacks.

In Forth's defence, other languages also have tricky subtleties, e.g. C++. Neither language prioritises theoretical purity, of course. They would be very different languages, with different drawbacks and advantages, if they did.

Both papers touch on whether the behaviours of certain unusual Forth constructs are well-defined according to the ANS Forth language standard. This sort of discussion should be quite familiar to C++ programmers.

[0] State-smartness - Why it is Evil and How to Exorcise it (Ertl, 1998) http://www.euroforth.org/ef98/ertl98.pdf

[1] State-smartness: Applications, Pitfalls, Alternatives (Ertl, 2001) https://www.complang.tuwien.ac.at/papers/ertl01state.pdf

I just implemented an ANSI compatible Forth so I'm reasonably familiar with those nasty bits, the 'DOES>' and 'DEFER' words in particular were interesting and caused me to have to rewrite some stuff that I had assumed was already stable.