Threaded Interpretive Language

A ThreadedInterpreter? is an interpreter written using a technique called threading (not to be confused with threads for concurrency) that entwines the 'get next instruction' operation of the interpreter with the actual instruction. This reduces the 'get next instruction' overhead and generally results in a 10% performance increase.

ForthLanguage implementations usually use a ThreadedInterpreter? and hence ForthLanguage is sometimes known as a ThreadedInterpretiveLanguage.

However, a threaded interpreter is an implementation detail and not a characteristic of the language itself. It is possible to use a threaded interpreter to implement non-Forth-like languages and Forth is often implemented without a threaded interpreter.

See http://www.complang.tuwien.ac.at/forth/threaded-code.html for a good exposition of what and why.

The SableVM (http://www.sablevm.org/) is a ThreadedInterpreter? for JavaLanguage.

BeeLanguage started out threaded. Several early BASICs for microcomputers were implemented as a ThreadedInterpreter?, including Microsoft BASIC. The standard ErlangLanguage virtual machine also uses threaded code.


An excellent work on this subject, containing a complete TIL implementation for the Z-80, is Loeliger's book ("Threaded Interpretive Languages" R.G. Loeliger, Byte Books 1981, ISBN 0-07-038360-X ).

I have a copy (I should have bought three) that I picked up in the years of Forth's waning "public" popularity. I've seldom had a such a lucid book that described the implementation details of a language.


EditText of this page (last edited January 10, 2012) or FindPage with title or text search