
Little Languages - maxhallinan
https://www.maxhallinan.com/posts/2018/12/07/little-languages/
======
panic
Andrej Bauer maintains a “programming languages zoo” of languages like this:
[http://plzoo.andrej.com](http://plzoo.andrej.com)

 _> The Programming Languages Zoo is a collection of miniature programming
languages which demonstrates various concepts and techniques used in
programming language design and implementation. It is a good starting point
for those who would like to implement their own programming language, or just
learn how it is done._

~~~
jnbiche
The PL Zoo is a great resource, but that's not exactly what the blog post is
advocating for. PL Zoo is meant for students studying the _implementation and
design_ of programming languages.

What the blog author is describing, on the other hand, is a small language for
teaching the _use_ and _application_ of certain programming techniques.

It's a very promising idea, one that I may try to bring to life for something
tricky, like monads or maybe Rust's ownership system.

~~~
chongli
_What the blog author is describing, on the other hand, is a small language
for teaching the use and application of certain programming techniques._

They already exist: the Racket student languages. My first year CS course was
built on them [1]. Really well-made and -run course.

[1]
[https://www.student.cs.uwaterloo.ca/~cs135/](https://www.student.cs.uwaterloo.ca/~cs135/)

~~~
maxhallinan
Thanks for mentioning Racket. I'm aware of the language but didn't know it
know it was designed specifically for "language-oriented programming".

------
sharpercoder
I'm very fond of small, specific and simple languages without sacrificing
inherent complexity. For me, that includes IP adresses, UUIDs, timestamps,
URIs, println formatting, et cetera.

It's a shame though that we don't represent them as such in the current state
of affairs but choose to implement them separately in every language. Can we
have a fast, universal, feature complete parser generator that is natively
supported in our mainstream languages?

For instance, think adding an ANTLR grammar into a .NET project and then be
able to just do `var ipAddress = ip"127.0.0.1";` and get full editor support
with that.

~~~
nathell
Clojure (and EDN) has it in the form of tagged literals.

[https://clojure.org/reference/reader#tagged_literals](https://clojure.org/reference/reader#tagged_literals)

------
yogthos
Scheme sounds like it's pretty close to what the author is describing. It's a
very small and simple core that you can build on, and even create mini
languages on top of. The macro system allows you to pretty much express any
idea without having to change the core language. As a bonus the runtime is
interactive allowing you to explore ideas and see the results immediately.

~~~
herrosheep
Forth is also quite amazing. I really enjoy both.

~~~
blattimwind
Lua always seemed somehow "right" to me (despite its numerous flaws, including
one-based indexing), just like s-expressions somehow are just the right format
for many kinds of data. You look at it and "just know". You understand it, the
computer understands it effortlessly, and if you remove any element it stops
making sense.

One thing both of these have in common is that they are slightly different
from mainstream ideas (e.g. C, Python, JSON, XML). Not so different it becomes
alien, but different enough to make you approach it with a different state of
mind.

~~~
airstrike
I'm not a Lua user, so I thought I'd ask why one-based indexing is a flaw. As
long as it's consistent, does it really matter?

As someone who is forced to use VBA, it sounds like Lua could be worse

~~~
jonsen
“Why numbering should start at zero”:

[http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EW...](http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html)

------
a-saleh
In my mind, there are three really great little languages:

* datafun - attempt to extend datalog to more generic computation. [http://www.rntz.net/datafun/](http://www.rntz.net/datafun/) I liked simillar exploration of computing with latices with the concept of propagators: [http://web.mit.edu/~axch/www/art.pdf](http://web.mit.edu/~axch/www/art.pdf)

* dhall - configuration language that has user defined functions, but is total :) [https://github.com/dhall-lang/dhall-lang](https://github.com/dhall-lang/dhall-lang)

* the gamma - a visualization/data query language : [http://tomasp.net/blog/2017/thegamma-getting-started/](http://tomasp.net/blog/2017/thegamma-getting-started/)

~~~
GordonS
Wow, The Gamma looks great! Any idea if it can generate zoomable time series
charts?

~~~
a-saleh
T.b.h. I am not sure, been a long time since I played with it. I think so?

------
greenyouse
I worked through the CTM book[0] a while ago and I think this was the general
approach taken using the Oz programming language. Each programming paradigm
was split into a kernel language that would demonstrate specific programming
features. I'd highly recommend trying it out.

I really like the diagram they use to split up the languages + paradigms[1]

[0][https://en.wikipedia.org/wiki/Concepts,_Techniques,_and_Mode...](https://en.wikipedia.org/wiki/Concepts,_Techniques,_and_Models_of_Computer_Programming)

[1][https://www.info.ucl.ac.be/~pvr/paradigmsDIAGRAMeng108.jpg](https://www.info.ucl.ac.be/~pvr/paradigmsDIAGRAMeng108.jpg)

------
jsnell
I was expecting this to be about
[http://wiki.c2.com/?LittleLanguage](http://wiki.c2.com/?LittleLanguage)

But instead it's almost the opposite. Bentley's original use of the little
language term was about optimizing the languages for specific tasks. Not about
building them around explaining a single concept

~~~
mmphosis
Here's another one: [http://www.erasmatazz.com/library/the-journal-of-
computer/jc...](http://www.erasmatazz.com/library/the-journal-of-
computer/jcgd-volume-9/little-languages.html)

------
aasasd
Wikipedia knows of this thing called XL, or ‘Extensible Language,’ though I
haven't seen it anywhere else:
[https://en.wikipedia.org/wiki/XL_(programming_language)](https://en.wikipedia.org/wiki/XL_\(programming_language\))

> XL features programmer-reconfigurable syntax and semantics. Compiler plug-
> ins can be used to add new features to the language. A base set of plug-ins
> implements a relatively standard imperative language. Programmers can write
> their own plug-ins to implement application-specific notations, which can
> then be used as readily as built-in language features.

> XL is defined at four different levels: XL0 defines how an input text is
> transformed into a parse tree. XL1 defines a base language with features
> comparable to C++. XL2 defines the standard library, which includes common
> data types and operators. XLR defines a dynamic runtime for XL based on XL0.

> XL has no primitive types nor keywords. All useful operators and data types,
> like integers or addition, are defined in the standard library (XL2). XL1 is
> portable between different execution environments. There is no such
> guarantee for XL2: if a particular CPU does not implement floating-point
> multiplication, the corresponding operator definition may be missing from
> the standard library, and using a floating-point multiply may result in a
> compile-time error.

Frankly, I'm not sure if this is much different from implementing a language
with a parser generator, but apparently the ‘semantics plugins’ are written in
a version of the language itself, instead of something like the eternal C[++].

------
sn41
Hmm. I wanted to offer a course based on Idris this time around, and found
that I would have to cover a lot of Haskell to get to the main parts of Idris.
As I was about to teach this semester, somebody pointed out the new book "The
Little Typer", along the lines of "The Little Lisper" and "The Little
Schemer". Looks like Pie is a toy language in "The Little Typer". Pie looks
promising - I'll dig in and spend a weekend on it :)

------
alew1
As I was reading, I kept thinking, he should really look at The Little Typer
and Pie. Then that was Section V!

(Really, many of the books in that series do this. The Reasoned Schemer for
logic programming, The Little Prover for ACL2-style first-order logic.)

------
bcherny
What an interesting idea. Sort of, isolate out a graph of concepts from a
language, and pull it out into its own language.

I do wonder why the author believes you need a separate language for this. Why
not a DSL, or even a regular library in your popular language of choice
(Scala, Haskell, JS, etc.).

Is that a reasonable approach too? Or is some part of the toy language
approach lost without perfect domain-specific syntax, or because of parts of
your host language leaking in?

~~~
johncalvinyoung
As a developer who loves Ruby, the article (or possibly someone's comment
above about making a mini-language around monads) reminded me of an excellent
talk I heard lately that implemented a DSL/object model for monads in Ruby,
and refactored some moderately sticky problems to use them. Still didn't
convince me that they were the One Holy Way to do my next project, but got it
a whole lot closer to a tool in my toolbox.

I think the reasoning behind implementing these small languages on their own
would be twofold: one, unless you're very careful, you end up with lots of
context and approach and style inherited from your host language. You can
write non-rubyish Ruby, but only to a degree...and anyone using it who's
moderately familiar with the language is likely to break your artificial
constraints. And for many of the programming concepts perhaps best
demonstrated in isolation, they're divergent enough to be hard to implement
well in a 'traditional' host language.

------
pgtan
Wonder, how everyone forget BibTeX, the (stack based) language for formating
bibligraphy databases:

[http://vesta.informatik.rwth-
aachen.de/ftp/pub/mirror/ctan/b...](http://vesta.informatik.rwth-
aachen.de/ftp/pub/mirror/ctan/biblio/bibtex/base/btxhak.pdf)

------
xellisx
Does brainfuck count as a small language?

~~~
maxhallinan
Brainfuck certainly is small. I think it might also be an example of what I
had in mind. Brainfuck could be a little language for the idea of a Turing
machine. Perhaps by writing Brainfuck programs, one better understands the
mechanics of the Turing machine.

------
kccqzy
When I first read the title, I thought the article was about awk. After all
the definitive book about awk has a whole chapter on little languages. In that
context, little languages means languages with specialized applications, and
not general-purpose.

