Turing Logo  

Designed for computer science instruction, Turing is simply the easiest, most fun, and most effective way of teaching programming concepts.


Quick Links
Home page of Holt Software Associates  | Home page of the Turing Programming Language, the fastest way to teach programming concepts  | Home page of Holt Software's Java products  | Home page of Ready to Program with Java(tm) Technology, a Java development environment designed for education  | Information about Holt Software's courses for teachers  | Information about how to contact Holt Software  | Information about how students can purchase Holt Software's books and software  | Information about how schools and bookstores can purchase Holt Software's books and software

Compiler? Interpreter? What exactly is Turing?


We often get questions as to the nature of Turing. Is Turing a compiler or an interpreter? Does a compiled Turing program run faster?

All these questions are connected, and we will answer them all, but first we need a little background.

A Little Background

The only thing that a computer can run is machine-code. Each different processor has a different machine-code that they can run. This means that for a user to run a program that they have written, the program must be translated into machine-code.

There are two basic ways of translating your program (in whatever language it was written) into machine-code. One is to do so ahead of time and then feed the entire machine-code to the computer at once. The other is to translate the program from whatever language is being used to machine-code as the machine is running it. The first method is called compiling and is usually used in conjunction with languages like C or Pascal. The second method is called interpreting and is most often associates with Basic.

Compilers

When you run a compiler, it translates your program from the language it was written in, into machine-code. This machine-code is then (usually) written out to a file (in DOS parlance, it's an executable). When you run the program, the computer executes the machine-code instructions in sequence.

The advantages in compiling are that because the code is already in machine-code form, it runs very quickly. No translation is required while the program is executing. Likewise, because machine-code is fairly compact, the resulting executable program can often be quite small. The disadvantages are that compiling a program can be somewhat lengthy, since the entire program must be compiled. Also, the original program is no longer connected to the machine-code, and mapping the machine-code back to the original program can be very difficult (making writing a debugger difficult indeed). Also, from a developer perspective, each processor has a different machine code and thus requires a completely different compiler.

An example of this is that run-time errors in a compiled program are usually very general and often don't indicate where the error occurred. This is because things like line number information are lost during compilation.

Interpreters

An interpreter converts each line of a program into machine language as the statement is encountered. If a statement is encountered multiple times (as occurs in a loop) the machine must convert it to machine language each time.

However, as you can imagine, translating the same line of code into machine-code and then executing the machine-code has quite a high overhead. Thus interpreters usually run much more slowly than a compiled program. However, because the original program is still being worked on, debuggers are easier to write and no separate executable file need be stored.

Converting the program to machine language, however, can take several minutes (although more recent compilers are faster). Compiler run-time error messages are usually very general and rarely point out the line on which an error occurs. This is because most of this information has been lost in the translation from program to machine language.

Turing

Turing is a pseudo-compiler. (A what?) A pseudo-compiler is technology half way between a pure interpreter and a pure compiler. When you run a program in Turing, it translates the program not into machine-code, but into what is called pseudo-code. Pseudo-code resembles a sort of generic machine-code. It is not specific to any processor, but it follows the generalities of what most machine-codes look like.

Because it is a generic language, translation from Turing to pseudo-code is very quick. In general, compilation time is measured in tenths of seconds to seconds for very long programs (although you can wait a few seconds when Turing runs the first time as it compiles several hundred lines of predefined subprograms in various modules).

Execution speed is also somewhere between a compiler and an interpreter. When the program is running, Turing is translating the pseudo-code into machine language instructions and executing them. However, because there is a strong resemblance between pseudo-code and machine-code on most processors, the translation is fairly efficient and quick. The Turing pseudo-compiler executes about half as fast as a true compiler and about five times faster than a true interpreter.

Using a pseudo-code compiler also greatly enhanced portability between machines. This has allowed us to create versions of Turing for the PC, ICON, Macintosh, SUN, VAX and IBM mainframes.

Creating a standalone executable [WinOOT 3.1.1 only]

If there's no actual compiler, how does creating an EXE work?

The Turing program can be divided into three parts. There's the editor, which allows you to modify your program. Then there's the compiler, which translates the Turing program into pseudo-code. Then there's the executor which interprets or executes the pseudo-code.

When you generate a standalone executable, it copies a stand-alone version of the executor into destination file and then translates the program being compiled into pseudo-code, which it then appends to the destination file, When the destination file is run, it loads the pseudo-code stuck on the end into memory and then starts interpreting it.

The stand-alone executor is moderately large, which is why all EXE's are a minimum of 200K, regardless of the size of the original program. However, even large programs don't take up a lot more space when converted to EXE as pseudo-code is actually quite efficient.

However, because it is the same executor in both Turing and the executable and both are interpreting the same pseudo-code, programs run at the same speed in the Turing environment and when converted to EXE.


[ Turing Home ] * [ Top of Page ] * [ Feedback ]