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 simulator
Since 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 runmake
.
Then run the simulator with the appropriate Alto disk image:
bin/salto disks/tdisk4.dsk.Z
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".)
Type bravo
to start the Bravo text editor.
Press 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:
Press
ESC
to exit insert mode.
Press
p
(put) to save the file.
Type
hello.bcpl
(the file name) and press ESC
(not enter!).
Press
q
then ENTER
to 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 language
The 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 a[b]
.
BCPL uses resultis 42
instead of return 42
.
Semicolons are optional, kind of like JavaScript.
For pointers, BCPL uses lv
and rv
(lvalue and rvalue) instead of &
and *
.
rvalues.
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.
lshift
and rshift
instead of <<
and >>
.
eq
, ne
, ls
, le
, gr
, 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 editor
The 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.
Pressing u
provides an undo.
To delete selected text, press d
.
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,
press g
(for get), then enter the filename and press ESC
.
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).
Troubleshooting
If 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.
Thank you for this, and for quantitatively demonstrating the hubris of Jobs. We still need dudes like him, who believe their own edits of history, but hopefully there's enough dudes like you who shed light on history.
ReplyDeletehistory is almost always written by the victorious, so it's understandable that Jobs would claim and credit himself with such an insight.
ReplyDeleteI worked for Charles Simonyi at Xerox ASD (Advanced Systems Development) on the BravoX (Bravo 10) editor (see https://en.wikipedia.org/wiki/Bravo_(software) ).
ReplyDeleteAs the Wikipedia article points out, BravoX was written in BCPL, and later re-implemented in a language called "Butte" - "A Butte is a small Mesa". But the source code syntax of Butte and BCPL were essentially the same. The difference was that the BCPL compiler mentioned here generated machine code for the Data General Nova (which was emulated by Alto microcode), and Butte generated Mesa-like byte code (but NOT Mesa byte code). As it happens, I implemented the Butte microcode interpreter for the Xerox Alto at Charles' direction, having lost the argument with Charles where I advocated that Butte should generate Mesa bytecode for maximum forward portability. Charles later agreed that we should have gone with Mesa byte codes... but too late...
See https://en.wikipedia.org/wiki/Mesa_(programming_language) for more information about Mesa. See also https://en.wikipedia.org/wiki/Xerox_Alto.
Was the code for Bravo, BravoX, or Butte ever made available? There's a reimplemented Mesa system available it could be run on if the Mesa-like vs Mesa issue was addressed... :)
ReplyDeleteMartin: very interesting. Eschaton: I couldn't find BravoX or Butte source code, but the code for Bravo and a bunch of other things is at http://xeroxalto.computerhistory.org/Indigo/AltoSource/.index.html
ReplyDeleteI used BCPL in the 70s at school and then at Cambridge under Martin Richards (its main begetter) and have no recollection of "heffalump" (we did call the exclamation mark "shriek" though). Have just checked with a Cambridge near-contemporary and he agrees.
ReplyDeleteJohn, maybe heffalump is a Xerox term. I found it in the Xerox BCPL manual, but it doesn't turn up anywhere else.
ReplyDeleteI never heard the term "heffalump" when I worked at Xerox.
ReplyDeleteThis is a great intro to BCPL but Bravo is way overkill for writing code. The best editor for that was Clint Parker's Flash editor. Lightweight and aptly named, it was blazing fast with silky smooth text scrolling that is still unequalled today. All microcoded of course, like everything Clint wrote.
A lot of the BCPL features listed above do not appear to be canonical BCPL. Dr. Martin Richards continues to maintain a BCPL implementation on his website, and has different features. For instance, his version uses { and } instead of $( and $) (which is what BCPL *originally* used) or [ and ]. ! and % are used for dereferencing exclusively; no => operation exists. Etc.
ReplyDelete