Exploring the Forth programming language

I enjoy reading about history, in particular programming history. A few months ago I discovered the Forth programming language, and fell into the rabbit hole. I knew about the Algol branch of programming languages, and the Lisp branch. Forth is a whole portion of programming history that I didn’t know even existed.

This language is built on minimalism and simplicity [1]. This was created by a guy working on telescopes for professional astronomers. It had to work on extremely small systems (in terms of CPU and RAM) and had to be reliable. Amazing.

I’ve heard of untyped languages before. B, the precursor to C, was a typeless programming language. I never really saw the advantage of something like this. I’ve programmed in statically-typed languages (C, SQL) and dynamically-typed languages (Ruby, Lisp, Javascript, Python, POSIX shell), but can’t wrap my head around the idea of a typeless language. Well, Forth is a typeless language, and it doesn’t really make a big difference to how one programs with it. Weird, but it works

A great part about Forth is listening to videos of Charles Moore and his talks about building programs that are reliable and simple. This man really cares about focusing on stripping programs down to their bare and necessary essentials. It shows in his writing and his conversation. It’s so satisfying hearing him talk about 10MB programs as too large [3].

The idea of using this language right over the machine is intoxicating. Forth was built on machines that were too small to have an operating system running on it. This high-level language runs a REPL, just like Lisp and Ruby, but is able to run it right over the metal. A lot of programming languages are built in C, but Forth used to be ported to new ISAs directly in Assembly. It took approximately one week to port Forth to a new CPU using Assembly! Its core can really be that small.

Of course, YMMV. BTW, this is a great site.

When I read things like “Forth is what you’d get if Python slept with Assembly Language: interactive, expressive, and without syntactical baggage, but still very close to the metal.” [4], I’m reminded of the promise of Lisp, but with the minimalism of C.

References

  1. History of Forth
  2. Interview with Charles Moore, discussing the history around the creation of Forth.
  3. 10 MB programs are too large
  4. Forth is a hacker’s language

Leave a Reply