Little Languages
Chris Laffra
Chrislaffra.com
laffra@uber.com
Holland USA
Holland
Canada

USA
Holland
Chris Laffra
Part 1 of 2
A dozen or so
influential and historical
Little Languages
Logo Features

abstract
syntax
domain
simple
1967
drawing a square
variables and iteration
sh
sort | uniq | wc
how I started
Features

REPL
plugins
pipes

history
tail `ls | head -1`
last lines of the first file
ls | head -1 | xargs tail
more idiomatic version
vs
cat file1 file1 file2 | sort | uniq -u
all lines in file2, but not in file1
1971
DSL
External Internal
New

Syntax
New

Implementation
Performance Target
Based on a chart by Martin Odersky for DSL Summer School, EPFL 2015
DeepShallow
Embedded
Smalltalk Features

OO

reflection

messages
elegance
1971
I bet that a programming language based on message passing
can be implemented in "a page of code." 

-- Alan Kay
how it all started
Small
Little
Talk
Language
=
=
Smalltalk == Little Language
brevity
Prolog Features

logical
declarative
problem
query
1972
mother_child(carla, bob).



father_child(chris, koen).

father_child(chris, bob).



sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y).



parent_child(X, Y) :- father_child(X, Y).

parent_child(X, Y) :- mother_child(X, Y).
predicates
?- sibling(bob, koen).
query
Yes
result
+
resolution



backtracking
SQL & QBE Features

relational
calculus
declarative
what ¬how
1973
.....Name: Bob

..Address:

.....City:

....State: TX

..Zipcode:
QBE
SELECT * FROM People

WHERE Name='Bob'

AND State='TX'
SQL
Bentley’s Language Design Yardsticks
Generality
Orthogonality
Similarity
Completeness
Parsimony
Extensibility
Openness
Lex & Yacc
Features

If-this-then
patterns
declarative
transform
1975
regex context-free
Lex
Flex
Moo
...
e
=
4
‘ ‘
z
i
s
Yacc
Bison
Nearley
...
size
=
4
AST
Some people, when confronted with a problem, think “I know, I'll use
regular expressions.” Now they have two problems. -- Jamie Zawinski
Make Features

DAG
tabs
build
rules
1975
target: dependencies

actions
Makefile
hello: hello.o

cc -o hello hello.o



hello.o: hello.c hello.h

cc -c hello.c



clean:

rm hello hello.o
Hello World
Dijkstra’s Suggestions
Only Consider
Simple Programs
Reduce the
Solution Space
Prove

Correctness
Use Abstraction

Patterns
Develop Tools
That Matter
Use Hierarchically
Factored Solutions
1972
pic Features

high level
pictures

typesetting
power
pi = 3.14159; n = 10; r = .5

s = 2 * pi / n

for i = 1 to n-1 do {

for j = i+1 to n do {

line from r*cos(s*i), r*sin(s*i)

to r*cos(s*j), r*sin(s*j)

}

}
decagram.pic
pic decagram.pic | troff | grops > decagram.ps
generate a decagram
1982
dot Features

parsimony
right level
similarity
digraph graph_2 {

a -> b -> c;

b -> d;

// -> is arrow

}
ellipsis and arrows
graph graph_1 {

size="1,1";

a [label="Foo"];

b [shape=box];

a -- b -- c [color=blue];

b -- d [style=dotted];

}
boxes and lines
1982
Logo → Scratch
To square

repeat 4 [

forward 100

right 90

]

End
Logo Scratch
1967 2003
2003
Part 2 of 2
Little Languages
I worked on
PROCOL Features

concurrency
messages

protocols
guards
1989
Protocols
Procol
HotWire Features

drawing
AOP
visual

debugging
Smalltalk or C++
visualization script
animation
1994
UIDE/Safari/IMP (Eclipse) Features

IDE
Tooling
abstract
language
language X10 extends Java {
set modifierIcons(Declaration d) = {
d.modifiers().isNullable() => "icons/nullable.gif";
d.modifiers().isValue() => "icons/value.gif";
};
Outline extends Java.Outline {
node async;
}
}
MEL - declaring IDE attributes for a new language
Xtext SpoofaxSee also: and 1998
1.
2.
3.
Paul Graham’s Rules
People
2001
Your Itch
Control
Greatness
Brevity
site org.escript {
feature org.escript {
plugin org.eclipse.escript.sample {
name="eScript Plug-in"
contribution org.eclipse.ui.actionSets {
actionSet {
id="actions", visible=true, label="eScript Sample"
action {
id=MyAction, tooltip="Hi, eScript World",
toolbarPath="eGroup", label="eScript Sample"
}
method run {
MessageDialog.openInformation(new Shell, "Hi", "eScript")
}
}
}
}
}
}
eScript Features

IDE
plugins
infer types
No XML
defining an Eclipse plugin
2004
EGL Features

Business
Modernization
Migration
Mainframe
2005
Quartz in Python Features

DAG
memoization
persistence
time-travel
2010
class C:
@dag
def f1(self, x, y):
return self.f2(x) + y
@dag
def f2(self, x):
return x * x
= + x
y f2
f1
PyAlgoViz Features

introspect
state
animate
for n, value in enumerate(L):
h = value *40 + 1
y = 400 - h
x = 50 + n * 50
rect(x, y, 40, h, "lightyellow")
visualization
def sort(L):

for i in range(len(L) - 1, 0, -1):

for j in range(i):

if L[j] > L[j+1]:

L[j],L[j+1] = L[j+1],L[j]



sort(random.sample(range(10), 10))
algorithm
+
2013
Summary
And
Advise
IDE Support
Designing your own
Little Language?
2018
Parser
AST
Lexer
Type Checker Grammar
AST
Type Checker
IDE Support
Linter
Writing a
hand-written
recursive
descent
parser
Using a
grammar-
based parser
or language
workbench
based on 

TypeScript

or similar
External DSL
Internal DSL
Dijkstra’s “The Humble Programmer”
1972
Programming is tremendously difficult
Be humble, we have small brains
Use modest and elegant languages
The End

Little languages