Thursday, January 19, 2023

Funny programming languages

One of the weirdest and most wonderful things about people is that they can make a joke out of anything. For any human discipline there’s people making jokes about that discipline. In programming, that starts with memes like “how do I exit vim” (as typified in places like r/programmerhumor), or funny examples of awful code (such as from TheDailyWTF).

Those are both highly accessible kinds of jokes. More interesting to me is the humor that heavily rely on experience or background knowledge, where the expectation is that many people won’t have the context that makes it funny. This is comedy that is produced by programmers for programmers. By relying on the shared context of software engineering, the gags aren’t recognizable as mainstream jokes. You could easily explain why this is a joke to a normie, but could you explain Enterprise Fizzbuzz? Aphyr’s Technical Interview series?

(This is something that happens in all fields, not just programming. 441 is a hilarious juggling pattern.)

The most interesting is when the medium of programming is itself used as a comedy substrate. This would be something like vanillaJS. There’s also some cases where the joke is an entire programming language. Not many, since making a PL is hard, but a few!

Funny Syntax

Things like ArnoldC and COW, where the language is a joke syntactic skin over another language.

IT'S SHOWTIME
TALK TO THE HAND "hello world"
YOU HAVE BEEN TERMINATED

These can be funny but they’re not very interesting.

Multicoded Languages

PLs designed to look like something else. Famous examples include Shakespeare, where programs look like plays, and Chef, where programs look like recipes. From baking a hello world cake:

Ingredients.
33 g chocolate chips
100 g butter
54 ml double cream
2 pinches baking powder
114 g sugar
111 ml beaten eggs
119 g flour
32 g cocoa powder
0 g cake mixture

[rest of code at link]

I devoted a lot of time to multicoded languages in my video on esolangs (talk page). Multicoded languages work on a couple of levels. First, it just looks funny, that a play/recipe/picture is actually a valid program. What makes them especially interesting, though, is that the programs can also serve as a valid play/recipe/picture. There’s the intellectual challenge of trying to find something that fits both purpose, and I find the successes really delightful. Someone successfully baked the hello world cake!

Funny Semantics

Languages where the language does funny things as part of execution. These tend to be the rarest kinds of joke languages, because relatively few people can actually make them. But they’re also the most interesting.

The most famous example in this category is INTERCAL, which is also the first “joke” language in history. Some of the more interesting semantics include:

  • A COME FROM statement. COME FROM 10 will cause execution to jump to the COME FROM after it runs line 10, regardless of where the COME FROM is in the program.
  • If fewer than 1/5 or more than 1/3 of statements are prefixed with PLEASE, then compilation raises an impolite/too polite error.
  • The MAYBE statement causes execution to fork, creating one thread where statement is executed and one where it isn’t.

INTERCAL is a collection of different jokes. Vigil, by contrast, is focused on a single joke. It’s like Python with a contract syntax for pre/post conditions:

def withdraw(acct, amount):
  implore amount >= 0
  implore amount <= acct.balance
  acct.balance -= amount
  swear acct.balance >= 0

If a swear ever fails, the function is deleted from the source code. This guarantees that only functionally correct remains in the codebase.

But isn’t a language that deletes code crazy?

No, wanting to keep code that demonstrably has bugs according to its own specifications is crazy. What good could it possibly serve? It is corrupted and must be cleansed from your codebase.

Finally there’s Malbolge, which is a language designed to be as hard to program in as possible. Among other things, it used the same memory space for data and source code, so data could be executed as code and vice-versa. It took two years from someone to write hello world.

Satirical Languages

A subset of funny semantics, usually, but these languages are also reactions to specific trends or discourse. Outside of that discourse, they just seem like ultra-weird languages instead of protests given form.

I only know of two examples. The first is HQ9+. At the time, there were three common tests of programming language fluency:

  • “Hello, world!”
  • Printing the lyrics to 99 Bottles of Beer. The 99 bottles website collected these programs, being a strong contender for the first Rosetta Code.
  • A quine, or program which prints its own source code.

HQ9+ was a programming language with only four commands:

  • H prints “hello, world”
  • Q prints the source code
  • 9 prints all the 99 Bottles lyrics
  • + “increments the accumulator.”

Obviously, being able to solve every fluency challenge in a single character, HQ9+ is the perfect programming language.

The other satire I know of is MetaGolfScript. “Code Golfing” is the sport of writing programs with as few characters as possible. The bulk of the community is on the Code Golf & Coding Challenges SE board, where the upvote system effectively pits languages against each other. This means that languages like Perl and APL have huge advantages over ones like Java and C.

Eventually people made dedicated golfing languages, which sparked an arms race of increasingly-compact golfing languages. MetaGolfScript is the “no you times infinity” of golfing languages, an entire family where any problem can be solved in zero characters. For example, MGS-4342596 prints “ABC”, while MGS-2579603820238107378666987055701286 tests if the input is a prime number. A terrible language, but a great statement on arms races and the futility of war.

There are probably other satirical languages, these are just the two I know about. There are a lot more satirical libraries than languages, like the aforementioned vanillaJS.



from Hacker News https://ift.tt/Qxur8ch

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.