COMAL
The Common Algorithmic Language, designed in Denmark by schoolteacher Børge R. Christensen and computer scientist Benedict Løfstedt to give students Pascal's structure inside BASIC's interactive environment.
Created by Børge R. Christensen and Benedict Løfstedt
COMAL (Common Algorithmic Language) is a teaching language designed in Denmark in 1973–74 by Børge R. Christensen, a mathematics teacher, and Benedict Løfstedt, a computer scientist. It kept what made BASIC easy for beginners: line numbers, an interactive interpreter and instant error messages. To that it added the control structures and named procedures of Pascal. The result became the standard school programming language in Denmark, spread to Ireland, Sweden, the UK and a Commodore enthusiast community in North America, and was one of the earlier structured languages to be widely available on 8-bit home computers.
History and Origins
A Nova, a bad BASIC and a meeting at Aarhus
In 1972 the Tønder Statsseminarium, a state teacher training college near the German border, received a Data General Nova 1200 minicomputer. Christensen had joined the college in 1971 as a mathematics and physics teacher and was given the job of teaching programming on it. The only language was Data General’s Extended BASIC. The Nova had no disk, only paper tape and teletypes. In his later account Christensen said the student programs were so hard to read that he often had to draw diagrams just to mark them.
Looking for help setting exam problems, he visited Aarhus University’s computer science department (DAIMI) and met Benedict Løfstedt. Løfstedt told him the problem was the language, not the students, and pointed him to Niklaus Wirth’s new book Systematic Programming, which presented Pascal. Christensen liked what he read but did not think Pascal would work for his students, because they would have had to deal with an editor, a compiler and an operating system. BASIC’s advantage was its interactive environment, where you type a line and run it immediately.
Design by post
Christensen and Løfstedt corresponded for about half a year and designed a language that kept BASIC’s environment and added Pascal’s structures. They had a first definition by early 1974. Christensen later described the result as “not really a programming language of its own, but rather a set of extensions to be put on top of an existing BASIC.” A large company asked for $50,000 to implement it. Two of Christensen’s students, Knud Christensen and Per Christiansen, offered to do it for free. They wrote it in Nova machine code, starting from Data General’s Extended BASIC source, which Christensen had obtained through Regnecentralen.
The first COMAL program ran on 5 August 1974. It was a five-line REPEAT ... UNTIL loop with automatic indentation. In February 1975 a version was ready to distribute on paper tape. Loading it on a 10-character-per-second teletype took an hour. Christensen said the whole implementation cost $300.
The first version had three main additions:
- Long variable names of up to eight characters, where the BASIC it replaced allowed only one or two. Christensen thought this was the main reason students adopted COMAL.
- Multi-line
IF ... THEN ... ELSE ... ENDIF, nested up to four levels. - Named procedures (
EXECUTE PRINTOUT…PROC PRINTOUT…ENDPROC), without parameters at first. According to Christensen, the interpreter linked each call directly to its procedure, so a call jumped straight to it instead of scanning line numbers the way a BASICGOSUBdid, and this made calls faster.
The project had a Danish working name at first. Christensen came up with “COMAL” while cycling home from the college. The group had been working with ALGOL (ALGOrithmic Language), and he turned that into COMmon Algorithmic Language.
COMAL 75, COMAL 77 and Regnecentralen
Most Danish colleges of the same type had Data General Novas, because a local Danish company distributed them. According to Christensen, they had switched from BASIC to COMAL within about half a year. The Danish computer maker A/S Regnecentralen (RC) ported the students’ work to its RC7000 (a Nova-compatible system) and later to the RC3600 and RC8000. RC released it as “RC BASIC” in February 1977 and renamed it “RC COMAL” that May. Christensen’s 1977 book RUN COMAL describes this improved version, known as COMAL 77.
COMAL 80
As microcomputers appeared around 1978, Christensen worried that Danish schools would buy PETs and Apples and go back to BASIC. He said that if that had happened he would have stopped teaching computing. In 1978–79 he defined a new version with parameter passing and other additions. Løfstedt had moved to Greenland, so Christensen did this second design alone.
A working group of academics and manufacturers took his definition further. Its members came from ICL, Regnecentralen, Dansk Data Elektronik, Roskilde University Center and others, and Tom Østerby of the Technical University of Denmark edited the report. On 25 March 1980 the group issued its Proposal for the nucleus of the COMAL 80 language. It decided that BASIC would no longer be a subset of COMAL. It also kept GOTO only for named labels, because line-number jumps were almost never found in COMAL programs. The name COMAL 80 refers both to the year and to the Z80 processor the first implementation ran on. Regnecentralen shipped RC Comal 80 for its RC702 Piccolo in May 1981.
UniComal, Commodore and the wider world
Around 1980–81 Christensen stepped back from development. One of the groups that took over was UniComal, a small Danish company formed by Jens Erik Jensen, Mogens Kjær, Helge Lassen and Lars Laursen. Kjær had written Christensen a detailed critique of the COMAL-80 definition, and Christensen persuaded him to target the Commodore PET instead of a less promising machine. That work became COMAL 0.14, which was later released for the Commodore 64 in 1984. UniComal then produced COMAL 80 2.0 on a Commodore 64 cartridge, with built-in graphics and support for user-written machine-code packages. Christensen called packages the most important extension to COMAL after his last definition. UniComal went on to IBM PC versions. UniComal 3.11 (1992) ran under DOS, Windows and OS/2.
Other implementations included:
| Platform | Implementer / notes |
|---|---|
| BBC Micro and Acorn Electron | Acornsoft COMAL (1984), by David Christensen, Jim Warwick and David Evers |
| TeleNova Compis (Sweden) | Enhanced COMAL supplied as the standard language on this school computer, for CP/M-86 and MS-DOS |
| Swedish Compis / Macintosh | Mytech’s COMAL, written in C, with a full-screen editor; Christensen said he had not seen the Mac version |
| Apple II with Z80 card | Metanic COMAL under CP/M |
| Amstrad CPC and PCW | A CP/M COMAL that Christensen described as “very much like the UniComal version” |
| Amiga | AmigaCOMAL (versions 3.x by 1989) |
| Unix, macOS | OpenCOMAL, an open-source interpreter by Jos Visser, later forked |
The Danish Data Historical Society (DDHF) also lists DDE’s ID-7000, SPC/1 and Supermax, the ICL Comet, Grundy NewBrain, Memotech MTX and Sinclair ZX Spectrum among machines that ran COMAL. Christensen mentioned VAX and Wicat versions as well.
Which year?
The encyclopedia dates COMAL to 1973, which is when the design began. Christensen and Løfstedt had corresponded for about half a year before the definition was finished at the start of 1974, and DDHF dates the design to “1973–1974”. In a 1981 survey Christensen himself wrote that COMAL was “defined in 1974”. The first program ran in August 1974, and the first release (COMAL 75) came in February 1975. English Wikipedia uses 1975. All of these dates are defensible, depending on whether you count the start of design, the finished definition or the first release.
Design Philosophy
Christensen was clear that COMAL was a practical tool, not a research project. “COMAL is very pragmatic,” he said. “We never took in new facilities and new structures until we felt that the students needed them.” Parameters, for example, were added only after the designers saw that students needed them.
He separated the language from the environment around it. His view was that the only good thing about BASIC was its interactive environment, and that this could be combined with a better language. In the mid-1980s he argued that the language was “more or less finished” and that future work should go into the environment: full-screen editors, symbol listings and help systems. He also campaigned to make line numbers optional, since they had been designed for teletypes.
The design also reflected Christensen’s strong dislike of unstructured BASIC. In a 1981 survey he called GOTO to a line number “the worst and most foolish control statement that was ever hit on.” In his talk he admitted that his Danish-language arguments against BASIC had been harsher still, and that some newspaper articles had attacked him for them.
Key Features
Structured control flow with BASIC’s feel
COMAL programs usually keep line numbers, and the interpreter checks each line as it is typed and indents blocks automatically when listing. The control structures are the ones Pascal programmers would expect, each closed by its own keyword:
0010 // count down, then report
0020 n#:=10
0030 WHILE n#>0 DO
0040 PRINT n#;
0050 n#:=n#-1
0060 ENDWHILE
0070 PRINT
0080 REPEAT
0090 INPUT "Pick 1, 2 or 3: ": choice#
0100 UNTIL choice#>=1 AND choice#<=3
0110 CASE choice# OF
0120 WHEN 1
0130 PRINT "One"
0140 WHEN 2,3
0150 PRINT "Two or three"
0160 ENDCASE
The April 1985 Kernel also defines FOR ... DO ... NEXT loops (some implementations spell the end ENDFOR), IF ... ELIF ... ELSE ... ENDIF and GOTO, which can jump only to a named label. A CASE with no matching WHEN and no OTHERWISE is a run-time error, which is why the example checks the input first. := is assignment and = is comparison. The suffix on a name sets its type: name$ is a string, count# an integer, and a name with no suffix is a real number. In classic implementations strings are dimensioned before use, for example DIM name$ OF 20; the 1985 Kernel also allows dynamic strings, where the OF length is optional.
Procedures and functions
COMAL 80 procedures and functions take value and reference parameters and can be recursive. A CLOSED routine has only local variables, so it cannot accidentally change the caller’s variables:
0200 PROC greet(who$) CLOSED
0210 PRINT "Hello, ";who$
0220 ENDPROC greet
0230 //
0240 FUNC factorial(n#) CLOSED
0250 IF n#<=1 THEN
0260 RETURN 1
0270 ELSE
0280 RETURN n#*factorial(n#-1)
0290 ENDIF
0300 ENDFUNC factorial
The routine’s name is repeated after ENDPROC and ENDFUNC, so the end of each block is clearly labelled in long listings.
Packages
UniComal’s implementations let machine-code (and later C) routines be bundled as packages that are called like ordinary COMAL procedures. Christensen noted that COMAL 2.0 had graphics built in, so drawing a circle took a single keyword, where 0.14 needed a user-written procedure. Christensen considered this the most important addition to COMAL made after his own definition.
Evolution
| Version | Date | Notes |
|---|---|---|
| COMAL 75 | Feb 1975 | Extensions on top of Data General Extended BASIC for the Nova |
| COMAL 77 / RC COMAL | 1977 | Regnecentralen’s improved version for the RC7000 |
| COMAL 80 nucleus | 25 Mar 1980 | Working-group proposal; BASIC no longer a subset |
| COMAL Kernel | Mar 1983 | Common core agreed among implementers (planned from May 1982) |
| COMAL Kernel Syntax & Semantics | Apr 1985 | Edited by Kevin Ryan, Trinity College Dublin |
| Common COMAL | late 1980s | Keyword set and tests published by the US COMAL Users Group in COMAL Today |
International standardization and development meetings ran from 1983 to at least 1987, in Copenhagen, Dublin, Reading, Cambridge, Nynäshamn, Edinburgh, Hornstrup and Portsmouth. The groups tried to make COMAL implementations from different vendors compatible.
Current Relevance
COMAL is a historical language. Its commercial vendors are gone, and the last major commercial release was UniComal’s PC version in the early 1990s. It can still be run in several ways:
- OpenCOMAL, an open-source (GPL) interpreter by Jos Visser, whose last stable release was 0.2.6. A GitHub fork (poldy/OpenCOMAL) patched it for current Linux and macOS, aims at compliance with the Kernel and Common COMAL definitions, and was tagged v0.3.0 in 2018.
- UniComal 3.11 for the IBM PC, preserved on the Internet Archive and runnable under DOSBox.
- Emulators for the Commodore 64, BBC Micro and other 8-bit machines, using the original disk and cartridge images.
There is no Docker image. The Danish Data Historical Society (DDHF) maintains a large COMAL archive, including the 1979–1989 standardization papers, scanned manuals and Christensen’s own articles. It set this up for the language’s 40th anniversary.
Why It Matters
COMAL is an early case of a teacher changing national computing practice. Christensen wanted a language his students could read, and with, by his account, $300 and two students he produced a structured, BASIC-derived language in 1974–75, several years before structured BASIC dialects became common on microcomputers. According to Christensen, Danish schools then effectively made COMAL a condition for buying computers, so manufacturers had to support it. In 1984 he received the first Niels Ivar Bech Prize, a Danish IT award, for spreading and refining COMAL.
The language also showed that the structured-programming ideas Christensen found in Wirth’s book did not require a batch compiler. Named procedures, block IFs and loops closed by keywords, local variables and meaningful names could all work in an interpreter on a paper-tape minicomputer, and later in a 64 KB home computer. Christensen summed up his philosophy this way: “Computers should be as easy to use for human beings as possible. We should be controlling computers, not the other way around.”
Timeline
Notable Uses & Legacy
Danish schools
COMAL replaced BASIC in the Danish colleges that used Data General Novas within about half a year of its 1975 release. Christensen said that by the early 1980s a company could not sell a computer to a Danish school unless it ran COMAL
Regnecentralen RC700 Piccolo and Piccoline
The Danish manufacturer Regnecentralen shipped RC COMAL on its RC7000 and RC8000 systems and RC Comal 80 on the RC702 Piccolo (1981) and later Piccoline microcomputers, which were made for the Danish education market
Irish second-level schools
COMAL was used to teach computer studies in Ireland. Irish textbooks such as John Kelly's Foundations in Computer Studies with COMAL (second edition, 1984) were written for it, and Trinity College Dublin took a leading part in the standardization work
Commodore computers
UniComal, a Danish company, wrote COMAL for the Commodore PET, the Commodore 64 (disk-based 0.14 and the 2.0 cartridge) and the Commodore 128. Christensen taught with Commodore 64s running COMAL
TeleNova Compis (Sweden)
An extended COMAL was the standard programming language of the Compis, a desktop computer that TeleNova made for Swedish schools in the mid-1980s
COMAL Users Group, USA
Len Lindsay's user group in Madison, Wisconsin published the magazine COMAL Today and COMAL books and disks for Commodore owners through the 1980s