As a software engineer, you likely pride yourself on writing clean, efficient, maintainable code. But have you ever felt the allure of the obscure, the cryptic, the downright bizarre? Welcome to the world of esoteric programming languages, or esolangs. These are not the tools you'll use to ship your next product, but they are a fascinating playground that challenges your understanding of what code is and what it can be.
My recent deep dive into this topic on my blog in Russian explores exactly this intersection of computer science and conceptual art.
The Humanities in Code
If we consider linguistics a humanities discipline (though it's arguably closer to natural sciences like biology), we can reflect on the inner workings of programming languages. In C++, Perl, and Python, we find words, syntax, and expressive techniques. Expressiveness is a humanities category. Just as any idea can be expressed in any natural language, any action can be described in any programming language. The difference lies only in the number of words required and the additional meanings this expression carries.
When we focus on natural languages, the difference between programming languages is how much code you need to write and what redundant actions the machine must perform. The more concise and free of extraneous elements the expression, the more beautiful and expressive it is.
Poetic Nuances
The philologist M. L. Gasparov noted that in Latin you can elegantly say "children who are worse than their fathers" in a way that is cumbersome in Russian. This flexibility is akin to the quirks of programming languages. For instance, assignment operations typically read right-to-left: in Python, x = 5 assigns the value to the variable. However, the R language flips this with 5 -> x. It's a subtle shift in perspective.
Interestingly, "concise" in programming doesn't always mean "free of extraneous elements." Assembler requires you to specify every minute action, making the program lengthy but fast because it does nothing extra. Meanwhile, Python or PHP might execute many background processes for a simple task, so concise code can hide significant extra activity.
Poetry and Programming
The domain where expressiveness is traditionally tested is poetry. And yes, people write poetry in programming languages. I've written about this before. Even Victor Pelevin, in an old interview, admitted to experimenting with poetic creativity using Assembler. His witty remark about preferring binary code to avoid rhyming problems highlights how the limited characters (0 and 1) make rhyming trivial, though it also perpetuates the stereotype that rhyme is essential for poetry.
Esolangs: The True Humanities Niche
The real humanities spirit in programming—knowledge for its own sake, devoid of practical purpose—finds its niche in esoteric languages. These languages aren't designed for writing useful programs but for entertainment and professional mischief. There's even an encyclopedia cataloging them.
Brainfuck is undeservedly popular for its extreme difficulty in reading, but more captivating examples exist.
1. Perligata: The Latin of Code
Perligata allows you to write code in Latin. All names and functions are based on Latin, not English. The inspiration came from the rigid syntax of traditional languages: first variable, then operator, then value—much like English. Latin, however, uses declensions. In Latin, Puer cani escam dedit and Escam dedit puer cani mean the same thing, "The boy gives the dog food," with only stylistic differences.
Damian Conway created Perligata based on this idea. Variable and value are determined not by word order but by Latin case endings. A noun in the dative case is the variable receiving the value; in the accusative, it's the variable whose value is used. They can be in any order. Here's an example:
nexto stringum reperimentum da. # $next = pos $string;
nextum stringo reperimento da. # pos $string = $next;
When asked why, Conway replied: "If you have to ask 'Why?', then the answer probably won't make any sense to you either." That's the hallmark of a truly humanities-driven project.
2. Shakespeare: A Theatrical Language
The Shakespeare Programming Language makes programs resemble Elizabethan plays. It's not very expressive—it can only add, subtract, and output results—but it does so through code that mimics play text. Variables are Shakespearean characters, functions are stage actions, and operators are character traits. Here's a snippet that computes prime numbers:
Primes
(This is the contents of the file primes.spl.)
Prime Number Computation in Copenhagen.
Romeo, a young man of Verona.
Juliet, a young woman.
Hamlet, a temporary variable from Denmark.
The Ghost, a limiting factor (and by a remarkable coincidence also
Hamlet's father).
Act I: Interview with the other side.
Scene I: At the last hour before dawn.
[Enter the Ghost and Juliet]
The Ghost:
You pretty little warm thing! Thou art as prompt as the difference
between the square of thyself and your golden hair. Speak your mind.
Juliet:
Listen to your heart!
[Exit the Ghost]
[Enter Romeo]
Juliet:
Thou art as sweet as a sunny summer's day!
Act II: Determining divisibility.
Scene I: A private conversation.
Juliet:
Art thou more cunning than the Ghost?
Romeo:
If so, let us proceed to scene V.
[Exit Romeo]
[Enter Hamlet]
Juliet:
You are as villainous as the square root of Romeo!
Hamlet:
You are as lovely as a red rose.
It's pure postmodern joy, and you could even stage these programs.
Why Bother?
Both Perligata and Shakespeare are implemented as extensions to Perl, so you can easily run them on your computer. Why do this? To borrow Conway's phrase again: "If you have to ask 'Why?', then the answer probably won't make any sense to you either." And that's what makes it so wonderfully human.