"ALGOL 60 at 60: The greatest computer language you've never used"

One of the more obscure features of Algol, which may be a bit strange to the modern beholder (and which is also to be observed in the Ackermann program, namely in the assignment part of the procedure “ackermann”), is that if-then-else constructs may not only appear as conditional clauses, but also appear in expressions.

E.g., in an arithmetic expression:

<arithmetic expression> ::= <simple arithmetic expression> |
        <if clause> <simple arithmetic expression>
        else <arithmetic expression> 

Here an example from the Revised Report, an expression which may be used as the right-hand side of an assignment:

if a<0 then A/B else if b=0 then B/A else z

It’s like ternary expressions on steroids.

x := if a<0 then A/B else if b=0 then B/A else z

This works also with Boolean expressions:

<Boolean expression> ::= <simple Boolean> | <if clause>
        <simple Boolean> else <Boolean expression>

And another, rather intimidating example from the Revised Report (also illustrating how this works as an expression):

if if if a then b else c then d else f then g else h < k

This also works with goto, which jumps to a label (designational expression):

<designational expression> ::= <simple designational expression> |
        <if clause> <simple designational expression>
        else <designational expression>

p.e. (again from the Revised Report)

Town [if y<0 then N else N+1]
if Ab<c then 17 else q[if w ≤ 0 then 2 else n]

to be used with goto:

<go to statement> ::= goto <designational expression>

p.e.

goto if Ab<c then 17 else q [if w<0 then 2 else n]

What about that index in conjunction with a label, as in “q[n]”, you may ask? Like in:

goto Town [n+1]

Well, this is a switch, declared in a switch statement and used to determine the effective label by index from the list provided in the declaration:

switch S:=S1,S2,Q[m], if v>-5 then S3 else S4
switch Q:=p1,w

BTW, labels are also valid arguments and may be passed to procedures.

Fun fact: Speaking of Boolean expressions, besides the usual Boolean operators, there’s also implication (⊃):

a      false false true  true
b      false true  false true
-----------------------------
a ⊃ b  true  true  false true

So much for today’s episode of “Fun with Algol 60”… :slight_smile:

1 Like

In a similar vein… At uni (c1980) they taught us COBOL. Or they tried to. What I learned a couple of months was that the lecturer was teaching us his particular variant of COBOL which based on the standard his previous employer (a bank) enforced. I found it frustrating so quietly ignored it until I bothered to buy a book on COBOL and learn it from the book. And that was my “AHA” moment for COBOL. I almost enjoyed writing in it after that - of-course my programs looked nothing like what the lecturer wanted them to look like but because they were still readable an functional he couldn’t mark me down. Almost regretted it come the Y2K stuff, but hey ho, if I’d stuck with COBOL, I’d have been working for a bank, wearing a suit and fighting a anachronistic hierarchy what would just have done my head in.

-Gordon

I haven’t written a lot of A60 myself but I feel like I know it because of its similarity to two other languages I’ve used a lot more: Imp and Coral60. Anyway, I put together some Algol 60 resources online if they’re of help to anyone - a bunch of test code and a formatter I wrote to convert Algol source files to publication syntax as used in periodicals like the CACM. Here’s the NUMAL sources for example, https://gtoal.com/languages/algol60/TESTS/NUMAL/SOURCES.a60.html and the code and various compilers and stuff can be found under https://gtoal.com/languages/algol60/?C=M;O=D
By the way - a bugbear of mine is when someone releases a so-called Algol 60 compiler that only supports reserved keywords and doesn’t support stropping. A complete waste of time - whatever those monstrosities are, they’re not Algol.

2 Likes

By the way - a bugbear of mine is when someone releases a so-called Algol 60 compiler that only supports reserved keywords and doesn’t support stropping. A complete waste of time - whatever those monstrosities are, they’re not Algol.

I tend to agree, Algol 60 was defined that way better or for worse.

In the 60’s it was all the rage to write a Algol compilers for a PHD then in the 70’s Pascal compilers and the 80’s C compilers.
While I see where reading computer history, politics sure kept computers and
computer science from advancing. I would like to say keep your foul accent marks, give useful symbols like >= for program writing, to all the people debating ASCII, in the 1960’s.
Could they not read ‘AMERICAN stan.’ and stick to latin characters. Could they not have added ‘lower case’ letters in 1961. The loss of left and up arrows was real loss.
I think stropping and not having a real character set hampered ALGOL in making it as production language. Ben,

On the influence:

ALGOL 60 also heavily influenced the Combined Programming Language (CPL), developed in the 1960s but not implemented until the following decade. CPL in turn led to Basic CPL (BCPL), from which B descended. The B language was further developed to become C.

C is far far away from Algol. Where readability of the algoritm was key in Algol, yhence the name, it was lost in the obscurity of C.

1 Like

It is writer of the code, that makes readbility. The fact that the reference languge
is formated nicely on the printed page in Algol does not mean the version
on cards looks anything the same, High level languges model a abstract machine,
and just what this model reflects are Ideas what a computer computes. Character
and string data types were bearly defined in hardware,in late 1950’s so it took
a few years for them reflect in programing languages, after Algol 60.
Programming langages, have hardware limitations that are glossed over
from the abstract machine, giving subset compilers when implimented,on
less powerfull machines.
Ben.

It’s important to note that Algol was first meant as a language for describing algorithms and only a programming language in the second place. (Greek letters, etc, are perfectly ok!) So, a “machine implementation” of Algol is somewhat like how APL relates to Iverson’s description language. (In favor of Algol, we may note that it’s still somewhat more read- and typeable. :slight_smile: )

This is also of note for some of the more obscure features of Algol, as this is not only about how to elegantly implement a procedural algorithm, but about being able to provide a description of any algorithm we may think of. (There are probably some edge cases, where what we may desire for a safe and error-avoiding machine implementation doesn’t also satisfy the needs for an understandable description.)

For example, we may provide a full description in Algol of how (and why) Napier’s bones (or a German Rechentisch, or Pre-Columbian wire knots, or even computations in cuneiform) operate and use the same language to implement this on a machine (with some compromises on the character set available), which is quite remarkable.

PS I’ve collected every Algol60 program I can find and added them to my test suite: https://github.com/gtoal/uparse/tree/main/tests

1 Like

How do you handle all the weird ALGOL characters like ‘10’ or ‘>_’ . **ED do you handle over strikes yet? ** :slight_smile:

I only wrote one or two programs in Algol for the TR 4 because I tended to use FORTRAN and COBOL as a business information technology student. This programming language was used more by electrical engineering students. But I know that artists like Frieder Nake used them on this computer. An example can be found here: Walk-Through-Raster. Serie 7.3-1 | ZKM.

Almost everything is supported by Unicode nowadays. There are a couple of constructs that don’t map to unicode (eg string quotes using < overstruck with |) but which can be represented in HTML using overstrikes (see https://gtoal.com/languages/algol60/a60tohtml/overstrike.html ). I’m using the underlined characters in unicode rather than overstriking an underline. I wrote a program to read most forms of Algol input, and output the canonical Unicode version in my Unicode parser.

Did you encode keywords like BEGIN for example?

Thanks for that. My “Ah Bisto” moment having spent early years on Algol 60, then Coral 66 with a splash of SID and SAG courtesy of RSRE Malvern.

What is SID and SAG?
Did any one ever a design a language easy write a a compiler for,
using spaces to separate tokens, or not on the largest main frame with
virtuial memory?
Looking up Coral 66 on the web now, still need to find some real program
examples to tell if how the defined langage differed from the production langauge?

I would have to check it but a collection of software I wrote in 1974-6 for a routing-table generator was in Coral 66 as far as I recall - it was hosted on an STC ITT3200 switch so may have been an STC-flavour of Coral - the main switch programs were a mix of “clever” machine code to achieve performance sampling telegraph lines, and the main system functionality might have been Coral but the programmers were old-style if then goto fiends and we (the customers) were going to have to maintain their spaghetti, poorly structured and uncommented code - we wrote other programs to analyse the code for errors (many) and find where the performance wasting was occurring. Even built a sound monitor to spot patterns of system behaviour and target code inspection and require the company to improve the code. I’ll have to scavenge in the man-cave to unearth it.

Sorry, Oldben, missed the SID and Sag part :blush: They were two RSRE tools used in their compiler research, not sure about SID but SAG was a Syntax Analysis Generator and they published documents which explained what and how they worked. part of my intro to compiler basics in the mid-60’s.

Do you still have course material for the compiler basics?

Fraid not a formal course; like so many of us early birds, one read up on a topic and attended talks to glean a wider knowledge from various research establishments’ experts. An early form of CPD I guess.

Hi, Had a ferret in my papers and recovered 3 source codes for Coral 66 programs written in 1972-76. Each printed out on line -printer and a bit faded in one case but legible. The major one covered analysis of a routing table followed by allowing editing then recreation of a replacement table for loading into an STC ITT3200 switch, so largely text manipulation based on building a push-down stack, tree snip and edit, then unpacking the stack to create the new table - all in Coral 66. A second one did a search for Coral text words that influenced program flow and output the input text indented to help one see that flow. So little or no maths or clever bit/nibble/bytes grammar used in these examples. Any use? I can photo some pages if that needed. Original machines, tapes long disused and part of a old military system so no help that way…

A second one did a search for Coral text words that influenced program flow and output the input text indented to help one see that flow.

Hah! By coincidence I did one of those as well ( /work/www.gtoal.com/languages/coral66/formatter/c66tohtml.e.txt ) although I didn’t have a lot of Coral66 source to test it on other than https://history.dcs.ed.ac.uk/archive/os/deimos/ercm09/emas-2900/coral2.txt .
I believe the Bloodhound Missile Preservation Group ( www.BMPG.org.uk has some voluminous Coral66 sources that do plenty of maths but I’d be very surprised if they ever get HMSO clearance to put them online.

1 Like