Live data from Hacker News

What the hell is Forth? (2019)

blog.information-superhighway.net

11–20 of 138 posts

Re: What the hell is Forth? (2019)

#11
Here are some great resources on Forth:

http://www.call-with-current-continuation.org/articles/forth...

https://git.sr.ht/~vdupras/duskos/tree/master/fs/doc/design/...

https://www.youtube.com/watch?v=9TJuOwy4aGA

Let me quote the first essay at length:

> Writing "good" Forth code is very hard, or at least what I consider good Forth code, which may be different from what others consider good. Forth has been called a "write only language", but only because it requires an additional effort to simplify your code to a point where everything becomes obvious. This is an art, it is a moment of transcendence, which I don't claim to have ever reached, but sometimes I get a glimpse of it, an inkling of the fact that if I would work very hard on this, it will become so simple, so heavily factored, using such obvious and clear names that everything just falls into place. It is this moment that programmers experience every once in a while, where a short, simple piece of code just does what it is supposed to do, without any extra baggage, easily understandable. To achieve it in Forth is much harder, it may require more time, many rewrites, but the results are even more satisfying, as the result is smaller, much simpler, fully self-contained and not burdened by code that you can not trust. When you forget about that urge of productivity, which has become the moloch we sacrifice our children to, you may be able to achieve that particular thing that is called quality, elegance, art. It may take a lifetime, you may never reach that far, but still you should strive for it.

> Or you remain a cog in the machine, developing on absurdly convoluted "software stacks", using inadequate and brittle languages, connect barely matching interfaces to only small parts of too many bloated libraries, using insanely sophisticated tools of incomprehensble complexity and trot on, asking yourself why everything sucks and why the last time you actually enjoyed programming and were you could be genuinely and deservedly proud on what you accomplished, was when you were a kid...

It seems to me that a lot of ideas in mainstream computing are pointing towards dead ends, and the practice of software engineering is either stagnating or in decay. Maybe it's time for a more radical reconsideration of how we build software, and time to give Forth (or something like it) a more serious look.

Re: What the hell is Forth? (2019)

#12
I used Forth for a while in the early 80's, but I don't miss it. It took a while to get used to it, but since everything I had done before that had been assembly language or interpreted Basic, it wasn't a steep curve. I remember doing things like writing code to take a string that was to be printed on a small dot matrix printer, like what you would find in a cash register, and flipping it upside down because the printer was physically mounted upside down in the final product but they wanted the print to be right side up when the tape exited the machine.

Re: What the hell is Forth? (2019)

#14
> A single person should be able to understand a computing system in its entirety, so that they can change it to fit their needs

This idea combined with the notion that software written by someone else necessarily serves their purposes rather than yours has me gradually working in that direction. Really all I need to do is write (or run) a forth on some bare metal. It's fun to build your own hardware as well which is what I'm during learning by doing right now too. Once I realized it was possible after reading jonesforth, I've been interested in (obsessed with) the idea.

To quote jonesforth:

> You really can write a complete FORTH in, say, 2000 lines of code. I don't just mean a FORTH program, I mean a complete FORTH operating system, environment and language. You could boot such a FORTH on a bare PC and it would come up with a prompt where you could start doing useful work. The FORTH you have here isn't minimal and uses a Linux process as its 'base PC' (both for the purposes of making it a good tutorial). It's possible to completely understand the system. Who can say they completely understand how Linux works, or gcc?

> Secondly FORTH has a peculiar bootstrapping property. By that I mean that after writing a little bit of assembly to talk to the hardware and implement a few primitives, all the rest of the language and compiler is written in FORTH itself.

Re: What the hell is Forth? (2019)

#15

I believe that any programmer should at least know a little about Forth. It's like Lisp. Just knowing about them is extremely enlightening, even if you don't use them in your daily life. Obligatory link: https://github.com/nornagon/jonesforth/blob/master/jonesfort... This well-written tutorial will have you implement a Forth in 500 lines of assembly and another 500 lines of Forth. You will feel like a different perso…

I couldn't get jonesforth to compile correctly. Not sure why. I found a python and a javascript implementation, not sure if I like them. Any recommendations?

Re: What the hell is Forth? (2019)

#16
post #3

I believe that any programmer should at least know a little about Forth. It's like Lisp. Just knowing about them is extremely enlightening, even if you don't use them in your daily life. Obligatory link: https://github.com/nornagon/jonesforth/blob/master/jonesfort... This well-written tutorial will have you implement a Forth in 500 lines of assembly and another 500 lines of Forth. You will feel like a different perso…

I've also heard it cures cancer. Any truth to this?

The percentage of people with cancer who are Forth users is very low. Take that as you wish...

Re: What the hell is Forth? (2019)

#17
If you want to build a Forth check out R. G. Loeliger's "Threaded Interpretive Languages Their Design And Implementation" https://archive.org/details/R.G.LoeligerThreadedInterpretive...

(Jonesforth has already been mentioned.)

Read "Starting Forth" and "Thinking Forth" too, even if you don't want to write a Forth or program in Forth. It'll still expand your mind in useful and fun ways.

Re: What the hell is Forth? (2019)

#19
post #15

I believe that any programmer should at least know a little about Forth. It's like Lisp. Just knowing about them is extremely enlightening, even if you don't use them in your daily life. Obligatory link: https://github.com/nornagon/jonesforth/blob/master/jonesfort... This well-written tutorial will have you implement a Forth in 500 lines of assembly and another 500 lines of Forth. You will feel like a different perso…

I couldn't get jonesforth to compile correctly. Not sure why. I found a python and a javascript implementation, not sure if I like them. Any recommendations?

I made tons of typos in both the assembly and Forth part when I did mine, but it did end up compiling correctly. Hunting the typos down was hard though because you get literally 0 feedback.

Re: What the hell is Forth? (2019)

#20

> A single person should be able to understand a computing system in its entirety, so that they can change it to fit their needs This idea combined with the notion that software written by someone else necessarily serves their purposes rather than yours has me gradually working in that direction. Really all I need to do is write (or run) a forth on some bare metal. It's fun to build your own hardware as well which is…

The part about the language being a little bootstrap and then mostly implemented in its own language...

Are there other languages like this? At least any mainstream ones?

Post reply on HN