This post was originally posted on LinkedIn.
For some people, old programming languages are ugly, obsolete, old-fashioned and useless. For me, they're the complete opposite...gems waiting to be rediscovered.
An old programming language can teach you a lot and can make you for sure a better developer. People today are getting used to have everything provided by the language and that's bad because it doesn't force you to think. Old programming language lack a lot of things that you find in modern languages, but that doesn't mean they're not as powerful, as they provide you all the tools to implement things yourself.
To illustrate how those programming work, we're to use a very basic app called "Fibonacci List" which will simply output a list of requested Fibonacci numbers, for example if we ask for 5, it should return 0, 1, 1, 2, 3, 5.
Let's start with the oldest programming language I know...
FORTRAN (Formula Translator - 1957)
A general-purpose, imperative programming language that is essentially suited to numeric computations and scientific computing.
program fibonacci
implicit none
integer :: a=0, b=1, num
write(*,'(a)',advance="no") "Enter a number: "
read(*,*) num
write(*,*) trim(fib(num, a, b))
contains
recursive function fib(num, a, b) result(fibo)
integer, intent(in) :: num, a, b
integer :: ab
character(1000) :: a_s, b_s, ab_s
character(1000) :: fibo
if(a > 0 .and. num > 1) then
ab = a + b
write(ab_s, '(I0)') ab
fibo = trim(ab_s) // " " // fib(num - 1, ab, a)
else if (a == 0) then
ab = a + b
write(a_s, '(I0)') a
write(b_s, '(I0)') b
write(ab_s, '(I0)') ab
fibo = trim(a_s) // " " // trim(b_s) // " " //
trim(ab_s) // " " // trim(fib(num - 1, ab, b))
else
fibo = ""
end if
return
end function fib
end program fibonacci
Let's see...A program must be enclosed between "program" and "end program" tag. Variables need a type when they are declared. A recursive function must be labeled as "recursive". String variables are fixed in length. "//" is used to concatenate. Integers and Character can be concatenated together without further transformations. We need to trim a lot to avoid extra space due to the really long fixed size. Functions can return zero, one or multiple values.
To compile this...I used GFORTRAN which come with Linux, but can be simply installed by doing "sudo apt-get install gfortran". Being a GNU App...this is not a real Fortran compiler...it's written in C.
GFORTRAN -WALL -C "NAME_OF_FILE.F95"
GFORTRAN -WALL -O "NAME_OF_EXEC" "NAME_OF_FILE.F95"
You can read my FORTRAN Introduction here.
Cobol (Common Object Business Oriented Language - 1959)
A compiled English-like computer programming language designed for business use.
It's imperative, procedural and since 2002, Object Oriented.
IDENTIFICATION DIVISION.
PROGRAM-ID. fibonacci.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 USER-NUMBER PIC 9(3).
01 A PIC 9(3).
01 B PIC 9(3).
01 AB PIC 9(3).
01 COUNTER PIC 9(3).
01 COUNTER-SPACES PIC 9(3).
PROCEDURE DIVISION.
PROGRAM-BEGIN.
MOVE 0 TO A.
MOVE 1 TO B.
DISPLAY "Enter a number: ".
ACCEPT USER-NUMBER.
PERFORM GET-FIBO WITH TEST AFTER UNTIL USER-NUMBER = 1.
DISPLAY " ".
PROGRAM-DONE.
STOP RUN.
GET-FIBO.
IF A = 0
COMPUTE AB = A + B
INSPECT AB TALLYING COUNTER FOR CHARACTERS
INSPECT AB TALLYING COUNTER-SPACES FOR LEADING ZEROS
COMPUTE COUNTER-SPACES = COUNTER-SPACES - COUNTER
DISPLAY 0 " " 1 " " AB(COUNTER:COUNTER-SPACES) WITH NO ADVANCING
COMPUTE USER-NUMBER = USER-NUMBER - 1
MOVE AB TO A
ELSE
MOVE 0 TO COUNTER
MOVE 0 TO COUNTER-SPACES
COMPUTE AB = A + B
INSPECT AB TALLYING COUNTER FOR CHARACTERS
INSPECT AB TALLYING COUNTER-SPACES FOR LEADING ZEROS
IF COUNTER-SPACES = 0
DISPLAY " " AB WITH NO ADVANCING
END-IF
IF COUNTER-SPACES = 1
COMPUTE COUNTER = COUNTER - COUNTER-SPACES
DISPLAY " " AB(COUNTER:COUNTER) WITH NO ADVANCING
END-IF
IF COUNTER-SPACES = 2
COMPUTE COUNTER-SPACES = COUNTER-SPACES - COUNTER
DISPLAY " " AB(COUNTER:COUNTER-SPACES) WITH NO ADVANCING
END-IF
COMPUTE USER-NUMBER = USER-NUMBER - 1
MOVE A TO B
MOVE AB TO A
END-IF.
As we can see...Cobol is very strict...it has "divisions" and "sections". Variables need to be declared first and cannot be declared anywhere else outside it's section. Moving a value into a variable is not the same as assigning a value to a variable. There is no such thing as IF-ELSE. You can inspect a variable to get its length or amount of zeros.
I know you're wondering what the heck "PIC 9" means...well..."9" is for numeric values, "X" for alphanumeric, "S" for sign and "V" for decimals.
To compile this...I used Open-Cobol that can be simply installed by doing "sudo apt-get install open-cobol". Being a GNU App...this is not a real Cobol compiler...it's written in C.
COBC -X -FREE -O "NAME_OF_FILE" "NAME_OF_FILE.COB"
You can read my Cobol Introduction here.
Simula (Simulation Programming Language - 1962)
Superset of Algol 60. Consired the first Object Oriented programming language.
begin
integer num;
text result;
procedure fib(num, a, b);
integer num, a, b;
begin
if a > 0 and num > 1 then
begin
OutInt(a+b,3);
fib(num - 1, a + b, a);
end;
if a = 0 then
begin
OutInt(a,3);
OutInt(b,3);
OutInt(a+b,3);
fib(num - 1, a + b, b);
end;
end;
OutText("Enter a number: ");
OutImage;
num := InInt;
fib(num,0,1)
OutImage;
end
Every program start with a "Begin - End". Variables need a type. We can have global and local variables. "OutInt" is used to print Integers on the screen while "OutText" is for strings. OutImage is used to print an empty line. Integer variables are assigned using "=" while String variables use ":=".
To compile, I used GNU CIM which is a transpiler from Simula to C. You can install it from here.
cim "NAME_OF_FILE.cim"
You can read my Simula Introduction here.
Snobol (String Oriented and Symbolic Language - 1967)
Imperative and Unstructured programming Language. Also, it's goal oriented.
* Fibonacci Sequence
define('fibo(num,a,b)temp','fib') :(fibo_end)
fib fibo = eq(a,0) a ' ' b ' ' ( a + b )
num = num - 1
a = a + b :s(fib0)
fib0 gt(num,1) :s(fib1)f(return)
fib1 fibo = gt(a,0) fibo ' ' ( a + b )
num = num - 1
temp = a
a = a + b
b = temp :s(fib0)f(return)
fibo_end
output = 'Enter a number: '
num = input
output = fibo(num,0,1)
end
Variables doesn't need a data type, it's type depend on the assigned value. When defining a method we need to specify what to call when it ends or fails. For each section we need to determine if it works or not and depending on that move to another section. An "If" condition needs to be by itself and move to other section depending on the result. In this example "gt(num,1)" is an "If" statement.
To compile we need to first build the compiler...which is by the way a C app.
WGET FTP://FTP.ULTIMATE.COM/SNOBOL/SNOBOL4-1.5.TAR.GZ
TAR –ZXVF SNOBOL4-1.5.TAR.GZ && CD SNOBOL4-1.5
SUDO APT-GET INSTALL M4
SUDO MAKE INSTALL
To run we need to do...
snobol "NAME_OF_FILE.sno"
You can read my Snobol Introduction here.
Algol68 (Algorithmic Language - 1968)
Part of the Algol family of imperative programming Languages (Algol58, Algol60 and Algol68). One of the most influential languages of all time, giving rise to Simula, B, Pascal and C amongst many others.
BEGIN
print("Enter a number: ");
INT num = read int;
PROC fib = (INT num, a, b)VOID:
IF a > 0 THEN
IF num > 1 THEN
printf(($g(0)x$, a + b));
fib(num-1, a+b, a)
FI
ELIF a = 0 THEN
printf(($g(0)x$, a + b));
fib(num-1, a+b, b)
FI;
printf(($g(0)x$, 0, 1));
fib(num,0,1);
print(newline)
END
All applications start with a BEGIN-END. Variables need a type. Procedures can have zero or more parameters. The last value is returned and a value must be always returned. When printing a number, the sign will be displayed, that's why we need to format its output. This one most likely the first programming language to use "ELIF", and also "FI" to close an "IF" statement. ";" is used to end a line.
To compile, we need to first install Algol68Genie
SUDO APT-GET INSTALL -Y ALGOL68G
Then we can simply do...
a68g "NAME_OF_FILE.a68g"
You can read my Algol68 Introduction here.
Bonus Section
I know...five is not enough...so why not include a bonus language...one that always interested me as the name seems kind of weird for a programming language -;)
Smalltalk (1972)
An object-oriented, dynamically typed reflective programming language.
Smalltalk had influenced many languages like Objective-C, Java, Python, Ruby and many more...
| number fib result |
result := ''.
fib := [:num :a :b |
a > 0 & (num asNumber > 1) ifTrue: [
result := result , (a + b) asString , ' ' ,
(fib value: (num asNumber - 1) value: (a + b) value: a).
] ifFalse: [
a = 0 ifTrue: [
result := a asString , ' ' , b asString , ' ' , (a + b) asString , ' ' ,
(fib value: (num asNumber - 1) value: (a + b) value: b).
].
].
].
Transcript show: 'Enter a number: '.
num := stdin nextLine.
Transcript show: (fib value: num value: 0 value: 1); cr.
Variables are declared between "|". Values are assigned using ":=". "IF" statements are special as they are defined as "ifTrue" and "ifFalse" and "[ ]" are used to enclosed blocks. We use "Transcript show" because otherwise a text will be printed enclosed like this 'This is a text' instead of This is a text. If you wonder about "value:", that's used to call a parameter.
To compile, we're going to use GNU Smalltalk, that can be installed like this
sudo apt-get install gnu-smalltalk
and them simply...
gst "NAME_OF_FILE.st"
You can read my Smalltalk Introduction here.
That's it -:) Hope you had some fun -;) I had a lot of fun learning them...and they surely made me a better developer...and yes...I frustrated me plenty of times...but that's the fun of programming -;)
Blag.
Top comments (33)
Awesome read :)
Thanks Anja 😄
great article!
"David West's book Object Thinking" is an amazing book @history_dev
Simula?!?
Wow, I believed I was the only one knowing that...
☺️ I’m addicted to programming…so I do a lot of research on old programming 😉
This is a great article, read a lot about Smalltalk in David West's book Object Thinking which I believe is a must read. I'm really pleased to discover you can still run it, will give it a go!
Also Algol is interesting because supposedly it was inspired by Plankalkül, created by Konrad Zuse and regarded as the first high-level programming language.
Thanks @history_dev Smalltalk is pretty cool, you're going to like it -;)
And yes...I think it was inspired by Plankalkül....I tried to learn it but couldn't find a compiler...or tutorial...and it also looks too weird -:P
Smalltalk is very declarative and not so procedural.
The example you put on the article is not very fair to the language
My fault 😔 Haven’t dig too deep on Smalltalk…but at least it compiles and works 🤓
dude fortran is dead no one uses it now we use C,C++,Java,Python,JS,TS,Ruby,etc
Such a statement is unfounded. Fortran is a niche language. Its usage is proportional to the size of the community it supports. Fortran is designed for scientists and engineers who specifically need high-performance computing. That community is small, but it does not mean that they do not exist. It's a tiny community, but it is running the world as of today without anyone noticing it. If you checked the weather today, that was the work of Fortran. Just one example.
Couldn’t had explained it better…thanks -:D
It’s not a matter of who use it or who doesn’t…learning about the past is important to learn about the future -;)
try to understand dude C is okay but fortran is no use for now
Trying saying that to this guy manning.com/books/modern-fortran He’s uses Fortran everyday -:) But hey…we all have our own points of view -;)
I have the same though as for half of the existing populars (go, java, rust...). I don't see the usecase to choose any of em' instead of c++.
[tl;dr]
Funfact, in the Nordic region (Sweden, Norway) used Cobol and Fortran for their tax and retirement fund handling. The people who designed the system, they still work for the government (age over 75); nobody dare to touch the system because:
But in fact they do burn literal millions to just maintain (every year they try to train hunders of youngsters; adding java based services; reginal servers; data centrals and so on).
The codebase so large, so slow, so slow to compile it is unbelivable (we talking about days). On a more modern approach they probably would be able to drop their expenses by 90% (do not need hunderds of devs, do not need half building amount of servers...), but this will not change any time soon... except, if the old folks finally retire :D
It’s not about use cases…it’s about being aware of them…knowing a little bit of how they work…I don’t use any of them for work…but I still enjoy learning them and using them once in a while…without them…we wouldn’t have any of the new and shiny ones 😉
This article has nudged me to go back and look at one of my old favorites: APL (A Programming Language), now A+ I believe. It's handling of multi-dimensional arrays could not be beaten back in the day. Many Thanks.
I tried APL…but it needs a special keyboard unless there are emulators which I haven’t found…will check out A+ -:) APL interests me although its syntax is so weird
Interesting interpretation of "old" - as I didn't recognise that style of Fortran code. Some quick checking confirms that recursion didn't get added until after both of the two versions I was formally taught at university - Fortran IV in 1980 and Fortran 77 in 1986.
Incidentally that gives you an idea of the academic delays in those days. I seem to recall the lecturer in 1986 being very pleased to say we were learning the "new" Fortran.
To get a sense of how limited Fortran IV was see here - FORTRAN 66
In my memory any difference between "IV" and "77" is overshadowed by the fact that I had to use punched cards for the former and then had the luxury of using a "glass teletype" for the latter.
Indeed, 1986 was a strange year - as at that same time I was doing other units that had me using VAX Pascal in one and using a Macintosh-based emulation of a PDP-8 to do assembler programming. Neither of these were a "learning" experience as I'd already been hobby programming a Z80 in hex and using Turbo Pascal on CP/M.
Yup…you’re right…what I found was a newer compiler and a not so old Fortran book…
ASM is something I want to learn…but last time I didn’t get past trough Hello World LOL
Thanks for sharing! Decades ago I started with Quick Basic 🙂 Funny it has
let
keyword to define variablesGlad you like it -:) Quick Basic is a classic -;)
Interestingly enough I had to take a required class on FORTRAN in 2017 for my physics degree. People are always blown away when I tell them it's the first language I learned lol
I haven't touched it since that class but I always mean to go back and mess around with it for a personal project at some point. Thanks for the blog post!
Happy that you like it -:) FORTRAN is one of my favorite languages...but amazes me that they taught it you on 2017....anyways...if you're looking for more...I can recommend this book manning.com/books/modern-fortran It's really nice -:D