Monthly Archives: April 2014

Forth – not quite dead

In my previous post, Thinking in Forth, I said that Forth is a dead language. I did this to make two points. The first is that I don’t have to revive or advocate a dead language, hurray, because that’s boring. The second point is that even a dead language still has value, like Latin does. However, just because I consider it to be a dead language doesn’t mean that everyone else does too.

Forth words

Forth is an excellent choice for education for several reasons:

  • it’s small, maybe 25 required core words
  • most of these words are one, two, or three letters long, so familiarity with English is not a prerequisite for learning Forth
  • it’s simple with no built-in abstractions – source code maps directly to assembly code (a Forth word is just a list of calls to previously defined words)
  • it has little syntax to learn
  • there is only one data type in basic Forth – integers (called ‘cells’)
  • useful programs can be written early in the learning process
    (a Forth program is just a list of one or more Forth words)
  • it’s very ‘bootstrap-able’ – one learns by concatenation, not starkly delineated ‘levels’
  • paradigms such as object-oriented and functional programming are consistent with Forth (and in fact many of them have often already been very well implemented and documented)
  • concatenative programming is much more pure and natural
    See Threaded Nature
  • syntonic programming is easier learn and use
    See Forth: A Syntonic Language
  • Forth is useful for building models and simulations
  • open and non-proprietary versions of Forth are freely available for a wide range of platforms

There are several efforts at delivering basic, classic Forth to beginning programmers. One that I particularly like is 4E4th which runs on a tiny, inexpensive protoyping card.
The Raspberry Pi can easily run a bigger, more capable Forth.

Several commercial enterprises continue to promote Forth. Some can be found towards the end of the excellent and extensive Forth page on Wikipedia

The creator of Forth, Chuck Moore, is a tireless, brilliant, and dynamic force. He has never stopped developing cutting edge technology and innovation based on Forth. For a look at some of his latest work, here’s a talk he gave in September 2013 on the ga144 chip. It has 144 cores, with energy measured in picoJoules per instruction and power in nanoWatts per core, and is of course programmed in Forth. That’s hardly dead technology.

So, while I do not aspire to revive Forth or advocate it generally, I may have been in error in describing it as dead. I come to praise Forth, not to bury it.

Thinking in Forth

I consider Forth to be a dead language, at least in the same sense that Latin is a dead language – i.e. nobody uses it in daily life anymore. I now only use it and write about it in the context of computational thinking. Forth may be a dead language, but that doesn’t preclude it from being vibrantly important. If you don’t like irony, you’re reading the wrong blog.

Forth was developed for over a decade by Charles (Chuck) Moore before being written down formally in 1970. Moore was a radio telescope guy at the start. He needed an expressive, helpful computer language for his own work, much as Newton needed calculus. The story is best told in his own words http://www.colorforth.com/HOPL.html

What makes Forth important is just that – it was created to serve as a computational assistant. Using it is very conversational and immersive. One doesn’t think for an hour, consult authority and standards, edit for an hour, then compile, then test, then go for lunch (or go home), etc. There is a non-stop dialectic, a friendly and thoughtful argument, with you handling the imagination and it handling the bits and bytes.
And a program emerges.

Forth words

I started using Forth in the late 1970s. Using it, I learned binary and hexadecimal numbers and arithmetic, register manipulation (the main task of a CPU), memory manipulation (the main task of a computer), and many concepts and paradigms of programming. These included imperative (states, flow control), functional (stateless, mathematical), object oriented (encapsulation, re-use), factoring, concatenative, declarative (mostly through a Prolog written in Forth), machine control, etc, etc,. I read several books and many articles, but the real learning happened by doing. What’s key here is the fact that I’ve never been a great programmer (very good, but never great). Anyone can gain tremendous benefit from spending even a few hours learning Forth. It enables one to invent an ad hoc language to solve an ad hoc problem. It’s not magic and other worldly like Excalibur. It’s more like an early hominid’s stone tool – it teaches one to think, especially to think about the next tool.

My Forth days are long in the past. Today, I write mainly in Haskell, Assembler, Prolog, and English. For database work, I use SQL, key-value stores, and JSON. Whenever I think about any problem, I think computationally. I’ve spent almost four decades thinking in Forth.

I intend to write many posts and maybe even a few articles on Forth, it will be a mainstay of this blog.