Live data from Hacker News

Thinking Forth (1984)

thinking-forth.sourceforge.net

1–10 of 51 posts

Re: Thinking Forth (1984)

#3
My introduction to Forth was tinkering first with Sun SPARC machines in the late 90s and then PowerMacs in the early 00s.

At the time, I had no idea that it was a discrete programming language; it only registered in my mind as part of the OpenBoot/OpenFirmware environments. Then I ran into the FreeBSD bootloader and things finally clicked. "Aha," I thought, "this is an actual programming language." But what made it so popular for the early boot process, and where else was it used?

The modularity was stunning. It was easy- almost absurdly so- to build complex code up from a series of tiny individual functions. That, coupled with the minuscule interpreters and simple stack-based approach, made perfect sense for situations where developers need to perform complex tasks with minimum of storage overhead, and with portability as a first class citizen.

Re: Thinking Forth (1984)

#4
Beside embedded system or firmware, what are Forth's popular use cases these days?

Personally I never see backend development or mobile frontend job vacancies that require Forth skill, for example.

Re: Thinking Forth (1984)

#5
post #4

Beside embedded system or firmware, what are Forth's popular use cases these days? Personally I never see backend development or mobile frontend job vacancies that require Forth skill, for example.

You are correct, Forth is not a institutional tool, more of a individual choice. IMO, one that allows you to prototype and debug interactively as you write your code and has been like that since the beginning.

It allows you to train yourself to have a complete control and command of your code making for tighter, simpler solutions for complex problems ( In my personal experience and comments for those that have been introduced to FORTH.)

If you consider that Embedded is a highly constrained resourced environment, then FORTH is a fantastic choice. Now step back, consider that statement once more, and you could be onto something even greater, as there is lots of resource waste-gates on modern OS and Computers. Now that Power is becoming a greater constrain resource, there might be an opportunity for someone to build something great in forth.

BTW the biggest back en used case is the bitcoint smart contract which is based on FORTH.

As you can see, and in full agreement in your statement, FORTH is a not a job magnet, IMO, you get better at programing understanding FORTH.

See Bret Victors talk, https://youtu.be/PUv66718DII you most of that already @ Forth ...! :;

Try it, you'll never go back! :)

Re: Thinking Forth (1984)

#6
post #4

Beside embedded system or firmware, what are Forth's popular use cases these days? Personally I never see backend development or mobile frontend job vacancies that require Forth skill, for example.

Forth has not won any popularity awards since the end of the '90s but it is still used by a small group of engineers around the world to solve their custom needs. This can be for embedded projects or firmware yes, but it has crept into larger projects.

IMHO opinion Forth is hard to learn, takes more effort to bootstrap your project (more like Assembler) and more importantly it is hard to switch gears to think with Chuck Moore's methodology. However once learned it can make one very productive.

Forth was (is?) used for experimental control in the ISS quite regularly. The ability to wip up a simple DSL that talks directly to hardware and will compile or can be used as a script is a win for those custom projects.

It's running in the FEDEX handheld package scanner from what I understand. (may be dated information) Funny story that. Way back, Version I was started in C but they hit the ROM size limits on the hardware that was already finished. Forth Inc. was asked if they could help. Using their Forth RTOS they re-wrote it and it all fit with room to spare. (Indirect-threaded-code is tight)

Years later, Version II hardware was designed with waaay more memory. Re-write in C fit nicely. All good.

But... the batteries would not last for an entire shift. Forth Inc was brought in again and they own their task scheduler so they modified it to put the CPU to sleep at every chance they could. Batteries lasted.

Largest known Forth program is on Windows. https://ribccs.com/candy/ 1M+ LOC. Compiles with VFX Forth by MPE UK.

Re: Thinking Forth (1984)

#7
post #4

Beside embedded system or firmware, what are Forth's popular use cases these days? Personally I never see backend development or mobile frontend job vacancies that require Forth skill, for example.

IIRC WebAssembly is at least partially inspired by Forth — both in syntax and being stack-based.

Re: Thinking Forth (1984)

#8
I treasure my copy of Thinking Forth. I was at a formative age when I read it and I learnt so many great programming concepts from it. The most important being keep breaking the problem down into simpler bits so you can understand and name each bit.

It is a Forth book, but I think anyone could get things out of it.

Leo Brodie's cartoons are very good too. One of my favourite ones is of a machine called the "Universal Processor" with a blender on top and computer keyboard underneath and a knob on the front which has three positions "Word", "Food", "Data" illustrating the danger of building over general solutions.

Re: Thinking Forth (1984)

#9
post #4

Beside embedded system or firmware, what are Forth's popular use cases these days? Personally I never see backend development or mobile frontend job vacancies that require Forth skill, for example.

That's literally what it's for. Forth is the simplest language to get running on hardware which you have no idea how to program directly. Much easier than doing it for C.

Re: Thinking Forth (1984)

#10

My introduction to Forth was tinkering first with Sun SPARC machines in the late 90s and then PowerMacs in the early 00s. At the time, I had no idea that it was a discrete programming language; it only registered in my mind as part of the OpenBoot/OpenFirmware environments. Then I ran into the FreeBSD bootloader and things finally clicked. "Aha," I thought, "this is an actual programming language." But what made it s…

> But what made it so popular for the early boot process, and where else was it used?

Probably simplicity. You can get a very basic Forth system going in a few dozen assembly instructions. Then, you write some Forth "primitives", words written in assembly, to do things like basic arithmetic, branching, stack manipulation, and memory manipulation. There are endless debates about how many primitives you really need, but in general a couple of dozen primitives ought to get you started.

Then the rest of Forth is just written in Forth! You might not really have recognisable Forth source at this stage but more complex words can be written out as lists of the addresses of primitives. Think of it as like rolling your own macro assembler. The "inner interpreter" reads these lists of addresses and either jumps directly to the machine code in a primitive, or into a command that starts the inner interpreter chewing on a new word, pushing the one you've just come from onto the return stack.

It seems really really complex until at some point as you stare at it, it'll just snap into focus and you see it's actually a very simple thing that does a very clever trick.

Post reply on HN