The first programming language for the Xerox Alto was BCPL, the language that led to C. This article shows how to write a BCPL "Hello World" program using Bravo, the first WYSIWYG text editor, and run it on the Alto simulator.
The Xerox Alto is the legendary minicomputer from 1973 that helped set the direction for personal computing. Since I'm helping restore a Xerox Alto (details), I wanted to learn more about BCPL programming. (The influential Mesa and and Smalltalk languages were developed on the Alto, but those are a topic for another post.)
Using the simulatorSince the Alto I'm restoring isn't running yet, I ran my BCPL program on Salto, an Alto simulator for Linux written by Juergen Buchmueller. To build it, download the simulator source from github.com/brainsqueezer/salto_simulator, install the dependencies listed in the README, and run
make. Then run the simulator with the appropriate Alto disk image:
Here's what the simulator looks like when it's running:
(To keep this focused, I'm not going to describe everything you can run on the simulator,
but I'll point out that pressing
? at the command line will show the directory contents.
Anything ending in
.run is a program you can run, e.g. "pinball".)
bravo to start the Bravo text editor.
i (for insert).
Enter the BCPL program:
// Hello world demo get "streams.d" external [ Ws ] let Main() be [ Ws("Hello World!*N") ]Here's a screenshot of the Bravo editor with the program entered:
ESCto exit insert mode.
p(put) to save the file.
hello.bcpl(the file name) and press
ENTERto quit the editor.
Run the BCPL compiler, the linker, and the executable by entering the following commands at the prompt:
bcpl hello.bcpl bldr/d/l/v hello helloIf all goes well, the program will print "Hello World!" Congratulations, you've run a BCPL program.
The following figure explains the Hello World program. If you know C, the program should be comprehensible.
The BCPL languageThe BCPL language is interesting because it was the grandparent of C. BCPL (Basic Combined Programming Language) was developed in 1966. The B language was developed in 1969 as a stripped down version of BCPL by Ken Thompson and Dennis Ritchie. With the introduction of the PDP-11, system software needed multiple datatypes, resulting in the development of the C language around 1972.
Overall, BCPL is like a primitive version of C with weirdly different syntax. The only type that BCPL supports is the 16-bit word, so it doesn't use type declarations. BCPL does support supports C-like structs and unions, including structs that can access bit fields from a word. (This is very useful for the low-level systems programming tasks that BCPL was designed for.) BCPL also has blocks and scoping rules like C, pointers along with lvalues and rvalues, and C-like looping constructs.
A BCPL program looks strange to a C programmer because many of the special characters are different and BCPL often uses words instead of special characters. Here are some differences:
Blocks are defined with
[...] rather than
For array indexing, BCPL uses
a!b instead of
resultis 42 instead of
For pointers, BCPL uses
rv (lvalue and rvalue) instead of
The BCPL operator
=> (known as "heffalump"; I'm not making this up) is used for indirect structure references instead of C's
selecton X into, instead of C's
switch, but cases are very similar with fall-throughs and default.
rshift instead of
ge in place of
test / ifso / ifnot instead of
if / else.
A BCPL reference manual is here if you want all the details of BCPL.
More about the Bravo editorThe Bravo editor was the first editor with WYSIWYG (what you see is what you get) editing. You could format text on the screen and print the text on a laser printer. Bravo was written by Butler Lampson and Charles Simonyi in 1974. Simonyi later moved to Microsoft, where he wrote Word, based on the ideas in Bravo.
Steve Jobs saw the Alto when he famously toured Xerox Parc in 1979, and it inspired the GUI for the Lisa and Mac. However, Steve Jobs said in a commencement address, "[The Mac] was the first computer with beautiful typography. If I had never dropped in on that [calligraphy] course in college, the Mac would have never had multiple typefaces or proportionally spaced fonts. And since Windows just copied the Mac, it's likely that no personal computer would have them." This is absurd since the Alto had a variety of high-quality proportionally spaced fonts in 1974, before the Apple I was created, let alone the Macintosh.
The image below shows the Hello World program with multiple fonts and centering applied. Since the compiler ignores any formatting, the program runs as before. (Obviously styling is more useful for documents than code.)
The manual for Bravo is here but
I'll give a quick guide to Bravo if you want to try more editing.
Bravo is a mouse-based editor, so use the mouse to select the text for editing.
left click and right click under text to select it with an underline.
The editor displays the current command at the top of the editing window.
If you mistype a command, pressing
DEL (delete) will usually get you
out of it.
u provides an undo.
To delete selected text, press
To insert more text, press
i, enter the text, then
ESC to exit insert mode.
To edit an existing file, start Bravo from the command line,
g (for get), then enter the filename and press
To apply formatting, select characters, press
l (look), and then enter a formatting code
(0-9 to change font, b for bold, i for italics).
TroubleshootingIf your program has an error, compilation will fail with an error message. The messages don't make much sense, so try to avoid typos.
The simulator has a few bugs and tends to start failing after a few minutes with errors in the simulated disk. This will drop you into the Alto debugger, called Swat. At that point, you should restart the simulator. Unfortunately any files you created in the simulator will be lost when you exit the simulator.