Page 1 of 1

Compiling stack languages

PostPosted: 14 Apr 2018 20:07
by joekillian
Is there anything inherently simpler about compiling stack based languages to assembly than other languages like C++?

For example, if a "conventional" language was designed to allow easy byte code translation to a stack based intermediate language "then" to assembly would that allow easier compiler design?

Re: Compiling stack languages

PostPosted: 15 Apr 2018 12:04
by Franck
It's not particulary stack based languages, but RPN notation that helps to simplify compilation.

With RPN, there is no instruction (separated with ; in C or C++) nor parenthesis : you just execute the words one after the other.
So the compilation is simplified.

In C or C++, you have to :
- identify the instructions (lexical).
- Create a tree that will allow to execute the instructions.
- Translate this into binary.

There is no such things in Oforth (or Forth).
Also, there is no separated compilation phase and, nevertheless, you can generate native code easily.

Franck