What You Can Learn from Obscure Programming Languages

DmitryZinoviev 137 views 28 slides Oct 08, 2024
Slide 1
Slide 1 of 28
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28

About This Presentation

A quick overview of several "osbcure" programming languages: Occam, Forth, APL, and Simula.


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 2/28
Meet my Pragmatic books
2016 2018 2021 2021

7Oct2024 Codebar 3/28
2016 2018 2021 2021
Meet my Pragmatic books
2024

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 12/28
Credentials Validation


CHECK_LOGIN
[1] LOGIN_OK ← (LOGIN 'admin') PASSWORD 'foobar'
≡ ∧ ≡
[2]

LOGIN ← 'admin'
PASSWORD ← 'password' Oh, no!

CHECK_LOGIN
LOGIN_OK
0
PASSWORD ← 'foobar'
CHECK_LOGIN
LOGIN_OK
1

7Oct2024 Codebar 13/28
Checkerboard, Remainders...
LINEAR ← 64

COLUMNS ← 2 | LINEAR
ROWS ← 2 | LINEAR ÷ 8

CHECKERED ← (ROWS ~COLUMNS) (COLUMNS ~ROWS)
∧ ∨ ∧
BOARD ← 8 8 CHECKERED

0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
BOARD[1; 2] 2D index

1
∇RESULT ← V DIVISIBLE_BY N
[1] REMAINDERS ← N | V
[2] ZEROREMS ← 0 = REMAINDERS
[3] RESULT ← ZEROREMS / V Compression!

[4]

STEP_17 ← ( 100) DIVISIBLE_BY 17

STEP_17
17 34 51 68 85

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;

NBusyCounters := NBusyCounters + 1; ! Seize a counter;
Hold(NegExp(1 / SMean, seed)); ! Service;
NBusyCounters := NBusyCounters - 1; ! Release the counter;

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 27/28
2016 2018 2021 2021 2018 2021 2021
Thank you!
2024

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