So, it is both the low overhead of the compiler AND the efficiency of the resulting code that made it a favorite of early microcomputer programmers seeking something more "productive" than Assembly language. This fact makes Forth likely the only language compiler you will find running from an 8-bit computer ROM cartridge. And various Forth compilers for 6502 have been implemented in as little as 1.5 KiB. similar functionality in Assembly is about 25%.
This ensures Forth is very simple (and fast) to compile, even on 8-bit machines, and that the results execute very efficiently, given that the lowest level Words were coded to be efficient on the CPU.Īccording to some 6502 Forth users, the typical overhead incurred by Forth programs vs. By combining the primitive words into ever more complex combinations, the program is built up in a way similar to Functional Programming languages. This means the language doesn't require much from the CPU in terms of addressing modes or spend any time doing sophisticated effective address calculations.Īdditionally, Forth provides a somewhat different paradigm than C in that it requires a program to be built up from very primitive and efficient units known as "Words" in Forth. Everything is passed through the Forth stack and procedures just deal with the stack for both their input and output. Forth lacks any sophisticated methods of dealing with parameters. Forth is exceptionally good for this use case, and superior to a C compiler, because Forth can make more efficient use of the 6502's hardware stack. One language that was popular on early 8-bit micros, including those that used the 6502 CPU, was Forth.