Thank you as JonesForth keeps getting hard to find. Any chance you will ever do an even more in-depth tutorial? Put it on lulu and I will buy. I'd like to write my own Forth, but need a bit more handholding.
If the tutorial is hard to find, please feel free to clone it on the git sites of your choice.
In depth: Likely not. I've actually been working on another literate language tutorial (completely unrelated to FORTH), so ... watch this space (or my blog).
I'm curious about Forth, as it's probably the most important language I've never learned. I've done a fair bit of low-level, micro-optimised coding in C and assembly, but don't get much time for that kind of thing these days.
How would you describe Forth in relation to those? What makes it stand out and what are its weaknesses?
Forth is probably the smallest true high level language there is. It is entirely self-contained, needs just about nothing in terms of hardware support and can run in as little as 2K of memory.
It is well suited to things like real-time control, you'll probably have a hard time getting used to stack manipulation (especially in the beginning) and it tends to keep you up all night (not sure if that is a strength or a weakness ;) ).
It will also be the most fun you've had with a computer in a long time and it will likely make you look at the rest of what we do with computers as clunky in the extreme.
What Forth is not really suitable for is large projects and things built with a team. It is more of an artisanal thing, something closer to watchmaking or jewelery than major construction.
If you want to know more about why Forth is the way it is you could do worse than to start with studying the life of Chuck Moore for a bit, the language and its author are roughly equally interesting and for want of a better word peculiar.
I remember writing a fairly trivial program in Forth on a ZX81 for a school open day. You needed the 16K RAM pack thing with the usual lump of Blu Tac to stop it wobbling.
When I "discovered" Forth, it seemed like science fiction (soo fast!) to me after BASIC juddering around the screen.
Probably worth mentioning the Jupiter Ace here[0] - a ZX81/Spectrum era computer which had Forth in ROM, instead of BASIC which was common at the time. The basic model only had 1K of RAM. I never used one but I remember when it came out, reviewers commented on its speed and memory efficiency.
"It will also be the most fun you've had with a computer in a long time and it will likely make you look at the rest of what we do with computers as clunky in the extreme."
Double true if one looks at the hardware and software Chuck Moore makes with it.
http://www.greenarraychips.com/ is his current company, mostly notable for extremely low-power chips using asynchronous circuits (i.e. there's no central clock). IIRC he develops the CAD software he uses to design chips on his own chips.
Read Chuck talk about OKad...when the hardware wasn't to his liking he built his own chips...after writing his own CAD software in only like 5k loc that runs waay faster than traditional CAD software and uses almost no resources.
Last time i did some coding in forth, it was Fig-Forth on the 8-bit Atari 800XL. It was really fun and I was amazing on how fast it could run despite being in such limited hardware.
I would say Forth is easier to use than assembly, and perhaps much more flexible/extensible than C, although in some senses lower level since C gives you a very nice, ordered way of specifying what are the arguments to your functions/etc.
Forth is a really cool language, but has the pitfall of trading time for space. It's a very lean language, and incredibly dynamic, but its heavy reliance on jumps makes it run slowly on modern hardware and thrashes most branch predictors.
The branch prediction problem is true for every language that doesn't JIT (pronounced: "cheat"). Furthermore, Forth is not limited to threaded code. You can have some simple code generation (subroutine threaded code+some primitive inlining) if you really want to prioritize speed. Finally, Forth is a simple language with simple implementations so it's often easy to add the primitive(s) you need in order to deal with the bottlenecks.
This is why Chuck Moore designed his own chips like GreenArrays I believe. There is no impedance mismatch between software and hardware and the entire thing is optimized for the problem domain and massively parallel. I'm sure you can get more speed out of C, but it no other language (even Lisp or Smalltalk) can the user understand the entirety of the system. Lisp machines and Smalltalk machines probably are about as close as possible, but I have zero experience with them personally. Perhaps the project to put PicoLisp on bare-metal qualifies if one uses a simple enough microcontroller as the language itself is about as simple as you can get a practical lisp.
Over the last twenty years or so, I have written serious Forth code generators for six CPU architectures. There's only one code generation algorithm that's not regularly present in most Pasgol family compilers. The results are the VFX Forth systems at http://www.mpeforth.com.
Not really, modern Lisps have done a fine job optimizing performance. FORTH suffers from treating the hardware too granularly, and thus not being able to take advantage of any of the advances in hardware in the last 2 decades.
There is no a priori reason FORTH can't take advantage of modern hardware, since in the extreme case the compiler can be completely replaced by redefining the meaning of ':' and ';'.
Feel free to have fun with Haskell and Forth all you like. Your project. :) However, you need to learn C and/or ASM then implement Forth and some system codeto get to the deeper truths. Probably. Quite a bit of people using it in embedded systems.
If you can get DOES> working, you really understand how Forth works. I have a toy Forth implementation where I got DOES> working, and I still have a hard time understanding how I got it working.