Learning to love computer codes

  • Published
Paint can
Image caption,
The MacPaint source code is 5,822 lines long

You could do worse than spend the summer learning to program, argues Bill Thompson

I've just finished reading one of the most important pieces of writing from the last 30 years. It is carefully constructed, elegantly expressed and one of the most functional pieces of literature I've ever encountered.

Admittedly the characterisation is poor, largely because there are no characters, and what plot development there is created entirely by the reader.

That's because the writing is a computer program, written in the Pascal language, so it consists of a series of declarations and definitions of variables, constants, procedures and functions, along with the functional code needed to carry out instructions in the right order.

It is the source code for MacPaint, and I'm able to read it because Apple has donated it to the Computer History Museum and it is now available to download.

MacPaint starts like this:


{ BitMap Painting Program by Bill Atkinson }

and includes lines like:

TYPE Str63 = String[63];


EntryPtr = ^QueueEntry; { for mask stuff }

QueueEntry = RECORD

addr: LongInt;

bump: INTEGER; { +2 or -2 for right or left }

twoH: INTEGER; { 2 times horiz word coord }

mask: INTEGER;


It may not be everybody's beach reading, but it has been wonderful to see how it works.

It was written by Bill Atkinson and shipped with the original Macintosh computer in 1984, and makes extensive use of the QuickDraw screen display package, which is also available to download.

MacPaint became the defining Mac program because it allowed anyone to draw and sketch on a screen for the first time.

Paint prose

There had been other drawing programs before, of course, beginning in 1963 when Ivan Sutherland created Sketchpad, and MacPaint itself was based on LisaSketch - also called SketchPad - which Atkinson developed for the earlier Apple Lisa computer.

But MacPaint came bundled with the Mac and was available to ordinary users rather than the computer scientists who had access to the early systems. It made its way into offices and classrooms and homes, and shifted the boundaries of what you could do with a computer.

I was one of those early users, as the small software company I worked for in Cambridge in 1984 acquired a Mac to 'test drive' as soon as they became available in the UK, and I later showed it to an artist friend of mine, Bryna Waldman.

She had never held a mouse before, and as far as I know had never in fact used a computer.

I watched as she drew a carefully composed sunset - in grey-scale, of course, as the early Mac had a monochrome screen - and realised that the world had changed.

The revolution that MacPaint began has been astonishingly successful, and we are now surrounded by computers with touch-based graphical interfaces of startling sophistication and rare beauty.

However very few of us understand what lies behind the tools we use, or appreciate how even the most computer user interface is derived from lines of code like:

PROCEDURE CursorNormal;


InitCursor; { arrow, not hidden }

GridMouse(-1,-1,0,0); { no grid }


This needs to change, because those who do not appreciate how the technologies that define their world work are in danger of being controlled by them.

Image caption,
School children should also be encouraged to learn about the foundations of programming

My partner's daughter is currently learning Latin because she is fascinated by the ancient civilisations of Greece and Rome and realises that unless she understands the language used at the time she will always be forced to see their world through the filter of another person's understanding, because everything she reads will be in translation.

If she knows the language herself then she will at least have removed one of the layers between her and Suetonius.

I believe that the same is true of programming, and that anyone using computer technology should have at least a basic understanding of what software looks like and how the lines of code in Pascal or BASIC or C control the operation of your laptop, mobile phone or pacemaker.

We live in a world increasingly defined by the code that runs on the billions of processors that surround us.

ICT lessons in schools concentrate solely on how to use applications and services and not on the underlying principles of computer science, so a whole generation is growing up with no real understanding of the technology that defines our age.

So if you've got a free moment this summer, perhaps you should pick up a code listing instead of the latest Dan Brown.

Bill Thompson is an independent journalist and regular commentator on the BBC World Service programme Digital Planet. He is currently working with the BBC on its archive project.

Related Internet Links

The BBC is not responsible for the content of external sites.