| ▲ | kragen 11 hours ago | |
I do have one objective thing to say about readability. In a pop infix language like C, Python, Lua, or JS, the expression
has fairly clear dataflow: data flows from a and b to c, and from c and d to e. This is knowable even without any previous knowledge of those five identifiers. The RPN version, in languages like Forth, PostScript, and Factor
can just as well correspond to any of these dataflow patterns:
And many others. You don't know if a or b is consuming something left on the stack from before, either.On this basis I think it's at least somewhat defensible to claim that stack languages are "less readable": information about the dataflow graph which is easily available in the infix syntax is not present, at least locally. You can reconstruct it by knowing, or guessing, the stack effect of each word. But that's different from just having it plainly written down. As a result, in Forth and PostScript, I regularly have bugs where I pass a parameter to, or receive a result from, the wrong place. This is not a major practical problem (it's usually pretty easy to figure out in the REPL) but it serves as evidence that stack languages really do require more effort to read and understand than pop infix languages. Of course, you can make almost exactly the same argument that explicit typing helps readability, and implicit variable capture by closures hurts it. I think there's some merit in that, actually. | ||
| ▲ | ofalkaed 2 hours ago | parent [-] | |
Forth words are not functions and if you try and use them like functions, things will get messy. You should never have things like "a b c d e" in Forth, you should have "abcde," a single word with a descriptive name built from a, b, c, d, and e, and designed so all you have to worry about is the stack effect of "abcde" and not the words it is built on or the data flow. I would say this is like saying C is terrible because people do ridiculous things with macros. I will give your posts a reread with fresh eyes tomorrow and probably have more to say, it is a bit too much to digest at this hour. | ||