FWIW I felt the same way about LISP for a long time until I fell in love with it via Emacs. So please educate me!
FWIW I felt the same way about LISP for a long time until I fell in love with it via Emacs. So please educate me!
The main feature of the Forth style is to write lots of 1 to 2 line functions, in such a way that at the high-level, you have essentially a domain-specific language that looks like exactly what you want a program to look like - for example, "RINSE WASH CYCLE SPIN STOP" for a washing machine program, and "RINSE WASH RINSE WASH CYCLE SPIN STOP" for an extra clean option.
People claim that once you learn Forth, you start programming Forth-style in other languages like C, Python etc. I can already see the appeal.
My C sometimes looks like Lispy Erlangish weirdness, and my Java often looks like my C. Certain languages just have certain ways of worming their way into your brain and improving the way you think, much to the dismay of everyone who can't think that way yet because the idiom isn't native to that language (yet).
One of the most rewarding training experiences was giving my old Haskell textbook to a junior team member and watching his (at the time .NET, w/LINQ) code change over the course of a few weekends.
For example I am writing functions with no (or less) mutation and keeping them pure. Makes for easy testing.
We have Ruby programmers who has never used map/fold etc.
Sounds very much like my experience with LISPs. Probably just need to dive in and try it. Thanks for the detailed response.
For instance here's a fairly complete Forth environment in around 10 KBytes running on an 8-bit home computer. There was no C compiler at all for that machine, and if there would be, working with it would be a lot more hassle than a Forth REPL.
https://floooh.github.io/tiny8bit/z1013.html?type=z1013_64&f...
What's the appeal today, I don't know. But I'm in the "curly braces" camp. If I'd be a Lisp guy, Forth would probably be more appealing to me.
...on a deck of punchcards in his shirt pocket.
I'm getting a keyboard popup, and I appear to be typing somewhere offscreen (I can see a typing suggestion containing exactly what I've typed, which wouldn't happen if input wasn't going anywhere), but the text isn't appearing onscreen, then when I press Enter, I get an "OK" as though I'd hit Enter on a blank line... and the input I'd typed isn't cleared. So, "words <Enter> words <Enter>" shows "wordswords" in my keyboard's suggestion, and "OK\nOK\n" on the display.
Looks really cool though :D
Otherwise, your development cycle in C or assembly is "peer at datasheet, carefully enter bitwise arithmetic, compile, flash, wait several seconds for flashing to complete, debug."
* Forth is tiny. You don't need a preprocessor, a compiler, a linker. Your entire programming environment, beside the text editor, can live directly on the target MCU.
* Forth is interactive. You can run your code, examine the results, define and redefine words, run again, etc right on the target machine (which may be a tiny controller). Yes, you likely will remove the REPL-related words from the final image (or not), but C can't hold a candle to the interactive development experience of Forth.
* Unlike in C, you can build an economical DSL in Forth to closely match your target domain. What Forth takes away in readability due to the need to think in stack terms, it more than pays back in expressiveness and abstraction, provided certain skill and taste.
While Forth does have an execution overhead and thus cannot obviate C completely in some cases, I've seen e.g. an injection controller for an internal combustion engine which did hard realtime completely in Forth. Hard realtime here means that all computations were clocked by the rotation of the shaft, with precise timing of different phases along the way.
C normally involves compiling the entire program at once. Even if you use a interpreted C of some sort, C is a lot more verbose and involves more typing.
This is important when testing and evaluating new hardware. All you need is a serial port or equivalent connection to a forth to allow you to exercise the hardware in a very interactive way. In some cases you might end up writing the final program by accident.