Bjarne Stroustrup and James Gosling both credit it as a major influence in the design of their languages. Built on top of Algol 60, it is the progenitor of the most popular, and reviled program paradigm, Object Oriented Programming. Designed by Ole-Johan Dahl, and Kristen Nygaard in 1962 at the Norwegian Computing Center in Oslo, it easily cracks the top 10 most influential computer programming languages ever invented. But in 2023 it is a distant memory. Having never reached the popularity of older languages still in use like Fortran, Lisp, and COBOL, I was curious to see what programming in this 60+ year old language would look like. But first I’d have to find a way to run it.
It usually isn’t too hard to find working implementation of just about any programming language you want, even the old ones, but Simula’s was harder than I was used to. After extensive searching I stumbled upon Gnu Cim
. The landing page for Gnu Cim said…
See the software page for information on obtaining GNU Cim and other GNU software.
Great! Exactly what I was looking for. I clicked the link, scrolled down to the “All GNU Packages” section, and clinked on the Cim link (Lol). Annnd it sends me right back to the original Gnu Cim landing page. Not to be deterred, I did some more digging until I came across an FTP site with multiple versions of GNU Cim
. I saw a Win32 folder in the directory and clicked it.
I looked at the install.txt for the Windows folder, noticed the note for Windows 95/98 users, and immediately decide to just use WSL instead.
I download the tar.gz…
-
I run
tar -xzf
-
I
cd
into the unzipped folder and read the INSTALL file -
I do the simple install with
./configure
,make
, andmake install
-
And I read the installed documentation using
info cim
At this point I’m feeling like a real graybeard. I only have one thing left to do. I fire up Nano, type the magic incantation…
begin
Outtext("Simula does it in C");
Outimage;
end
and…
I know nothing about C, and a segfault is pretty cryptic. I try it on my RPI 4 to make sure it isn’t an WSL thing but that doesn’t work either. So, it’s back to looking for another implementation. After a few more failed attempts I find a browser based Simula compiler
. But unfortunately, when I try to type in some examples, I get a bunch of errors. After much searching, I do end up finding a version that works
. It’s called Portable Simula, and it’s based off the 1985 Simula standard. It requires openJDK 19 for some of its features but after downloading and running java -jar simula.jar
I’m finally greeted with a working Simula Environment.
Portable Simula conveniently gives us an editing environment along with the language. It provides basic functionality like saving, syntax highlighting, and even allows us to build and run the program from within the editor. It also provides us with a variety of sample programs written in Simula for us to study. The website comes with a document for the language standard
, complete with Backus-Naur notation, and a 200+ page text book
to get us started.
Simula operates on blocks of code. Following in the footsteps of our programming ancestors we can invoke the sacred “Hello World” program by typing…
begin
OutText("Hello World!");
comment my first program;
end;
While later programming languages would use curly braces and whitespace, Simula uses keywords to denote logical blocks of code, which was common at the time. Furthermore, everything not enclosed in double quotes is interpreted as uppercase, so both beGIN
and BEGIN
are interpreted the same way. This was also characteristic of the time, as programmers programmed their computers by shouting. OutText
is a built-in function. It works like print
in other languages. Simula calls these functions System Procedures, or just procedures. Statements end with a semicolon and comments start with the keyword comment
.
Simula can work with numbers as well as text. Below we can see an example adding two numbers together.
begin integer Int1,Int2; integer Result; Int1:=3; Int2:=4; Result := Int1 + Int2; OutInt(Result, 1); OutImage end
Note that integers can be declared on 1 line as shown with integer Int1,Int2;
or by itself as shown with integer Result;
The variables can be assigned values with the :=
operator. OutInt
is used to “print” the integer, and OutImage is called to build the final Simula “Image”. From my digging it appears that OutImage is usually necessary at the end of a block, or a compiler error will be generated. I initially forgot OutImage
though so, I imagine that maybe Portable Simula is just implicitly adding this if it’s missing, or it was changed in a later standard. Regardless I’ll leave it in from now.
Working with text in Simula is a little different than with numbers. You can’t just do
begin
Text message;
message := "Howdy";
OutText(message);
OutImage;
end
As you will get a runtime error. Instead you need to swap “:=” with “:-” like this
begin Text message; message :- "Howdy"; OutText(message); OutImage; end
The reason we have to use “:-” instead of “:=” is because we can’t assign a string to a text variable that is longer than the text variables length. Referring to our Simula text book we see this note about text.
Strictly speaking the location reserved for the text variable holds a reference to a sequence of
characters. These characters are known as a text frame. A text reference contains a pointer to its text
frame plus related variables and procedures.
So a text frame needs to be large enough to hold the characters you want it to. In the first example
Text message;
message := "Howdy";
The message variable’s length
is 0. In the second example, message is given the value of “Howdy” and the text frame contains enough space for its 5 characters.
message :- "Howdy";
OutText(message);
Now that message has a value and a length > 0, you can mutate it.
begin
Text message;
message :- "Howdy";
message := "Hi";
OutText(message);
OutImage;
end
Mutating a text variable with :=
does not automatically update the “length” property of a text variable. If you were to call message.Length
you will see that it is still 5.
If in the above example you were to try to assign message to a string longer than 5 like for example “Hello There”, you will get a runtime error.
Text frames also have positions. Positions are the location of the next character that will be read with the GetChar
method.
Defining functions (or procedures in Simula parlance) is different then you may be used to.
begin
procedure SayHello;
comment Keyword Procedure;
OutText("Hi There");
procedure Square(T); Integer T;
begin
OutInt(T*T,4);
OutImage;
end--of--square--proc;
procedure Add(num1,num2,result);
! Adds to numbers together and stores in result;
name result;