proglangbase / bbhw

Bye Bye Hello World
Mozilla Public License 2.0
6 stars 4 forks source link

Gforth version #14

Closed lonetech closed 2 months ago

lonetech commented 3 months ago

Forth is a stack based, minimal syntax, extremely imperative programming language which encourages tacit code. It's one of the early languages, and the source of phrases such as "refactor". While there exist standards, many Forths do things subtly differently, and programs frequently use shortcut words. Forth's design makes it very easy to bootstrap, and it is therefore popular for small (e.g. sectorforth) or exotic (e.g. pbforth) targets.

This is a reasonably complete implementation of bye bye hello world in Gforth. The main quirk is some assumption the user won't enter very large numbers, and the countdown loop uses -do -loop which is not standard.

lonetech commented 2 months ago

Well, obviously I can't test on your systems. gforth is already packaged in Debian (and the derivative Ubuntu), and homebrew (which is more likely to have whatever macosx requires to work). Crashing the OS by running this should be completely impossible (but I have never attempted WSL). Also I didn't request any parallel build, gforth took 13s. It appears macosx specific for gforth to require libffi, and presumably they changed what the compiler accepts in the ten years since gforth 0.7.3. The brew formula also specifies emacs and libtool.

I could also port to other forths such as pforth, yforth, zForth, 4th, wForth, RetroForth, durexforth, pbforth, ...

c4augustus commented 2 months ago

One more change. Both pforth and gforth give the message "Invalid input" when it should be "Invalid countdown".