8 ms·
Good context on why Forth didn't pan out can be found here: http://yosefk.com/blog/my-history-with-forth-stack-machines.html http://yosefk.com/blog/my-history-
by samatman 10y ago
Good context on why Forth didn't pan out can be found here:
http://yosefk.com/blog/my-history-with-forth-stack-machines.html http://yosefk.com/blog/my-history-with-forth-stack-machines....
I adore Forth and feel that it's in the small handful of languages / approaches to language that will permanently change a developer's understanding of the field. Perhaps if GreenArrays had succeeded well enough to make a few more generations of processor the landscape would be very different. Perhaps not.
Given today's architecture, the impedance mismatch between the stack paradigm and the register architecture costs Forth most of its advantage. Still, if there's another language that allows one to write an interactive assembler for a system with 8k of RAM, I've yet to hear of it.
The minimum investment in Forth, which I recommend to all thoughtful developers, is reading Programming a Problem Oriented Language by Chuck Moore, Forth's inventor.
- tbirdz 10y agoProgramming a Problem Oriented Language is freely available here: http://www.forth.org/POL.pdf http://www.forth.org/POL.pdf I'd also recommend looking at Thinking Forth if you want to get some more insight into Forth's philosophy, and really program structuring in general. It's also a good read even for people who don't have much practical use for forth in itself, many of the ideas are language independent. http://thinking-forth.sourceforge.net/ http://thinking-forth.sourceforge.net/
- textmode 10y agoTo whomever runs www.forth.org: The nameserver bywater.songbird.com is non-responsive. You have two nameservers on roundrobin. At least put the dead one second and turn off the roundrobin.
- phaemon 10y agoThat should be, "To whoever runs www.forth.org". Because it would be, "She runs www.forth.org". Alternatively, if you're not really interested, just always use "whoever" as it's acceptable in all situations.
- wtbob 10y ago> http://yosefk.com/blog/my-history-with-forth-stack-machines... http://yosefk.com/blog/my-history-with-forth-stack-machines..... What an absolutely fascinating article. I wonder how useful Forth would be for implementing another language atop a VM (e.g. the JVM, CLR or Lua's VM — or WebAssembly).
- buzzybee 10y agoMost (naive) VMs are defined as Forth-like stack machines as it's hard to reckon ways to map high-level instructions to load/store register semantics, but much easier to think in terms of stack push/pop. In that sense, Forth lives everywhere, it's just not formally acknowledged as such because it's a compilation target, so you only see it when you go debug the VM in terms of its instruction set. A way to think about Forth is not as a solution, but a strategy: build the smallest abstraction that works, then build a second abstraction that refines things slightly closer to the domain problem, but explicitly compiles to the semantics of the previous one. If you do this several times you can get a very powerful environment quickly. But it takes time to reinvent the world from scratch, and shipping a project still usually leads to taking on dependencies. "Pure" Forth is just a matter of applying the approach directly to the hardware, resulting in a barebones, loose-cannon system that is clearly very powerful, but too dangerous to use out of the box. Traditional compiler technology, in contrast, exchanges a big set of dependencies(a compiler, a build system, a module system, etc.) for a predefined semantics, type system, error checking, etc. These things are really useful for applications, but such languages can never be quite as direct since they are general-purpose. The Forth approach is still useful always.
- david-given 10y agoWhile back I wrote a Forth interpreter. (2.4kloc of portable C, passes nearly all the ANS Forth test suite.) I recommend this to anybody interested in programming languages; you don't have to finish it, but once you get the core interpreter working (in mine, the inner loop is two lines of C!) there's this aha moment and you finally get what the fuss is about, and you can feel your brain expanding. But as a programming language to work in? Well... - Forth has no (well, very little) runtime error checking. If your stack underflows, and you're lucky, it'll halt and tell you. But get anything else wrong, and it won't notice, and it'll just silently and invisibly poison its internal state and then crash later in a way that's really hard to debug. - The language is strongly typed. It just doesn't have any type checking, and if you get the types wrong, it'll silently and invisibly poison its internal state and the crash later etc. You have to remember what type of object you push onto the stack, because you need to use the right kind of word to consume the object again. Does this word push a float? You need to know, because you need to use FDROP instead of DROP to consume it. - The main culprit here is the compiler, which passes internal state around is by pushing objects onto the compiler stack. e.g. the BEGIN word, which starts a loop, pushes a 'dest' object onto the compiler stack. You have to consume this with UNTIL, WHILE or AGAIN. If you use the wrong word, or exit the definition without consuming it, it'll silently and invisibly poison its internal state etc. So you're now mentally juggling three different stacks: the data stack, the return stack, and the compiler stack, and if you make a mistake anywhere you're going to have a bad day. - There's a lot of trivia to remember, which you need to remember. EXIT is allowed inside a BEGIN..AGAIN loop. But it's not allowed inside a DO..LOOP loop, because DO..LOOP loops are permitted to store a state object on the return stack. I will retrieve the index of the innermost DO..LOOP loop, and J will retrieve the index of the next DO..LOOP loop... but not if you've pushed something onto the return stack yourself inside the outer loop. If you don't get it right, it will silently and invisibly etc. - Forth's only really intended to work on bare metal, and this shows. e.g. data space is assumed to increase from HERE up to the top of memory, and there's no facility for disjoint data spaces. The way you define data is to take a pointer to HERE and then just write stuff. All that stuff is defined to be contiguous. There's no scope for, e.g., running out of heap and allocating another block from the operating system. Oh, and try not to run out of memory, because it will etc. - Stack juggling gets old very, very quickly. (Although some Forths, not mine, support local variables.) Where Forth really excels is as an assembler substitute, where you're will to focus down and concentrate on every byte of source and you're going to put up with a complete absence of error checking because you need the performance. It's certainly great there. Being able to fit a complete interactive environment into a tiny, tiny space is astonishingly useful for debugging. But I'd hate to have to write anything of any great complexity in it. I have heard of type-checked Forths; here's one, although I notice it takes a lot of liberties with the language (like not really having a return stack): http://www.arestlessmind.org/2009/02/03/intro.html http://www.arestlessmind.org/2009/02/03/intro.html But I've never used one. I should, one day; I'm willing to believe that it's a much more pleasant experience than raw Forth. In particular, an embedded Forth with strict type checking but no runtime overhead sounds amazing... (Aside: the Jupiter Ace was a Z80-based home computer from the 1980s, about the same grade as the ZX81. It came with Forth. Javascript emulator! http://jupiler.retrolandia.net/ http://jupiler.retrolandia.net/ It's got games! In Forth! Load one, do SHIFT+SPACE to exit, then 'vlist' will dump the dictionary and 'list word' will decode a word.)