Organize and Share your Electronics the way you want. Sign-Up for a free account now. It takes only 30 seconds!

"Hello world" in the BCPL language on the Xerox Alto simulator

"Hello world" in the BCPL language on the Xerox Alto simulator

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.)


The Xerox Alto II XM computer. Note the video screen is arranged in portrait mode. Next to the keyboard is a mouse. The Diablo disk drive is below the keyboard. The base contains the circuit boards and power supplies.

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 run make.
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:

The Salto simulator for the Xerox Alto.

The Salto simulator for the Xerox Alto.

(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:

A Xerox Alto 'Hello World' program for written in BCPL, in the Bravo editor.

A Xerox Alto ‘Hello World’ program for written in BCPL, in the Bravo editor.

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
hello

If all goes well, the program will print “Hello World!”
Congratulations, you’ve run a BCPL program.

Output of the Hello World program in BCPL on the Xerox Alto simulator.

Output of the Hello World program in BCPL on the Xerox Alto simulator.

The following figure explains the Hello World program.
If you know C, the program should be comprehensible.

'Hello World' program in BCPL with explanation.

‘Hello World’ program in BCPL with explanation.

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 Bravo editor provides WYSIWYG formatting of text.

The Bravo editor provides WYSIWYG formatting of text.

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.

If something goes wrong, you'll end up in Swat, the Xerox Alto's debugging system.

If something goes wrong, you’ll end up in Swat, the Xerox Alto’s debugging system.

Conclusion

The BCPL language (which predates the Alto) had a huge influence on programming languages since it led to C (and thus C++, Java, C#, and so forth).
The Bravo editor was the first WYSIWYG text editor and strongly influenced personal computer word processing.
Using the Alto simulator, you can try both BCPL and Bravo for yourself by compiling a “Hello World” program, and experience a slice of 1970s computing history.

Read more Here







Related Pins

Solar LED Light ,20000mah  Li-ion battery , 24V solar panel with MPPT charge Controller
Solar LED Light ,20000mah Li-ion battery , 24V solar panel with MPPT charge Controller
Transfer of TI’s Wi-Fi® Alliance (WFA) Certifications to SimpleLink™ Wi-Fi CC3x00
Transfer of TI’s Wi-Fi® Alliance (WFA) Certifications to SimpleLink™ Wi-Fi CC3x00
DIY USB 5V Solar Power Pack
DIY USB 5V Solar Power Pack
Tutorial: DHT22 sensor with a PICmicro
Tutorial: DHT22 sensor with a PICmicro
BQ24650 Based MPPT li-ion Battery Chage Controller With Software MPPT adjust and 3 Channel LED P ...
BQ24650 Based MPPT li-ion Battery Chage Controller With Software MPPT adjust and 3 Channel LED PWM dimming.
Play beautiful music on an Arduino thumb piano
Play beautiful music on an Arduino thumb piano
Kids can build these circuits
Kids can build these circuits
40 dB attenuator
40 dB attenuator
A multimeter heads-up display with Arduino glasses
A multimeter heads-up display with Arduino glasses
Robotic fish swims under Arduino control
Robotic fish swims under Arduino control
Arduino Xylophone
Arduino Xylophone
MPPT Solar Charger Testing
MPPT Solar Charger Testing
Design and Application Guide of Bootstrap Circuit for High-Voltage Gate-Drive IC
Design and Application Guide of Bootstrap Circuit for High-Voltage Gate-Drive IC
ESLOV is the amazing new IoT invention kit from Arduino
ESLOV is the amazing new IoT invention kit from Arduino
μPC1237 based 2 channel speaker protector
μPC1237 based 2 channel speaker protector
ESP8266 WeatherStation Color
ESP8266 WeatherStation Color
Keyless piano project using Arduino uno
Keyless piano project using Arduino uno
IoT Wardrobe
IoT Wardrobe
Automotive CAN Transceivers
Automotive CAN Transceivers
Restoring a vintage Xerox Alto day 8: it boots!
Restoring a vintage Xerox Alto day 8: it boots!

Top


Shares