4 ms·
Honestly, that page pretty well convinced me that I have no interest in learning Forth. Possibly it was the "Since Forth needs few registers, a chip with many
by Symmetry 16y ago
Honestly, that page pretty well convinced me that I have no interest in learning Forth. Possibly it was the "Since Forth needs few registers, a chip with many is just a lot of wasted silicon" bit.
- daoudc 16y agoPresumably there's no reason why an optimising compiler couldn't make use of extra registers.
- thesz 15y agoAt the end of procedure you have to have a Forth ABI compliant stack state. If your stack state is in registers, more than one, you have to insert special code to reassign them (or schedule registers with that constraint in mind). Registers aren't good at compressing code the Forth way. Register code for z = x - y (assume all are in registers or stack) could be sub r1,r2,r3, or sub r127,r124,r11, or anything. Register indices depends on context. On Forth it always will be just sub instruction. If y operand is in memory, the Forth code will be @ sub, and always will be. We could abstract that : @sub @ sub ; if we feel that calling @sub will save us little code memory. It is just not possible with registers, because of the context: the sequence ld ri,(rj); sub rk,rl,ri could use any proper i, j, k and l as register indices. As a side note I should say that Java stack machine byte code isn't compressed as Forth code should be, so it lose to register code in Dalvik. As a rule, Forth code is 2-3 times less than CISC code (VAX, x86) and CISC code is 2-3 times less that RISC code (which itself is smaller that VLIW code).
- jerf 16y agoIf I were flung back in time to the 1970s, the two languages I think I could stand to work in would be Lisp and Forth. (C is not on the list because C has still come a long way since then; 2011-C is better in a lot of little ways than 1970-C, and the sum total is quite large.) But in 2011, I'd be more interested in their sequels, like Clojure or Factor [1]. But I do think it's important to look at Forth and see its place in history as a viable alternative to C, on pretty much any level C cared to compete in. It's important to understand that C is not the only way. (I don't mean this as a criticism of C.) [1]: http://factorcode.org/ http://factorcode.org/
- Symmetry 16y agoThats fair enough. And that sentence I quoted would be much less horrifying in the 1970s given all the changes in computers since then.