3 ms·
I don't think reverse polish notation is all that difficult, the difficulty lies rather in that Forth is best done as an actual low-level stack oriented languag
by Jach 14y ago
I don't think reverse polish notation is all that difficult, the difficulty lies rather in that Forth is best done as an actual low-level stack oriented language, not as a general purpose "does mostly everything at least okayish" language such as C++, Java, or Python. Few programmers work at such a low-level. There's usually an operating system in the way of your program and the machine, or at least a complex kernel that does more than strictly necessary, and in general there are just quite a few layers of indirection to get at the "actual" hardware. Even a lot of assembly programmers don't work low enough unless they happen to be doing small "kernel"-less (or "kernels" they made themselves) embedded systems. Verilog/VHDL/MyHDL programmers are probably in the same camp as Forth programmers, as long as they aren't just working on top of some big IP core they don't understand (like Java programmers writing on top of the JVM on top of the OS). Forth wants to talk to actual hardware, mainstream programming is about getting as far away from hardware as possible and leveraging other people's code whenever possible instead of doing it yourself. (This isn't to say the mainstream view is always wrong, it's often good that programmers work far away from the hardware, but for those sorts of problems I don't think Forth is really a good fit.)
This Washing Machine example isn't hard to understand: ": WASHER ( -- ) WASH SPIN RINSE SPIN ;" http://www.forth.com/embedded/swiftx-embedded-systems-7.html http://www.forth.com/embedded/swiftx-embedded-systems-7.html provides the rest of the implementation, which is also not hard to understand, and is at least as easy to understand as a corresponding assembly (or C) version would be. But it requires knowledge of the washing machine, which requires reading data sheets and maybe even doing some manual voltage tests, and it requires knowing (or choosing) which pins (or memory addresses) on the program host connect with the washing machine. There's a minimal kernel involved. You have to know what accomplishment it is you even want to achieve (as the Forth program begins with designing the high-level behavior I quoted, then continues by implementing bottom-up from the compiler primitives to meet the design).
I think Forth will be at most as popular as HDL languages are popular. That is, not very. And in both cases the allure of using C (whether compiled to what the embedded system's processor understands or compiled to the primitives of an IP core implementing a whole processor) will be strong, for there are lots of C programmers and C is more-or-less useful in any domain.