Gforth 1.0

166 points by joshcsimmons 22 hours ago on hackernews | 17 comments

Hendrikto | 21 hours 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.

daitangio | 19 hours ago

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

mitxela | 13 hours ago

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.

jnpnj | 12 hours ago

Same, people often described it as the lisp of assembly. You get a lot of freedom of abstraction over almost direct bare metal.

jacquesm | 6 hours ago

Exactly, and if you build your inner interpreter properly it is wicked fast.

jacquesm | 6 hours ago

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.

jan_m_savage | 20 hours ago

and here is the tutorial: https://net2o.de/gforth/Tutorial.html

anta40 | 18 hours ago

Nice to see gforth is still being maintained.

BTW, on the other side, looks like gforth still lacks the ability to create native OS executable, something like:

gcc myprog.c -o myprog

?

jan_m_savage | 18 hours ago

That’s because Gforth is a threaded-code VM that saves dictionary images rather than compiling to native code.

As you prolly know, Forth blurs compile time and run time in general, and there’s no so-called clean compile, then link boundary like in C.

SwiftForth, VFX Forth, and iForth do emit real executables, and there are smaller native-code Forths for Linux too, but then the opportunity cost is losing Gforth’s portability and its standards-heavy library ecosystem.

nickcw | 17 hours ago

You may enjoy ccforth then which is a mostly gforth compatible compiler which compiles to native via C.

https://github.com/ncw/ccforth

I wrote it as an experiment in having both a forth interpreter and compiler running at the same time.

lebuffon | 14 hours ago

Whoa! That is a really nice piece of work. Congrats!

iberator | 14 hours ago

For people who doesn't know forth:

Forth can have comments and doesn't need to be all at one line:)

also labels works as functions etc.

Its way more tradable language in real life than people think

fallat | 13 hours ago

The standard library is lacking some really nice conveniences. I'm working on correcting this and teaching Forth as a "grassroots" language for people who want to go back to the joy of programming as an art. The 100rabbits folks have already done a lot of work around proliferating that idea but I want to work outside of the Uxn machine that they use. Mark my words, us programmers are not phased by AI stealing the joy of programming :) The day job business programming, sure. But that was only fun sometimes. Forth will continue to exercise our brains and work through logic and data flow problems - skills we can bring to guiding agents for the day job.
Have you considered factor? Its from the joy-inspired branch of the forth/concatenative family, but its a heavily underrated, batteries included language. Which has a bit of a smalltalk feel given its image-based deployment and the "live" nature of its tools (graphical repl, object inspectors, etc)

jacquesm | 6 hours ago

I just did a big project using Forth and it is every bit as useful as it was in the past. Yes, there no security model, and you're going to have to work to manage your project, no fancy IDE or editor. I took a piece of code I wrote in 1988 and built it out to pass the Forth standard core words test and some extensions as well, then added all of the Raspberry Pi io devices as primitives. This makes it a super useful little toolkit (6K loc, 0 dependencies) to build embedded systems with in the robotics space.

I did consider using Gforth and another one that Don Hopkins pointed me to but I the end the familiarity with my own code won out over first reading myself into a large project. It all worked pretty well, the device I built with it is performing way beyond my expectations and I'm really happy I chose Forth even though it is a choice that I think only very few people would have made because it feels so old-fashioned. What especially pleased me is the lack of superstructure and the ease with which the whole thing could be moved between machines of varying word-size and underlying CPU architecture.

Forth still has a place. Now I need to get my grubby hands on some GA 144s.

stephen_cagle | 6 hours ago

Not Forth, but if you want a game that kind of feels a little like the GA144 then you might be interested in TIS-100 https://store.steampowered.com/app/370360/TIS100/ .

jacquesm | 6 hours ago

Interesting. I just saw the GreenArrays website is down, that's not good news.

And what I meant was I want the actual hardware. I may have to make it myself.