What You Can Learn from Obscure Programming Languages
DmitryZinoviev
137 views
28 slides
Oct 08, 2024
Slide 1 of 28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
About This Presentation
A quick overview of several "osbcure" programming languages: Occam, Forth, APL, and Simula.
Size: 6.48 MB
Language: en
Added: Oct 08, 2024
Slides: 28 pages
Slide Content
What You Can Learn from
Obscure Programming Languages
Dmitry Zinoviev
Professor in Computer Science and MSDS Graduate
Program Director
Suffolk University, Boston
7Oct2024 Codebar 4/28
What Are “Obscure” Languages?
●Programming languages that were once promising but did not
deliver because they were:
–too niche (m4, SNOBOL, Postscript, HyperTalk, RPG),
–too hardware-dependent (Occam, Assembly, Bliss),
–practically overcomplicated (Forth, APL, Ada),
–too late to come (Starset, D, Julia, Delphi), or
–technologically premature (Simula/ALGOL 68, Lisp).
7Oct2024 Codebar 5/28
What Are “Obscure” Languages?
●Programming languages that were once promising but did not
deliver because they were:
–too niche (m4, SNOBOL, Postscript, HyperTalk, RPG),
–too hardware-dependent (Occam, Assembly, Bliss),
–practically overcomplicated (Forth, APL, Ada),
–too late to come (Starset, D, Julia, Delphi), or
–technologically premature (Simula/ALGOL 68, Lisp).
7Oct2024 Codebar 6/28
Language Landscape
●First programming languages: Assembly (1949),
Shortcode/Autocode (1949/1952), FORTRAN (1957), ALGOL
(1958), LISP (1958), COBOL (1959).
●“History of Programming Languages” (HOPL) lists 8945 languages.
Most of them are dead or obscure.
●TIOBE tracks 50 most popular programming languages. Only eight
of them have the rating of 2% or more (Python, C++, Java, C,
C#, JavaScript, Visual Basic, Go). The remaining languages are
essentially obscure. (But not dead!)
7Oct2024 Codebar 7/28
From Fortran and Lisp to V and Qore
7Oct2024 Codebar 8/28
No!
●I do not know all of those languages.
●You should not know all of those languages.
●Nobody should know any of those languages.
7Oct2024 Codebar 9/28
Why Care?
●Understanding: Many features of modern programming languages
have roots in obscure languages.
●Rediscovering: These languages pioneered paradigms that are in
use today, like concurrent computing (Occam) and stack-based
programming (Forth). Some paradigms are still to be discovered.
●Problem Solving: These languages may offer unique (“forgotten”)
approaches to common problems that can change the way you
think about code.
7Oct2024 Codebar 10/28
A Programming Language (APL)
●An array-processing language, 1962
●N-dim arrays are the only data type; scalars are zero-dim arrays
–Vectorized operations
–Strong linear algebra support
●Latin characters, punctuation, digits, spaces, and 65 more special
characters, such as , , , , and even (not in Unicode!)
⊖ ⍞ ⌹⍝
–Specialized keyboard and display driver required
7Oct2024 Codebar 11/28
APL Contribution
●NumPy forerunner
●Compact, powerful, mathematical, “read-only” notation
●Example: calculation of e through Taylor series expansion
1 + + / 1 ÷ (! 170)
⍳
●Example: function for login/password validatione≈1+∑
k=0
170
1
k!
7Oct2024 Codebar 14/28
Let the “Forth” Be with You
●Stack-based programming language (1968)
–Reverse Polish Notation (RPN), no operator precedence
–Two stacks: data and control (return)
–Variable permitted but discouraged
●Comments are commands (weird!)
●Very compact and easy-to-implement interpreter/compiler
●Favorite NASA programming language (as of 2003)
7Oct2024 Codebar 15/28
Forth Contribution (1)
●All you need is a deep stack and stack-manipulation words
–“words” is Forthish for “functions”
●Recursion is everything
●Floating-point numbers are for weaklings. Use rationals!
–E.g., calculate circumference from diameter:
10000
↩
ok 1 \ Push the diameter
355 113
↩
ok 3 \ Push the π as a rational number
*/ .
↩
31415 ok
7Oct2024 Codebar 16/28
Forth Contribution (2)
●Self-documenting words:
OVER ( x1 x2 -- x1 x2 x1 ) \ shows the stack state before and after
●Expandable word dictionaries – essentially, libraries
●Elaborated control flow
: SAY ( flag -- ) IF ." Hello" ELSE ." Goodbye" THEN ;
↩
ok
TRUE SAY
↩
Hello ok
FALSE SAY
↩
Goodbye ok
7Oct2024 Codebar 17/28
Factorials
: FACTORIAL ( n -- n ) RECURSIVE
?DUP 0= IF
1 \ 0! = 1; The base case
ELSE
DUP 1- FACTORIAL * \ n! = n*(n-1)!; The recursive case
THEN ;
↩
ok
25 FACTORIAL .
↩
7034535277573963776 ok
7Oct2024 Codebar 18/28
Occam
●The Transputer language from Inmos (1983–84)
●Optimized for concurrency and parallelism
●Communicating sequential processes (CSP):
–Everything is a process
–Processes run concurrently
–Processes communicate
●Plus π-calculus (dynamic connectivity)
7Oct2024 Codebar 19/28
Occam Contribution (1)
●Erlang/Elixir forerunner
●Channels connect processes
–Unidirectional, exclusive (1-to-1), synchronous, semi-structured
–Can be mapped to hardware channels
–Read/wite a byte:
CHAN BYTE in, out:
BYTE item:
SEQ
in ? item -- "What?" Read/receive a byte from channel 'in'
out ! item -- "Bang!" Write/send a byte to channel 'out'
7Oct2024 Codebar 20/28
Occam Contribution (2)
●Process prioritization
●Alternative processes: forerunners of the select() function in C
standard library, take a possible action and ignore the impossible
7Oct2024 Codebar 21/28
Deadlock Detection
PROC deadlock ()
VAL hello IS 'H':
CHAN OF BYTE alice.to.bob, bob.to.alice:
PAR
BYTE text.msg:
SEQ -- Alice: text me, then I text you
bob.to.alice ? text.msg
alice.to.bob ! hello
BYTE text.msg:
SEQ -- Bob: text me, then I text you
alice.to.bob ? text.msg
bob.to.alice ! hello
:
-- KRoC: deadlock: no valid processes found in workspace(s)
-- KRoC: program deadlocked (no processes to run)
7Oct2024 Codebar 22/28
Simula
●First proper object-oriented language (1962–1967)
–Followed by Smalltalk, another “obscure” language
●A proper superset of ALGOL-60 (1958)
●Uses some “illegal” characters ( , ,
≠, ¬=), but can survive with ≤ ≥
ASCII substitutes
●Extended to cover computer simulation
7Oct2024 Codebar 23/28
ALGOL/Simula Contribution
●Dynamic memory allocation and
references (a.k.a. pointers)
–malloc()/free(), new/delete
●Objects as combinations of data and
methods
●Class inheritance, overriding, virtual
methods
●Passing parameters by name
BEGIN
TEXT txt;
txt :- Blanks(64); ! “calloc()” ;
txt := "Hello, "; ! “strcpy()” ;
! Skip over the greeting ;
txt.SetPos(8);
txt.PutChar('D');
txt.PutChar('Z');
! Remove the trailing blanks ;
txt.Strip;
OutText(txt);
OutText("!");
END;
7Oct2024 Codebar 24/28
Simula Contribution
●Are you a “self’y” (Python) or a “this’y” (C++/Java)? Simula “has”
both!
●(Not really.)
CLASS Point2d(x,y); INTEGER x, y;
BEGIN
REF(point2d) self;
self :- THIS Point2d;
self.x := x;
self.y := y;
END Point2d;
7Oct2024 Codebar 25/28
Simula[tion]
●Co-routines with suspension/resumption (yes, back then!)
●Inheritance from class Simulation makes your code a discrete-event
simulator:
–Your system has a set of states and can transit from one state to
another upon arrival of external events (the event loop)
–The events are either prerecorded or generated at random
–Each system component is a Simula process and can be passive,
active, or suspended
7Oct2024 Codebar 26/28
Service
Counter
Customer
Simulation
Process CLASS Customer(Arrival); REAL Arrival;
BEGIN
IF NBusyCounters = NCounters THEN
Wait(Queue); ! Enqueue the customer;
IF NOT Queue.Empty THEN
BEGIN
REF(Customer) Next;
Next :- Queue.First;
Next.Out; ! Dequeue;
REACTIVATE Next AFTER Current;
END;
! Collect statistic ;
CustomersOut := CustomersOut + 1;
TotalTime := TotalTime + (Time - Arrival);
END Customer;
7Oct2024 Codebar 28/28
Any Qs? Want to Do Grad School?
Dmitry Zinoviev [email protected] (school business) [email protected] (books, etc.)
Professor in Computer Science and MSDS
Graduate Program Director
Suffolk University, Boston