⬆️ ⬇️

5-minute guide to esoteric programming languages: try to classify them

Esoteric programming languages ​​(or esolang - short for esoteric language) are languages ​​created not only to write code. In one of our materials, we casually raised this topic - there was described the language BANCStar (strictly speaking, it is impossible to call it 100% "esoteric", although it would be desirable).



In this material we will dwell on how one can classify esoteric PLs: what distinguishes “comic” esoteric languages ​​from “serious”, what goals their creators can pursue and what inspires the latter.



Photo by Markus Spiske PD

')

A couple of words about esoteric PL



A piece of art or a joke, a puzzle or a secret cipher — all of these definitions refer to esoteric programming languages. Such languages ​​are created for different purposes, however, “the development of a convenient tool for solving work programmer problems” is usually not included in their list.



According to software architect Federico Tomassetti (Federico Tomassetti), an esoteric programming language is being developed to challenge the “standards” of the design of the PL. This challenge can be expressed in different ways: from a simple desire for something unusual to the creation of a full-fledged "artistic work." Let us try to figure out what these challenges may be and how, in this connection, the whole variety of esoteric languages ​​can be divided into groups.



An important point: the authors of many esoteric languages ​​tend to lay as many differences as possible into their syntax and structure (from everything that was created in this sphere earlier). Therefore, any classification of esoteric PL is rather an opportunity to understand how, why and with what purposes languages ​​were created, rather than an attempt to create a strict and orderly system.



What are the classification options



Turing fullness



The most obvious approach to the division of esoteric languages ​​into groups is according to whether they are turing-complete : is it possible (at least in theory) using a language to implement any computable function or not. One of the Turing-full languages ​​is, for example INTERCAL . On the website of the American programmer, hacker and co-founder of the Open Source Initiative Eric Raymond (Eric S. Raymond, ESR), INTERCAL is described as "designed to achieve Turing completeness and maximum dissimilarity to existing programming languages."



Thanks to these features, INTERCAL, according to the ESR, is capable of "causing tears (laughter) from strong men" and is "the center of the international community of techno-masochists."



Despite its comic character, INTERCAL was not only “viable” (if this concept is applicable to esoteric languages), but also became the basis for creating many other esoteric PLs.



On the other hand, among esoteric languages ​​(due to their peculiarities) there are Turing incomplete languages . Such, for example, as HQ9 +, having only 4 commands (from them just the name of language is also made). This comic language allows you to easily solve all the “standard” tasks of a novice programmer: from “Hello, world!” (Command H) to output a quine (command Q).



However, even Turing completeness does not mean that esoteric language can be easily used in work. Among the esoteric languages, “ Turing quagmires ” are quite common - languages ​​that have Turing completeness, but have limited (and even poor) syntax and semantics.



In theory, they have the same capabilities as any turing-complete languages ​​(both esoteric and working), however, due to restrictions, it is extremely difficult to implement some types of programs with their help. INTERCAL, by the way, is often referred to as “quagmire”. Another example is another equally popular esoteric PL Brainfuck. To imagine how complex simple operations using such languages ​​can be, here is an example of the classic “Hello, world!” On Brainfuck (there are other options for implementation, including shorter ones):



+++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++.+++++++++++++++++ ++++++++++++.+++++++..+++.------------------- --------------------------------------------- ---------------.+++++++++++++++++++++++++++++ ++++++++++++++++++++++++++.++++++++++++++++++ ++++++.+++.------.--------.------------------ --------------------------------------------- ----.-----------------------. 


Goals for creating a language



Federico Tomassetti identifies several “target groups” of esoteric languages. Among them, for example:



1. Languages ​​designed to solve a specific problem.



This task is not always universally recognized, but for the creator of the language and the community of like-minded people, it has value — which means that the language that helps to solve it is valuable. These include Thue (named after the Norwegian mathematician Axel Thue ) - a language created as a demonstration of the zero type in the Chomsky hierarchy (by the way, it also refers to the "Turing bogs").



2. “Confusing Languages” or Black Boxes



They are designed to make the code as unreadable as possible for the uninitiated and make it difficult to write code. The most striking feature of the “black boxes” is obfuscation, that is, the intentional concealment of the true value of a particular section of code. These include, for example, Malbolge (named after Dante for the eighth circle of hell, which includes various kinds of cheaters). Evidence of its complexity can be at least the fact that the working quine on Malbolge was written 14 years after the creation of the language, the second version - after 3 years.



On the other hand, there are more "humane" examples of such languages. In particular, the same BANCStar , which can be attributed to the working programming languages ​​with a big stretch. According to developer Joe Logri (Joe Loughry), by 1997, no more than a dozen people wrote programs in this language around the world, and a total of about 1,350 programs were written in BANCStar — a practically esoteric language that, however, was developed in commercial purposes. One of these goals was to ensure that sensitive banking information was well protected (it was strictly forbidden for developers to comment on the code).



3. Languages ​​created to confirm the viability of a particular concept.



By themselves, these languages ​​can be inconvenient and non-functional, but nevertheless, they are irrefutable evidence that the concept has a right to exist. These languages ​​include, for example, the family of languages Funges , which uses multidimensional representations of programs.



sources of inspiration



Esoteric programming languages ​​can be classified including “by the interests of their authors”: many of these interests and hobbies are reflected in the syntax and features of languages.



1. Cinema



One of the most popular examples of esoteric languages, inspired by the cinema in general (and science fiction in particular) is the var'aq language. It was created by Brian Connors, an admirer of the Star Trek universe, and is "a language based on the hacking culture of the Klingon race."



According to the author , the very name var'aq in Klingon does not mean anything, but the language could be named after some popular Klingon mathematician (something like Pascal). The syntax and features of the language, according to the author, reflect the specific type of thinking and the mentality of the Klingons.



Among the esoteric programming languages, other cinema examples are popular. In particular, a language that uses as a syntax the phrases of Arnold Schwarzenegger, or Groot , named after the character “Guardians of the Galaxy” (the syntax of this language is quite predictable).



2. Literature



Another source of inspiration for the creators of esoteric programming languages ​​is books. Probably one of the most illustrative examples of “literary” syntax in programming is the Shakespeare language. The authors of the language, Karl Hasselstrom (Karl Hasselström) and John Aslund (Jon Åslund), write that they decided to create it as part of the course of the syntax analysis. A few weeks before, they had become acquainted with other esoteric programming languages ​​and had come up with the task of combining the course, knowledge of esoteric languages, and a peculiar Shakespeare style.



As a result, there was a language that allows turning any program into a dramatic work, the characters of which step onto the stage and (mostly) inflict on each other all kinds of insults. Each program contains the title and acts, which, in turn, are divided into scenes (all as in the present play). Here, for example, an excerpt from the drama “Hello World”, act one, scene one (altogether there are 2 acts in Hello World, the first consists of two, the second consists of three scenes):



The Infamous Hello World Program.



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!



You are as brave as the sum of your fat little stuffed misused dusty

old rotten codpiece and a beautiful fair warm peaceful sunny summer's

day. You are as healthy as the difference between the sum of the

sweetest reddest rose and my father and yourself! Speak your mind!



You are as cowardly as the sum of yourself and the difference

between a big mighty proud kingdom and a horse. Speak your mind.



Speak your mind!



[Exit Romeo]




3. Fine art



Perhaps the most famous example of an esoteric language inspired by painting is Piet , named after Pete Mondrian, one of the pioneers of abstract painting. The program code in Piet looks like an abstract image made up of 20 different colors - examples of the work of programmers on Piet can be found here .



By the way, some of the developers are so inspired by their creations that they decide to perpetuate them on canvas - this is how, for example, Jack Andersen made his program in the process of work. Read more about Piet in this article on Habré.



Another language using colors and named after the artist is Matisse (a modification of Brainfuck). Another “extremely esoteric” art-related programming language is Magritte. Only one program is written on it - in the style of surrealism by Rene Magritte - because of what the language is referred to as non-functional and comic (about this category just below).



Comic languages



Sometimes "joke tongues" are divided into a separate group. The esolang wiki portal dedicated to esoteric languages describes comic languages ​​as “not of interest - with the exception of their humorous component”, as well as “totally inappropriate for programming even in theory, banal and less interesting versions of existing esoteric languages”. However, the esolang comic language list alone contains more than 130 items.



On the other hand, sometimes even more complex, recognized esoteric PL are sometimes referred to as comic languages. For example, INTERCAL, the whole manual on which represents a joke: in the introduction, in particular, it is emphasized that "all the coincidences of the programming languages ​​described here with other programming languages, living or dead, are random."



As a rule, each esoteric language can be classified at once in several ways - by turing completeness, goals and objectives (if they are clearly marked), by reference to works of art and even by the sense of humor of the creators of the language. In the end, esoteric languages ​​are created in order to break all the rules - including the rules of classification.



In the second part of our five-minute guide, we will try to figure out which esoteric languages ​​have the most admirers among developers, and why are they being developed at all?

Source: https://habr.com/ru/post/344680/



All Articles