The Blue Screen I Was Always Glad to See

Contents
In November 1983 a small company called Borland sold a Pascal compiler for $49.95. The program on the disk was under 40 KB. It held a full-screen editor, a compiler and a runner, and the whole cycle of typing a line, compiling and seeing the result took a couple of seconds on a 4.77 MHz IBM PC, on a machine where the competition took minutes and a stack of floppies to do the same. That program was Turbo Pascal, and this month it is twenty-seven years old. I want to look back at it fondly, and at two of its descendants that mattered to me more than any other software I have used: Turbo Pascal 5.5 with Objects, and Turbo C 2.0.
I met Turbo Pascal at twelve, and grew up with it. My first copy did not run on a PC at all: it was the CP/M version, on the Apple IIe we had at home, with a Z80 CP/M card and Apple’s Extended 80-Column Text Card. An XT clone, bought new, arrived in 1986, and Turbo Pascal 3.0 for DOS was my Bar Mitzvah present that year. An AT with a hard disk replaced the XT in 1988, Turbo C 2.0 arrived at the end of that year and Turbo Pascal 5.5 in the summer of 1989, and in 1991, my last year of high school, I bought a 386. All of it ran at home. From the first week I kept a notebook, a squared exercise book with a list of programs I meant to write on the inside cover, and I still have it. The entries quoted below are as I wrote them, capital letters and all. They are a better record than my memory of what these tools felt like the first time.
This is not a history of Borland. It is a look at what those three tools did, why they felt the way they did to a teenager and still do to me, and what is still worth taking from them in 2010, when a build of a mid-sized C++ project can take longer than an entire Turbo Pascal session used to.
One file, three programs
The way you built a program on a PC in 1983 was the way you built it on a minicomputer. You edited the source in one program, ran a compiler that wrote an object file to disk, ran a linker that wrote an executable to disk, and then ran the executable. Each step was a separate program loaded from a floppy, and if the compiler found an error you went back to the editor, found the line by its number and tried again. Microsoft’s Pascal of the time compiled in several passes, each one a separate trip to the disk.
Turbo Pascal put all of it in memory at once. The editor used WordStar’s keys, which everyone already knew
(Ctrl-K B and Ctrl-K K to mark a block, Ctrl-K C to copy it, Ctrl-Y to delete a line), the
compiler read the source straight out of the editor’s buffer, and the output could go to memory and run
immediately, without touching the disk at all. The compiler was a single pass and very fast, and that
mattered less than the fact that it was there: no loading, no waiting for the drive.
The detail I remember best is what it did with an error. It did not print a list. It stopped at the first error, put you back in the editor with the cursor on the offending spot and the message at the top of the screen, and waited. Fix it, compile again. That loop, measured in seconds, is the whole reason the product was called Turbo. It is also, I think, why so many people of my age learned to program with it: you could try things faster than you could think about them, and when you were wrong you found out immediately and exactly where.
Turbo Pascal started life on CP/M. Its ancestor, Compas Pascal, was a CP/M compiler, and the first release in November 1983 came for CP/M-80 as well as for the IBM PC, and the Apple II was one of the machines it supported, as long as it had a Z80 card. That card was a second computer on a board, a Z80 running at about 2 MHz that took over the Apple’s memory and ran CP/M, with the 6502 left doing the screen and the disks. Ours was a IIe with a CP/M card and Apple’s Extended 80-Column Text Card in the auxiliary slot, which did two things at once: it turned the 40-column screen into a real 80 by 24 one, the shape a CP/M program and its WordStar-style editor expected, and it added a second 64 KB, taking the machine to 128 KB. That is where I met Turbo Pascal 1.0, in 1985, in the CP/M version. It started with the one-letter menu that every early Turbo Pascal had on every machine, E to edit, C to compile, R to run, and until then the only programming I had done was in Applesoft BASIC, which tells you about a mistake only when the program reaches the line it is on.
Jan. Typed in the program from the manual that asks your name and says hello. Pressed C and it was finished before I let go of the key. Pressed R and it said HELLO to me. The word processor takes longer than that just to start. ONE SECOND.
Made a mistake on purpose to see what happens. It doesn’t wait till it gets there like Applesoft. It goes straight to the exact place and tells you what’s wrong. It’s like it is helping.
A week later comes the other side of running from memory:
LOST EVERYTHING. The program went round forever and nothing worked, not even Ctrl-C, and I had to turn it off. It never saved it. 2 hours of typing. RULE: PRESS S BEFORE YOU PRESS R!!!
Running straight from memory was the whole point, and the price was that a program which hung the machine took the unsaved source with it. I doubt there was a Turbo Pascal programmer of that era who did not learn that rule the same way. I still save before I run, out of a reflex I can date to that page.
The compiler was written by Anders Hejlsberg, who had built its ancestor, Compas Pascal, in Denmark, and sold by Philippe Kahn’s new company. The price was as radical as the speed. At $49.95 it cost less than a textbook, and it was sold by mail order straight from a full-page advertisement in BYTE.
It had limits that look strange now. A program compiled to a .COM file, so code and data each had to fit
in 64 KB. There were no separate units: a big program was one big file, or several pulled in with the
{$I} include directive. It did not matter. Nobody I knew wrote a program that hit those limits for years.
Turbo Pascal 2.0: the first upgrade
Version 2.0 came out in 1984, at $69.95, and it was the release that made Turbo Pascal something you could build real programs with rather than just learn on. Three things stand out.
Windows, in the text-mode sense. The Window procedure turned a rectangle of the screen into a little
screen of its own: ClrScr, GotoXY and the text output all worked inside it, with its own origin and its
own scrolling. For a business program on a text display, that was the difference between a
teletype-style prompt and something that looked like an application.
Here is the idea in the form I used it for years, with the uses Crt that Turbo Pascal 4.0 later required
(in the early versions these routines were simply built in):
program Box;
uses Crt;
var
I: Integer;
begin
ClrScr;
TextBackground(Blue);
Window(20, 5, 60, 15);
ClrScr;
TextColor(Yellow);
for I := 1 to 5 do
begin
GotoXY(3, I * 2);
Write('Line ', I, ' of its own little screen');
end;
Window(1, 1, 80, 25);
NormVideo;
GotoXY(1, 24);
end.
GotoXY(3, 2) inside that window is column 22, row 6 of the real screen. The second ClrScr clears only
the window, which is how you painted a blue box on a black screen in one line.
Window was one of the routines that only the PC versions had, so I met it in 1986, when the XT arrived at
home with 640 KB, two 360 KB floppy drives and no hard disk, and Turbo Pascal 3.0 for DOS, my Bar Mitzvah
present, went into its left-hand drive:
THE XT! It has COLOURS. Window is the best command. You give it 4 numbers and it makes a little screen and everything stays inside. Made a blue box with yellow writing and a border out of = signs and a menu with 1 2 3 4. It looks like a REAL program, like the ones they sell in boxes in the shop.
Every one of those programs stopped compiling the day I moved up to 4.0, because Turbo Pascal 4.0 had moved
ClrScr, Window and their friends out of the language and into the Crt unit. The fix was the one line,
uses Crt. Finding that out took a long evening with the manual and an entry in the notebook that I will
not quote.
Overlays. A program that did not fit in memory could be split into overlay procedures that shared one
region and were loaded from disk when called. You marked a procedure overlay, and the compiler and runtime
did the rest. It was slow if you got the grouping wrong, and it was still a way past the wall.
The heap. Version 2.0 reworked heap management. Turbo Pascal let you give memory back in two styles:
Mark and Release, a stack discipline where you remembered a point and later threw away everything
allocated since, and Dispose, which freed one variable at a time, so a linked structure could lose a node
without losing everything after it. And there was an 8087 edition, sold as an add-on, for those of us who
had the maths coprocessor or wished we had.
What came after, briefly, because it sets up the part I want to talk about. Version 3.0 (1985) was faster still and added turtle graphics, and it was the present I had asked for:
BAR MITZVAH!!! Got Turbo Pascal 3.0, the real one in the box with the thick manual. Everyone else gave me pens and envelopes. It has TURTLE GRAPHICS. Made the turtle draw a spiral 400 times.
Version 4.0 (1987) was a rewrite: units with separate compilation, real
.EXE files that broke the 64 KB limit, and a new pull-down-menu IDE in the colours everyone now remembers
(and it broke a fair amount of 3.0 code, which nobody remembers fondly). Version 5.0 (1988) put a
source-level debugger inside that IDE and brought overlays back as a unit. And then in May 1989 came 5.5.
Turbo Pascal 5.5 with Objects
Turbo Pascal 5.5 added one keyword, object, and with it inheritance, virtual methods, constructors and
destructors. The design came from Apple’s Object Pascal, which Larry Tesler’s team had worked out with
Niklaus Wirth for the Macintosh in 1985, but Hejlsberg’s version fitted the way Turbo Pascal programmers
already worked: an object was a record with procedures attached, and it could live on the stack, in a
global, or on the heap. There was no garbage collector and no hidden allocation.
Mine came in the summer of 1989, after months of saving, a box of manuals with the disks tucked inside:
Got Turbo Pascal 5.5, the real one in the box, with 3 books. Read the thin book until 2 in the morning. It is about OBJECTS.
The thinnest manual was the one that mattered. This is the kind of program it taught you to write in the first hour:
program Shapes;
type
PShape = ^TShape;
TShape = object
Name: string[12];
constructor Init(AName: string);
function Area: Real; virtual;
procedure Show;
destructor Done; virtual;
end;
PRect = ^TRect;
TRect = object(TShape)
W, H: Real;
constructor Init(AW, AH: Real);
function Area: Real; virtual;
end;
PCircle = ^TCircle;
TCircle = object(TShape)
R: Real;
constructor Init(AR: Real);
function Area: Real; virtual;
end;
constructor TShape.Init(AName: string);
begin
Name := AName;
end;
function TShape.Area: Real;
begin
Area := 0;
end;
procedure TShape.Show;
begin
WriteLn(Name:8, Area:10:2); { Area is virtual: the child's runs }
end;
destructor TShape.Done;
begin
end;
constructor TRect.Init(AW, AH: Real);
begin
TShape.Init('rect');
W := AW; H := AH;
end;
function TRect.Area: Real;
begin
Area := W * H;
end;
constructor TCircle.Init(AR: Real);
begin
TShape.Init('circle');
R := AR;
end;
function TCircle.Area: Real;
begin
Area := Pi * R * R;
end;
var
List: array[1..3] of PShape;
I: Integer;
begin
List[1] := New(PRect, Init(3, 4));
List[2] := New(PCircle, Init(1));
List[3] := New(PRect, Init(2.5, 2));
for I := 1 to 3 do
List[I]^.Show;
for I := 1 to 3 do
Dispose(List[I], Done);
end.
It prints:
rect 12.00
circle 3.14
rect 5.00
Everything interesting is in TShape.Show. It was written once, for the base type, and it calls Area,
and the Area that runs is the one belonging to whatever the object really is. In 1989 most of us had
never seen that. We had written the same thing as a case statement over a tag field in a variant record,
and every new kind of shape meant finding and editing every case. Here a new shape is a new type, and
Show never changes.
It took me three days to see that, and the notebook has both ends of it:
Don’t understand virtual. Why would anyone want a procedure that doesn’t know which procedure it’s going to call??
I GET IT. Added a triangle and did NOT change Show and it still worked. Show doesn’t need to know. NOTHING needs to know. This must be how they write real programs.
The last line is underlined twice. Twenty-one years on, I would not put it much differently.
A few things in that program are pure Turbo Pascal, and they were what made it feel like Pascal rather than something bolted on.
New with a constructor. New(PRect, Init(3, 4)) allocates a TRect on the heap, runs its
constructor and returns the pointer, typed as whatever you assign it to. Dispose(List[I], Done) runs the
destructor and then frees the memory. Because Done is virtual, the right destructor runs even though the
list holds PShape, and Dispose frees the right number of bytes, because the destructor knows the real
size.
The constructor does real work. An object type with virtual methods carries a hidden field, a pointer to
its virtual method table, and the constructor is what fills it in. In Turbo Pascal that field is a single
16-bit word, placed after the fields of the first type in the hierarchy that declares a virtual method, so a
TShape is 15 bytes: 13 for the string[12], 2 for the table pointer. The table itself starts with the
size of an instance and that size negated, then the addresses of the virtual methods in order.
Forget the constructor, and {$R+} catches it. Those two size words are a checksum. With range checking
on, every virtual call first checks that the object’s table pointer leads to a table whose two words add up
to zero, and a static object that never had its constructor called fails the check:
program NoVmt;
{$R+}
type
TShape = object
function Area: Real; virtual;
constructor Init;
end;
constructor TShape.Init; begin end;
function TShape.Area: Real; begin Area := 1 end;
var S: TShape;
begin
{ S.Init; } { forget the constructor ... }
WriteLn(S.Area:0:1);
end.
That stops with runtime error 210, “Object not initialized”, instead of jumping through whatever garbage
was in the table pointer. With {$R-} you got the jump. I learned to leave {$R+} on during development
from exactly this.
Runtime error 210. Looked it up in the back of the book, it means Object not initialized. I forgot to call Init. THE COMPUTER KNEW I FORGOT. How does it know??
The two size words at the top of the table are how it knows. It took me a couple of years to find that out, and it was worth the wait.
Static objects were allowed. var S: TShape is an object on the stack, with no pointer anywhere. Apple’s
Object Pascal made every object a reference on the heap; Turbo Pascal let you choose, which suited a
640 KB machine where the heap was something you watched.
What I remember most about 5.5, though, is the manual. It came with a separate Object-Oriented Programming Guide, a slim book that explained inheritance, virtual methods and late binding from nothing, with examples you could type in and run. C++ was the fashionable language, but C++ meant AT&T’s cfront or Zortech, a long tool chain and manuals written for people who already knew. Borland’s guide was written for someone who had been programming in Pascal for a few years and had never heard the word polymorphism, which was most of us, and it worked just as well for a fifteen-year-old who read it in bed. A lot of programmers met objects for the first time in that book, and I suspect a fair share of the C# and Delphi written today descends from that hour with it.
It also set the pattern. Turbo Pascal 6.0 put the same objects to work in Turbo Vision, a text-mode
application framework, and when Delphi arrived in 1995 its class was the 5.5 object made into a heap-only
reference with a common ancestor. Delphi 2010 still compiles the 5.5 object syntax today.
Turbo C 2.0: the same blue screen, for C
Borland’s C compiler came later than its Pascal, and it came from outside: Turbo C 1.0 in 1987 was built on Wizard C, a compiler Borland bought from Bob Jervis. Version 1.5 added the graphics library that it shared with Turbo Pascal, and in 1988, alongside Turbo Pascal 5.0, came Turbo C 2.0. For me it is the best of the line. It was a C compiler for people who had been spoiled by Turbo Pascal.
TC.EXE was the same IDE: blue background, the menu bar along the top, the message window along the bottom,
the same keys. Alt-F9 compiled the current file, F9 made the project, Ctrl-F9 ran it and Alt-F5
showed you the screen your program had drawn. What 2.0 added was the debugger, inside the editor. F7 stepped
into a call, F8 stepped over it, Ctrl-F8 set a breakpoint on the line under the cursor and Ctrl-F7 added
a watch, and the current line was highlighted in the source you had just written. In 1988 source-level
debugging on a PC meant a separate product, and for C it usually meant CodeView and a separate trip through a
separate program. Turbo C 2.0 gave it to you in the same window, for the price of a compiler. (The
Professional pack added Turbo Assembler and the standalone Turbo Debugger, for the problems the integrated one
could not see into.)
Turbo C actually came before 5.5 for me, at the end of 1988. By then the XT had gone: an AT, a 286 with a hard disk, had replaced it that spring, and the notebook marks the day:
WE HAVE AN AT!!! 286 and a 20 MB HARD DISK. Put Turbo Pascal on it and there is loads of room left. No more swapping disks. Ran the spiral and it was finished so fast I thought it hadn’t done anything.
Turbo C went straight onto that disk, which was lucky. With its headers and libraries spread over several floppies, on the XT’s two drives it would have been a juggling act, and Turbo Pascal, in one file, had never asked for anything. I learned C on it with Kernighan and Ritchie from the library:
TURBO C! It looks EXACTLY like Turbo Pascal, same blue, same keys. C is like Pascal written by someone in a hurry. { } instead of begin end, = instead of :=, and == instead of =, which is a trap.
F7 is the best key on the keyboard. The program goes ONE line at a time and the line lights up, and you can put i in the watch window and see it change. It’s like looking inside the computer’s head.
Turbo Pascal 5.0 had the same debugger, but I was still on 4.0, so I found it in Turbo C, the language where I needed it most.
There was also TCC.EXE, the same compiler on the command line, with a make that understood it, so the
programs you wrote in the IDE could be built by a batch file. That was more important than it sounds: it meant
Turbo C was a serious tool and not just a teaching one.
The C that only made sense on a PC
Turbo C 2.0 was close to the ANSI standard that was being finished at the time: it had function prototypes,
void, const and a standard library that matched the draft. But the programs people wrote with it were
deeply 8086 programs, and the language had grown words for that.
The first was the pointer. On an 8086 an address is a 16-bit segment and a 16-bit offset, and Turbo C let you
choose a memory model for the whole program: tiny, small, medium, compact, large or huge, depending on
whether code and data each fitted in one 64 KB segment. On top of that, any single pointer could be declared
near (an offset in the default segment, 2 bytes) or far (segment and offset, 4 bytes). The most famous far
pointer of all pointed at the screen:
#include <dos.h>
void put_at(int row, int col, char ch, unsigned char attr)
{
unsigned far *screen = (unsigned far *) MK_FP(0xB800, 0);
screen[row * 80 + col] = ((unsigned) attr << 8) | (unsigned char) ch;
}
Segment B800 is linear address B8000, the colour text screen. Every cell is two bytes, the character and
its attribute, so writing a 16-bit word puts a character on the screen with its colour, faster than any BIOS
call. put_at(0, 0, 'A', 0x1E) is a yellow A on blue in the top-left corner. Everyone wrote this function.
Most of us wrote it before we understood why 0x1E was yellow on blue.
Wrote straight into the screen at B800. No printf, no anything, you put the number in memory and the letter is THERE. Filled the whole screen with yellow stars faster than you can see. I felt like a hacker.
Crashed the computer 3 times with a pointer that didn’t point anywhere. Reset button every time. The book says C trusts the programmer. It shouldn’t trust me.
There is no memory protection in real mode, so a stray far pointer could write over DOS itself, and the only recovery was the reset button. It is the same lesson as runtime error 210 from the other direction: Pascal had checked for me, and C did not.
The second was that Turbo C carried Turbo Pascal’s habits across. conio.h had window, gotoxy, clrscr,
textcolor, textbackground and cprintf, which is to say the Crt unit in C clothing, and the Pascal box
program above translates nearly line for line. The graphics library was the same Borland Graphics Interface
in both languages, with the same .BGI driver files that had to be in the right directory, and the same
message when they were not, which I can still recite: BGI Error: Graphics not initialized (use 'initgraph').
BGI Error: Graphics not initialized (use ‘initgraph’). I DID use initgraph!!! (The .BGI file has to be on the disk. 40 minutes.)
Staying resident
The far pointer to B800 led somewhere else as well, and it is where the notebook stops being about toys. DOS
ran one program at a time, and when a program ended, DOS took its memory back. Except that function 31h of
interrupt 21h, terminate and stay resident, ended a program and let it keep its memory, and if before ending
it had pointed one of the machine’s interrupt vectors at its own code, that code went on running, called by
the timer or the keyboard, underneath whatever ran next. That was a TSR, and it was how a PC did more than one
thing at a time in the 1980s: Borland’s own SideKick, a pop-up notepad and calculator, print spoolers, keyboard
enhancers, and later the anti-virus monitors.
Turbo C made it almost respectable. A function declared interrupt saved every register and set up the data
segment on entry, getvect and setvect read and wrote the interrupt vector table, and keep was function 31h.
This is about the smallest TSR worth writing, a counter in the top-right corner of the screen that goes on
ticking after the program has ended:
#include <dos.h>
static void interrupt (*old_tick)(void);
static unsigned ticks;
static void interrupt new_tick(void)
{
unsigned far *screen = (unsigned far *) MK_FP(0xB800, 0);
ticks++;
screen[79] = 0x1E00 | ('0' + (ticks / 18) % 10);
(*old_tick)(); /* chain to whoever had the vector before */
}
int main(void)
{
old_tick = getvect(0x1C);
setvect(0x1C, new_tick);
keep(0, _SS + (_SP / 16) - _psp); /* end, but keep this many paragraphs */
return 0;
}
Interrupt 1Ch is the hook the BIOS calls on every timer tick, about 18.2 times a second, so ticks / 18 is close
to seconds. The handler writes straight into the screen because it may do nothing else: it can be called in the
middle of any program, including the middle of DOS itself, and DOS was not written to be entered twice. A TSR
that called DOS at the wrong moment did not fail politely; it trampled DOS’s own stack and took the machine with
it. The way out was an undocumented byte, the InDOS flag, whose address function 34h returned, and which every
TSR author found in the end, usually in the lists of undocumented interrupts that went round the bulletin boards.
Turbo Pascal had the same tools, interrupt procedures, GetIntVec, SetIntVec and Keep in the Dos unit,
but the resident programs I wrote were in Turbo C and assembler, where every byte left in memory was a byte
taken from someone else’s 640 KB.
My program STAYS IN MEMORY after it ends. Ran WordStar and the number in the corner kept counting on top of it. DOS doesn’t even know it’s there.
Pop-up works except when it doesn’t. Press the key while the disk is going and everything freezes. DOS can’t be busy twice. There is a secret byte that says if DOS is busy (INDOS). It’s not in the manual, it’s in a list of interrupts from a BBS.
The same tricks were what viruses were made of. Brain, in 1986, hid in the boot sector. Jerusalem, found at the
Hebrew University in 1987, went resident just like the counter above, hooked interrupt 21h and infected every
program that was run, and because of a bug it re-infected .EXE files each time, so they grew with every run.
Cascade made the letters on the screen fall to the bottom. An anti-virus program of those years was the same
knowledge pointed the other way: a scanner that searched every file and boot sector for byte strings taken from
each known virus, and a resident monitor, itself a TSR, that hooked interrupts 21h and 13h and refused when
something tried to write to a program file or a boot sector. Writing one meant taking viruses apart byte by byte
in a debugger, on a machine you were ready to reformat.
Took Jerusalem apart in the debugger. It hooks 21h like my programs do. It’s just a TSR that does bad things. My scanner finds it now.
Those were the programs people paid me for, as a teenager: TSRs and anti-virus programs, low-level code that lived in the gap between what DOS did and what people needed. Everything I needed to write them, I had learned at this blue screen.
What C did not have yet
Put Turbo C 2.0 next to Turbo Pascal 5.5 and the irony of 1989 is plain: the Pascal programmer had objects
and the C programmer did not. If you wanted Show to call the right Area in Turbo C 2.0, you built the
virtual method table yourself:
#include <stdio.h>
#include <stdlib.h>
struct shape;
struct shape_vt {
double (*area)(const struct shape *s);
};
struct shape {
const struct shape_vt *vt;
const char *name;
};
struct rect {
struct shape base;
double w, h;
};
struct circle {
struct shape base;
double r;
};
static double rect_area(const struct shape *s)
{
const struct rect *r = (const struct rect *) s;
return r->w * r->h;
}
static double circle_area(const struct shape *s)
{
const struct circle *c = (const struct circle *) s;
return 3.14159265358979 * c->r * c->r;
}
static const struct shape_vt rect_vt = { rect_area };
static const struct shape_vt circle_vt = { circle_area };
static struct shape *new_rect(double w, double h)
{
struct rect *r = malloc(sizeof *r);
r->base.vt = &rect_vt;
r->base.name = "rect";
r->w = w;
r->h = h;
return &r->base;
}
static struct shape *new_circle(double radius)
{
struct circle *c = malloc(sizeof *c);
c->base.vt = &circle_vt;
c->base.name = "circle";
c->r = radius;
return &c->base;
}
int main(void)
{
struct shape *list[3];
int i;
list[0] = new_rect(3, 4);
list[1] = new_circle(1);
list[2] = new_rect(2.5, 2);
for (i = 0; i < 3; i++)
printf("%8s%10.2f\n", list[i]->name, list[i]->vt->area(list[i]));
for (i = 0; i < 3; i++)
free(list[i]);
return 0;
}
It prints the same three lines as the Pascal. Read the two side by side and you can see exactly what
object and virtual did for you: the vt field is the hidden table pointer, rect_vt and circle_vt are
the tables the compiler would have built, and new_rect is a constructor whose most important line is the one
that sets vt. Forget that line here and there is no {$R+} to catch it; the program jumps through whatever
malloc left in the field. (This version also skips checking malloc for NULL, which in 1989, on a
640 KB machine, would not have been a safe habit.) C programmers on the PC wrote this by hand until Turbo C++
1.0 arrived in 1990, and a good few kept writing it afterwards. There are large C code bases today, the Linux
kernel’s file system layer among them, built around exactly this pattern.
The 386
The last machine in the notebook is a 386, which I bought in 1991, in my last year of high school, with my own money. By then the tools in this post had stopped being only toys: I was writing low-level software for people who paid for it, the TSRs and anti-virus programs above, and the 386 was paid for by programs written on the AT. The 386 itself was not new by then: Compaq had sold the first 386 PC in September 1986, and Intel’s cheaper 386SX had been out since 1988, so five years on a 386 was what you bought for home, and the 486 was the expensive one. It ran every program from the XT unchanged, only faster.
1991. Bought a 386!!! With MY money, from MY programs. The star program fills the screen before you can see it start. Typed in the HELLO program from the Apple again and it still compiles. Should be studying for exams.
Every kind of program in this post first ran for me on one of those machines, the Apple, the XT, the AT and the 386, on a desk at home. The last of them was bought with what the others had taught me.
Running them again in 2010
The best news is that none of this is lost. Borland, before it sold its compilers on, put several of the old versions on its museum pages as free downloads, among them Turbo Pascal 1.0 (the PC edition of the version I started with), 3.02 and 5.5 and Turbo C 2.01, and they are still there on Embarcadero’s developer network. Download them, mount the directory in DOSBox, and the blue screen comes up exactly as it did, the compile loop is instantaneous, and the debugger steps through your code. Turbo Pascal 1.0 fits several times over on the floppy image you would have to make for it.
You do not even need DOS for the Pascal. Free Pascal has a Turbo Pascal mode, fpc -Mtp, and it compiles the
programs in this post unchanged, including the forgotten constructor, which it stops with the same runtime
error 210. It also ships a text-mode IDE that is deliberately the old one, keys and colours included.
There is one trap in running old binaries rather than old source. Programs built with Turbo Pascal 7’s Crt
unit calibrate their Delay loop at start-up by counting how far the CPU gets in one clock tick, and on any
processor faster than about 200 MHz the count overflows a division and the program dies before it starts with
“Runtime error 200”. Nearly every program built with that version has it, because nearly every program used
Crt, and there are patches for the binaries and for the unit. DOSBox, because it emulates a slower machine, mostly hides it.
What they got right
Looking back from Visual Studio 2010, which takes longer to open than Turbo Pascal took to compile a thousand-line program, it is tempting to say the old tools were simply better. They were not. They were small, for a small machine and small programs, and we have more programs and bigger ones now. But a few things they got right still look right to me.
The loop is the product. Turbo Pascal was not the best compiler of its day and did not claim to be. It was the one where the time from an idea to seeing it run was shortest, and that decided everything else: who could learn on it, how fast they learned, and how willing they were to try something and throw it away. Every tool I use now I measure first, without thinking about it, by how long that loop is.
Stop at the first error, and show me where. A list of forty errors, thirty-nine of them caused by the first, is not more helpful than one error with the cursor on it. Modern compilers have got much better at the second error, and I still prefer the first.
The manual is part of the tool. Turbo Pascal 5.5’s OOP guide did more for object-oriented programming on the PC than any language feature, because it met its readers where they were.
Price is a design decision. $49.95 put a real compiler in the hands of students, hobbyists and small businesses, the people who did not have a site licence for anything. That is a large part of why Pascal, for a decade, was the language people learned to program in.
The man who wrote the compiler, Anders Hejlsberg, went on to design Delphi and then, at Microsoft, C#, whose fourth version shipped this spring. You can see the line from one to the other if you look: properties, the component model, a fast compiler, an IDE built around the edit-run cycle. You can see it too in Delphi, still going under Embarcadero, and in Free Pascal and Lazarus, which carry the dialect to platforms Borland never dreamt of.
I read the notebook again before writing this. The boy in it is twelve on the first page and finishing
school on the last, and he is excited about things I take for granted now, and wrong about a few things, C’s trust among them. But he noticed, without the words for
it, the same things this whole post has been about: that ONE SECOND mattered more than anything
else, that a compiler which shows you where you went wrong is helping you, that Show not needing to know is
how real programs are written, and that watching a variable change one line at a time is looking inside the
computer’s head. I have learned a great deal since. I am not sure I have learned anything that mattered more.
The thing I miss is not a feature. It is being a teenager at a desk at home, pressing Ctrl-F9, and seeing my program run before
I had taken my hand off the keyboard, on a blue screen I was always glad to see.
The Blue Screen I Was Always Glad to See