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

Regarding how some things were much more versatile in ALGOL 60, but also a bit underdefined in terms of implementation, compare this section from the Revised Report on procedures:

5.4.6. Code as procedure body. It is understood that the procedure body may be expressed in non-Algol language. Since it is intended that the use of this feature should be entirely a question of hardware representation, no further rules concerning this code language can be given within the reference language.

From a stand point of a fully defined language, this may be quite a gapping omission, however, from the stand point of a high-level definition language, which happened to be a programming language, as well, it may have been wise to leave this (and how this may be encapsulated) to the particular implementation. (Especially, given the variety of hardware available at the time and what external mechanisms may have been available or not.)

I also started with Algol/ESPOL, Pascal and was learning Ada when I ran across C. I really enjoyed the different syntax though still like the old style in VHDL, but not so much in Oberon.

A friend, on the other hand, started all his C programs with

#define BEGIN {
#define END }
#define AND &&
#define OR ||

and so on. The rest of his C program was in Pascal syntax. I thought it was far less readable. But when I see new languages copy C and claim as a feature their “intuitive syntax” I have to laugh. They should have used the word “familiar” instead.

3 Likes

For an example to the contrary, some time ago I was musing about having a higher level language for writing Web Assembly code without losing any of the more assembly-like directness. As it happens, there’s already PL/M (the language Gary Kildall used to implement CP/M), which has all the desirable features – no need to reinvent the wheel. However, no one, including myself, would buy an ALGOL-like syntax nowadays. Therefore, it seemed reasonable to introduce C-style brackets, etc, as an alternative syntax. Just the other way round as in your example. tempora, mores, etc.! It’s all about familiarity. (BTW, nothing has come of this in terms of an actual project yet.)

I once worked in a team whose product was an in-house CAD system, written in Pascal. But it was said of one of the team that he wrote in Fortran. I’ve certainly heard the phrase ‘you can write Fortran in any language.’

Writing Fortran in a new $LANGUAGE is a great way to learn the language. “Fortran” is pretty simple. Simple Fortran is simple. Things like COMMON blocks and COMPLEX numbers don’t move well, but the rest does. It’s a solid “lowest common denominator” language and has the significant broad concepts (variables, expressions, iteration, I/O – these will take you far).

Some languages are more accommodating than others, but nevertheless it gives you a leg up in adopting that language.

Simply, when approaching a new language, just try to do a 1:1 translation of Code You Know in $YOUR_LANGUAGE, and convert it in to $LANGUAGE. In the end, you should have something that works, that translates what you knew in the old language in to constructs in the new language.

What you don’t have, in the end, is an idiomatic version of your code. But that’s OK. Because now you can hit the same code again, but this time from a point of view of adding $LANGUAGE idioms and constructs in to your “working code”.

There’s still hurdles not doubt. Especially some of the modern functional languages etc that don’t look at all like what you’re used to. But when you’re “uplifting” something from a less expressive language to a more expressive language, then, ideally, you should be able to more or less get a pretty much straigh across conversion.

I liken this experience to what I had learning Lisp and Scheme. These languages always flumoxed me, reading them I would see concepts that were simply opaque to me, mostly because of the vocabulary used. Everyone loves LAMBDA, CDR, CAR, CADR.

But then I ran across a book “Simply Scheme”.

Simply Scheme used it’s own vocabulary early on. Its skipped the opaque, meaningless words. The word LAMBDA actually has a lot of history and weight behind it, and carries implications with it. But if you don’t know it history, at a glance, you’re pretty much out of luck.

Acting as a Rosetta Stone of sort, Simply Scheme jumped over that problem. Once I essentially learned “Lambda” meant “function”, it was an AHA moment and I could then proceed to write “Fortran in Scheme/Lisp”.

Much akin to “make it work, then make it fast” you can apply “make it work, then make it idiomatic”.

The original Bourne shell by Steve Bourne was famously written in “Bournegol”, which was this plus some other, similar constructions. (Its source can be browsed on TUHS.) It contains such gems as this (a random selection from some quick browsing):

LOCAL TREPTR	list(flg)
{
	REG TREPTR	r;
	REG INT		b;

	r = term(flg);
	WHILE r ANDF ((b=(wdval==ANDFSYM)) ORF wdval==ORFSYM)
	DO	r = makelist((b ? TAND : TORF), r, term(NLFLG));
	OD
	return(r);
}

It also, as discussed in the Bournegol thread linked above, uses some creative abuses of SIGSEGV to manage its memory handling, which reportedly turned out to be problematic in some Unix ports.

Remeber this is the late 1950’s. The often the only addressing mode was direct addressing. You had arguments over open and closed subroutines. IBM and the 7 dwarves (USA) were the only computers you could get unless you built your own. I still have not figured just what a Algol routine does, but it reflects the thinking of that era.
Here the history of Why it was done that way, is very needed lesson.
Ben.

Interestingly, I just read the term “open subroutine” last night. The strange thing is, it is in a book from the mid-eighties! The book is The Digital Way: MACRO-11 Assembly Language Programming by James F. Peters. It was published in 1985, by which point I would have expected the word “macro” to have completely replaced “open subroutine” in any normal use — and particular when using MACRO-11! (All in all, it is not a terribly good book; it appears to be the classic sort of textbook which is really just a collection of course notes from some specific course, bound up and sold mostly to the students of a particular college where that course is taught. It’s not horrible, but I don’t think I’d bother to buy it again.)

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?