The code for the Prime Sieve in Turbo Pascal: program primes(input, output) To compare the performance of TP and TM-2, I am using a program based on the Prime Sieve benchmark included with TM-2. Because of the separate linker you can freely mix modules compiled with either native or M-code and hence get the best of both worlds. Then, for code that must run quickly you can set the IDE to compile to native Z80 code which runs much faster, but takes up more disk space and compiles more slowly.
This allows you to compile code that doesn't need to run quickly to M-code, which executes more slowly, but compiles much quicker and the manual says it generally takes about 1/3 the size of native code. Native vs M-CodeĮach module can be compiled to either native Z80 code or to M-code to be run on the built-in virtual machine. Therefore when you make a change to your codebase, you only need to recompile the modules that have actually changed, which on a big project can greatly increase build speeds. In addition, because the modules are separate they can be compiled separately. Because of this isolation it allows the linker to only link-in functions that are used and hence reduces the executable size. They allow you you to hide data and functions within a namespace and only expose what you want to. These are similar to Units in later versions of Turbo Pascal. The Modula in Turbo Modula-2, of course indicates the use of modules to separate code. To have these facilities on a CP/M machine in 1986 would have been incredible. In addition the library has been extended and you gain more numeric data types, coroutines, exceptions, procedures as parameters, typeless parameters, etc. With TM-2 you get many of the things that are liked about TP, including overlays, easy access to machine-code functions and a good standard library. The language itself is similar to TP and it is pretty easy to convert TP code to TM-2. However for this you get a lot more facilities, a bigger library and an altogether more sophisticated system. The most obvious initial difference is the size of an installation: TM-2 takes up 142Kb, compared to TP's tiny 34Kb. On top of this TM-2 added a separate linker and library manager. Like Turbo Pascal, Turbo Modula-2 was an Integrated Development Environment including a compiler and Wordstar based editor. I want to show why it was a real shame this happened, and how much better a programmer's life could have been. There doesn't seem to be any publicly documented reason for the withdrawal and it is said that Borland even denied its existence for a time.
It was released in 1986 by Echelon under license from Borland and then quickly withdrawn. Why TM-2 made such a fleeting appearance is shrouded in mystery. However, it was a superb product and, in many ways, feels like a grown-up version of Turbo Pascal. You probably haven't heard of Turbo Modula-2 for CP/M as it was only on the market for a brief period of time. I have written previously about why Turbo Pascal is a Great Choice For Programming Under CP/M and now it is time to talk about what could have been.