Think of a stack-based language as operating on a stack of paper plates with a sharpie in hand.
Each operation has some effect on the stack, for example, ADD (and other two-input or binary operations), generally takes off the top two paper plates (permanently), ADDs them, and writes a new paper plate and puts it on the stack. A Stack of two elements (the operands) will have just one (the result) after said operation.
The INPUT operation might take input, then write that to the stack.
Simply putting a ‘thing’ like 5 or “Hello, World!” as an operation will write that to a new paper plate, and put it on the stack. Generally, there are utility instructions like DUP for duplicating the element at the top, or SWAP for swapping the top two elements.
Anyway, to the point. Multiplying two inputs would go something like this (for some reason, most stack based languages are in caps):
INPUT INPUT MUL OUTPUT
I guess that’s readable. But once you start getting more complex things going…
INPUT DUP INPUT ADD OUTPUT ADD
In the end, they make you want to fix the writers Enter key. He could have written:
x = Input( )
y = Input( )
output( x + y )
output( x + x + y )
But there are some good things about stack based languages. For one, they are amazingly well suited for designing simple hardware.







