Esolangs!
No Newsletter next week
I have some real life stuff going on and also a secret project deadline. I'd still like to make time for the newsletter, but it's easier to just say it probably won't happen. Sorry.
Esolangs!
That secret project is a talk on esolangs! A friend asked if I wanted to do a short lecture on esolangs for her class and I jumped at the chance. It's been a lot of work, mostly because I'm also using this as an opportunity to learn basic video editing, which will be useful to making more FM teaching materials in the future. Also, I had to learn enough of a bunch of different esolangs to make a coherent presentation. I'll have something ready by the end of next week, along with supplementary materials for people who are interested.
So what is an esolang? The term stands for "esoteric languages", but it means something more than "languages that are uncommon or exotic". Software is big, and "uncommon/exotic" depends on who you ask. Esolangs are more defined by family resemblances, with some general (but not universal) properties: I'd say the most common definer of an "esolang" is that it's not designed for practical use. Esolangs are designed to be admired as languages, or in specific programs, but there's no expectation that people "should" use them for actual tasks.
Under this definition, something like Inform7 is not an esolang (ref):
A room has a number called rval. The rval of a room is usually 0.
When play begins, seed the random-number generator with 1234.
The story genre is "Fantasy".
The story headline is "A Computerized Fantasy Simulation Game".
The release number is 3.
The story creation year is 1979.
Use the serial comma.
A thing can be non-flaming or flaming. A thing is usually non-flaming.
While it's an exotic language, and certainly that's an unusual syntax, it does have a concrete use: making interactive fiction games.1 The most famous esolang, brainfuck, was designed purely to have the smallest compiler possible, not to actually be useful to anybody. Here's how to do 2*3
in brainfuck:
+++>++<
[->[->+>+<<]>[-<+>]<<]
You can play around with the script here. Brainfuck was my first esolang, and as a dumb high schooler I was proud of my Mad Brainfuck Skillz. Except that I was still a sheltered Orthodox kid and couldn't swear, so I said BF instead of brainfuck. Also, I couldn't program actual languages, so my Mad Brainfuck Skills were a complete waste of time.
Esolangs are interesting for a lot of reasons. Many of them explore a specific idea. Befunge, which came out the same year as brainfuck, was designed to be easy to interpret but impossible to compile. It did this by having a 2D control flow. Normally the instruction counter moved left-to-right, but some commands could make it go right-to-left or even vertically. Interestingly enough, this "worked" because Befunge is a stack-based language like Forth. Stack languages seem to generally have a lot more control flexibility than register-based languages, possibly because there's very few syntactic restrictions. Just idle speculation here.
Esolangs can also explore other models of computation. One language I probably won't get a chance to talk about, due to space constraints, is Shakespeare. Shakespeare is designed to look like a play. Here's the first 11 lines of "Hello World" (ref):
Romeo, a young man with a remarkable patience.
Juliet, a likewise young woman of remarkable grace.
Ophelia, a remarkable woman much in dispute with Hamlet.
Hamlet, the flatterer of Andersen Insulting A/S.
Act I: Hamlet's insults and flattery.
Scene I: The insulting of Romeo.
[Enter Hamlet and Romeo]
Hamlet:
You lying stupid fatherless big smelly half-witted coward!
You are as stupid as the difference between a handsome rich brave
hero and thyself! Speak your mind!
{75 lines cut}
Shakespeare has a really cool computational connection. Every Shakespeare variable must be named after a character in one of Shakespeare's plays, so there's only a finite number of variables. To add more, each character can "remember" or "recall" values, turning them into LIFO data stacks. This means Shakespeare most closely maps to an n-stack pushdown automata, and we know 2-stack PDAs are Turing-complete, so Shakespeare is, too. I find that really neat!
Shakespeare is also an example of a multicoded esolang: a language that's designed to look like both a programming language and "something else". In Shakespeare's case, a play. The most famous multicoded language is Piet, by David Morgan-Mar, which is designed to look like a picture. Here's a Piet picture that calculates Pi:
The red part of the program is both code and also data. The bigger you make the picture, the more accurately it calculates pi. Also by David-Morgan Mar is Chef, where programs look like recipes. Most of the recipes are nonsensical, but if you know exactly what you're doing, you can make a "Hello World" program that looks like a cake recipe. And then bake the cake. And then eat the cake.
What I'm most excited to talk about, though, is a context where esolangs are widely used, so much so that it's affected the community around it: code golf. Code golfing is a recreational activity where you try to write a program in the fewest number of characters possible. These days most of this happens in the Code Golf Stack Exchange. If you go there, you'll sometimes run into an answer where a person presents a program and also a proof that it will eventually provide the correct answer, though it will take longer than the lifetime of the universe to do it. But it's two bytes shorter than the next-best program, so it's objectively superior!
It used to be that languages like Perl and APLs were the best choices for golfing, because they're already pretty terse, but they're still imperfect. They're all designed to do things besides golf, like actual programs. What if we made a language designed for golfing and nothing else?
You get GolfScript. Here's "is this number a prime" in GolfScript (ref):
~.,{*.!+}*.*\%
This inspired even Golfier languages, like Pyth, where the same problem is just }QPQ
, or Jelly, where the problem is ÆP
. My absolute favorite, though, is MetaGolfScript. Here's "is this number a prime" in a MetaGolfScript:
Zero bytes! Or at least, zero bytes in MetaGolfScript-2579603820238107378666987055701286. MGS is actually a family of languages, each identical to GolfScript except in how it handles an empty program. IIRC MGS was the only language banned outright from CGSE, at least for a while.2 But the point wasn't to MGS compete, the point of MGS was to be appreciated. A quintessential esolang, a piece of art that only makes sense for a niche community of people. I find that lovely.
Anyway, I'm turning all of this into a lecture. Spending this week finishing the material and doing recordings, next week stitching it all together, and it'll be ready for my friend's class the week after that. Should've made some sort of donation incentive to demonstrate Bodyfuck to the class, but ah well, it's a bit late for that.
If you're interested in learning more about esolangs, three resources:
- The Esolang Wiki: Lots of individual esolang creators put their works on here. Tends to bias a bit more to joke languages and brainfuck-equivalents, because those are the easiest things for beginner esolangers to create. Also a lot of stuff that's made purely for the joy of making a programming language, as opposed to exploring and specific idea. So huge amount of quantity, no curation.
- Esoteric Codes: And here's the curation. Interviews with specific creators, deep dives into complex esolangs, and esolangs as art. The creator, Daniel Tempkin, is also an avid esolanger himself, creating things like Folders and Light Pattern.
- Try It Online!: The codegolf-esolang cultural trade goes both ways! Run by a famous code golfer (so famous he has an OEIS sequence named after him), it fixes one of the major issues in esolangs, which is getting them running on your computer. You can now try 400+ esolangs online.
-
On the other hand, I'm going to use Orca as an example of an esolang, which also has a concrete use: livecoding MIDI instruments. I don't have a clear explanation for why I think of Orca as an esolang but not Inform7, besides for "feel": there's an element of counterculture in Orca that's not in Inform7. Orca was invented by two artists who live on a boat, and I mean that in the best way possible. ↩
-
Now it's okay again, but the culture of the site has shifted so that you're only competing with programs in the same language, and using MGS is like eating all the chess pieces and saying it's your birthday so you win. Unsurprisingly, nobody uses MGS. ↩
If you're reading this on the web, you can subscribe here. Updates are once a week. My main website is here.
My new book, Logic for Programmers, is now in early access! Get it here.