News for hackers. Stuff that matters.
Re:Factor: An impressive stack-based language environment by Someone on Saturday August 11, 2018 @01:50PM (#17740715)
”Stacks are also efficient. The JVM bytecode is actually a stack language, for example.”

The advantage of stack-based is that instructions need not tell where there arguments live, making them smaller (if you have 16 integer registers, for example, a simple “add register I to register j, store result in register k” instruction needs 12 bits to encode the values of i, j, and k. That’s quite a lot if your instructions are 16 bits)

The disadvantage is that you have to move data to where instructions expect to see it before you can do computations. That makes your code larger and slower.

Last I know needing more instructions to do the same is more of a problem than having smaller instructions solves (https://www.usenix.org/events/vee05/full_papers/p153-yunhe.p...), but that’s over 10 years old.

There are no comments on this comment yet.