I have a list of programming languages I really should learn more about, and Forth was on it. The book is a fun and accessible introduction to Forth. It's of the 'lots of drawings of little people running around shoving things in boxes with names on' school of explanation I last saw in introductions to BASIC, but it works pretty pleasantly here. It starts off simply and ramps up reasonably but quickly.
Like those introductions to BASIC, it assumes that people with no prior programming experience will quickly understand the model of computation with memory being a big array of storage slots. Retrospectively, from a world with many high-level scripting languages, where people might learn Python and have no clue at all about what's really going on under the hood, this accidentally-close-to-the-metal approach seems weird. Except, in this case, it's not accidentally so - people call C a platform-independent assembly language, but it has nothing on Forth.
I'd come across stack-based languages before in the form of PostScript, but despite this emphasis, I don't think it's really the core of the language. The main thing is that it's really a macro-driven bytecode assembler. The use of a stack makes gluing the values together easier, since things don't have to be threaded through variables so much, but I think the real core is in the way new words are defined in terms of sequences of old words, and the way that new keywords are defined by associating some words with compile-time actions, rather than runtime actions. This is where it moves into the funky macro behaviour, more reminiscent of Lisp macros than something as weak as the C pre-processor.
Behind it all, Forth is tied closely to the metal and an expected memory model. It's quite imperative and embedded-feeling. Despite what the fans say, I think it'd be a nightmare to use for big systems. It does have some intriguing strengths, though. The mental load of dealing with a stack and the data-flow associated with that encourages people to build up programs from lots of small functions, and to build helper words which allow specialised compilation of structures. This feels remarkably like a modern high-level functional language!
I don't think Forth is actually a language you'd particularly want to use today unless you have a tightly embedded system and need something that can be jammed in, but still provides power and abstraction (of a sort). However, I think it's a great language to learn if you're not used to this kind of thing, if you want to see what can built up using a very lightweight set of tools and some powerful abstractions.
Posted 2010-09-15.