|
Designed for computer science instruction, Turing is simply the easiest, most fun, and most effective way of teaching programming concepts. |
|
Quick Links |
||
All these questions are connected, and we will answer them all, but first we need a little background.
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.
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.
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.
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.
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.