The Complete Magazine on Open Source

Exercise Your Mind with Exotic Programming Languages

4.05K 0

man thought exotic programming in his mind
Have you ever encountered Ook! or ‘Brainfuck’? No, we are not trying to shock you, but these are actually the names of the exotic programming languages discussed in this article. Learn more about the origin, nature, eccentricities and uses of these languages with a few examples and try-outs.

The word ‘exotic’ is defined by the Oxford dictionary as “…of a kind not ordinarily encountered.” If that is so, what is meant by exotic programming languages? These are languages that are not used for commercial purposes or even for anything ‘useful’. This definition can be applied a little loosely and, hence, many different types of programming languages can be classified as ‘exotic’. So, after some consideration, I have included three types of languages as belonging to this category. Exotic programming languages include languages that are intentionally designed to be difficult to learn and program with. Such languages are often used to analyse the power of programming languages. They are known as esoteric programming languages. Some exotic languages, known as joke languages, are created for the sake of fun. And the third type includes non-English-based programming languages. The definition clearly mentions that these languages do not serve any practical purpose. Then what’s all the fuss about exotic programming languages? To understand their importance, we need to first understand what makes a programming language a programming language.

The ‘Turing completeness’ of programming languages

A language qualifies as a programming language in the true sense only if it is ‘Turing complete’. A language that is Turing complete can be used to represent any computable algorithm. Many of the so called languages are, in fact, not languages, in the true sense. Examples of tools that are not Turing complete and hence not languages in the strict sense include HTML, XML, JSON, etc. But it is often quite surprising to come across Turing complete languages in the most unexpected places. Indeed, it was surprising for me to learn that tools like Vim, sed, AWK, etc, are Turing complete. This knowledge about Turing completeness can be used to shed some light on exotic programming languages. Esoteric programming languages are tiny programming languages that are Turing complete. In layman’s terms we can say that esoteric languages are powerful enough to do any task that is achievable by heavyweight languages like C, C++, Java, etc. Some of the joke languages and most of the non-English-based languages are also Turing complete.

The importance and relevance of exotic programming languages

Now we know that the languages we will be discussing here are Turing complete and are worthy of being called a ‘programming language’. What about their relevance in the open source arena? In my opinion, these languages truly capture the ethos of open source program development. They neither have any commercial applications nor will they ever allow the developer to earn even a single rupee. No profit-seeking company will ever develop any of these languages. But each and every one of these languages has a small but fervent group of supporters responsible for development and maintenance. This underlines the fact that the real value of open source development is broadening the frontiers of knowledge and not just monetary benefit.

Another question that needs an answer is regarding the uses of exotic programming languages. If these languages are not widely used then why study or write about them? For starters, programming is not always about developing applications. Programming can also be used to test the skills of a potential candidate in an interview, to create puzzles that will baffle even the most accomplished programmer, for recreational purposes, etc. So, in essence, exotic programming languages are somewhat similar to crossword puzzles or word jumble games; they offer very good exercise for the mind. Over the years, thousands of pages have been filled about the features of different programming language paradigms like object oriented programming, structured programming, functional programming and logic programming. Also, computer magazines have published volumes about different languages like C, C++, Java, Python, etc. But none of them ever considered exotic programming languages seriously. So it will be pure fun for readers to get to know these weird languages.

Esoteric programming languages

Esoteric programming languages (also known as esolangs) are Turing complete languages in which program development is done with a tiny set of tokens. These languages are created to test the patience and perseverance of potential geeks. The sheer variety of languages available is quite amazing. In this section we will discuss just five esoteric programming languages. In fact, there are more than 750 entries in the wiki page about esoteric languages. We will discuss esolangs called Brainfuck, Ook!, Piet, Whitespace and Java2K.

Brainfuck

Brainfuck is the most widely used and popular esoteric language. But its awkward name often limits public discussions on it. The language is often called BF, Brainf*** or Brainf**k by the timid. So henceforth I will address the language as BF, which is known for its extreme minimalism. There are only eight commands and one instruction pointer in BF. A data pointer is used to point to the current cell being processed. The number of cells is theoretically infinite and all are initialised to zero. The eight commands are represented by the following eight symbols. They are:

  • ‘<’ (less than to increment data pointer)
  • ‘>’ (greater than to decrement data pointer)
  • ‘+’ (plus to increment the byte at the data pointer)
  • – (minus to decrement the byte at the data pointer)
  • ‘.’ (dot to output the byte at the data pointer)
  • ‘,’ (comma to store one byte at the location pointed by the data pointer)
  • ‘[‘ (opening square bracket to forward the instruction pointer to the next command after the closing square bracket if the byte at the data pointer is zero), and
  • ‘]’ (closing square bracket to move back the instruction pointer to the next command after the opening square bracket if the byte at the data pointer is non-zero).

Thus any BF program will consist of only these eight symbols.

Whitespaces are ignored by the BF interpreter. There are many open source interpreters available for processing BF. One of the most widely used interpreter and IDE for BF is an open source IDE called BFdev. The extensions for BF programs are .b and .bf. Writing programs in BF is considered a Herculean task. It is so difficult that if there is a God and if he ever lets me enter heaven, I will request him to write an operating system using BF – just as proof of his omniscience. Similarly, printing an arbitrarily large BF program might take up the whole magazine. So I will stick to a trivial task. The following is a BF program to print the text ‘OPEN SOURCE FOR YOU’ on the screen.

+++++++[>++++++++++<-]>+++++++++.
>++++++++[>++++++++++<-]>.
>+++++++[>++++++++++<-]>-.
>+++++++[>++++++++++<-]>++++++++.
>+++[>++++++++++<-]>++.
>++++++++[>++++++++++<-]>+++.
>+++++++[>++++++++++<-]>+++++++++.
>++++++++[>++++++++++<-]>+++++.
>++++++++[>++++++++++<-]>++.
>++++++[>++++++++++<-]>+++++++.
>+++++++[>++++++++++<-]>-.
>+++[>++++++++++<-]>++.
>+++++++[>++++++++++<-]>.
>+++++++[>++++++++++<-]>+++++++++.
>++++++++[>++++++++++<-]>++.
>+++[>++++++++++<-]>++.
>+++++++++[>++++++++++<-]>-.
>+++++++[>++++++++++<-]>+++++++++.
>++++++++[>++++++++++<-]>+++++.

The size of the program clearly illustrates the difficulty of writing even the simplest of programs in BF.

Ook!

Ook! is not an independent programming language. It is a derivative language of BF. What makes Ook! interesting is the fact that there are only three keywords — Ook., Ook?, and Ook!. These three keywords are taken in pairs to form the eight keywords of BF. The three keywords of the language Ook! are created in such a way that they are supposed to be writable and readable even by orangutans. There are some online interpreters freely available for Ook!. The size of programs tends to become even more longer with Ook!. The following is an Ook! program to print my name ‘DEEPU’ on the screen.

Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook. Ook. Ook. Ook! Ook. Ook! Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook. Ook. Ook. Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook.

The program is too large for debugging and comprehension; hence, all we can do is hope and pray that the program gives the correct output.

Figure 1

Piet

Piet is an even more bizarre esolang. The programs in Piet do not use any text-based keywords; instead, Piet uses coloured blocks as keywords. The final program obtained in the Piet language will look like an abstract painting. This is the reason why it’s named after the Dutch painter Piet Mondarin, who is the pioneer of geometric abstract art. The extension of a Piet program is .ppm (Portable Pixelmap Graphics), which is an open graphics file format. The most widely used IDE for Piet is the open source Piet Creator. I tried to create (the word ‘write’ is not appropriate for Piet programs) a Piet program to print ‘OPEN SOURCE FOR YOU’. But after a few hours, I understood that every man has his breaking point; so I satisfied myself with printing ‘OSFY’. Figure 1 is actually the program to print the message ‘OSFY’.

But I also came to know that there are interpreters for Piet created using Piet itself. I was dumbfounded at the mere thought about such a horrendous venture. Imagine the countless agonising hours spent by those geeks to develop these types of near impossible programs. I am sure if there ever were a religion for open source developers, these guys would be canonized as saints by the devotees.

Whitespace

In almost every programming language, whitespace characters are ignored by the compilers and interpreters or have minor implications. But Whitespace is an exception to this rule. It is an esoteric programming language in which the whitespace characters alone are used to generate the program. Every non-whitespace character used in the program is considered as a comment and ignored by the compiler. This language can never be included in the academic curriculum because the answer script containing the correct Whitespace programs will look exactly like the one without any answer – it will be blank! The programs are generated by using spaces, tabs and line feeds alone. The five commands in the language Whitespace are described below. [Space] is used for stack manipulation. The combination [Tab][Space] is used for arithmetic operation. The combination [Tab][Tab] is used for heap access. [Linefeed] is used for flow control, and the combination [Tab][Linefeed] is used for I/O manipulation. Since Whitespace ignores all the non-whitespace characters, programs can be easily embedded inside other free form languages like C. Thus Whitespace can be used to generate polyglot programs, which are programs written in a valid form of multiple programming languages.

Java2K

I will end the discussion on esoteric languages with Java2K. It is in no way related to the popular programming language, Java. Most of the languages we ever come across are deterministic programming languages. But Java2K is a probabilistic programming language. Every function in Java2K has two implementations, and the actual version of the function to be executed is selected at runtime, based on the values provided by a pseudo random number generator. So it is extremely difficult to write programs with relatively high accuracy. To make it even more difficult, the language uses a base-11 number system with whitespace as the eleventh symbol in the number system. Of all the five esoteric languages discussed in this section, I found Java2K the most annoying. So I leave the readers to experiment with this depressing language.

Joke languages

Joke languages are those exotic languages that do not serve any practical purpose other than the potential fun that can be had by dabbling with them. They are mostly generated from existing esoteric programming languages and not usable even in theoretical scenarios. Sometimes, joke languages are created by ingenious programmers to win certain contests. There are about hundred entries in the wiki page about joke languages with languages even named ###, ***, COW, FIFTH, etc. Many of these joke languages are not Turing complete and are not programming languages in the true sense. Joke languages include those used to generate programs that will serve just a single purpose. For example, a joke language called 99 is used only to generate the lyrics of the song ‘99 bottles of beer’. Joke languages also include languages like Malbolge, often considered the most difficult language ever invented to write an executable program with.

Non-English-based languages

Most well known languages have their character set based on the English alphabet. The overwhelming trend in computer science is to accept the dominance of English as the principal language. This is true even for languages that were developed in non-English speaking countries. For example, Python was developed in the Netherlands and Ruby in Japan, but even these languages adopted English-based keywords. But there is a small minority of languages that use non-English characters to form their tokens. Chinese programming languages, which were developed in the 1970s, are examples of languages using non-English characters for token generation. It’s interesting to know that there are programming language systems that use Indian languages like Hindi and Bengali to form their tokens. The Hindawi Indic programming system is a scalable system, which supports many programming paradigms. Hindi and Bengali C (Shaili Guru), C++ (Shaili Shraeni), OpenJava (Shaili Kritrim), lex (Shaili Shabda), yacc (Shaili Vyaaka), x86 Assembly (Shaili Yantrik), BASIC (Shaili Prathmik) and Logo (Shaili Robot) are the different languages supported by the Hindawi system. The system uses front-end compilers that translate the Hindi or Bengali code into its English equivalent, which in turn is compiled by the GCC compiler that acts as a back-end compiler. These kinds of non-English-based programming languages are very helpful to students without an English background.

This article has discussed some of the weirdest programming languages that have ever been created by humans. On the surface, it may seem that these languages are purposeless and a waste of time. But, in reality, they are useful in many different ways. They expand our knowledge of how programming languages work, they offer challenging puzzles to budding programmers and they also represent the real spirit of open source development. But the journey through exotic programming languages was slightly disappointing because none of the languages I have featured here were developed in our country. I believe that as a computing superpower we must make a contribution in every field of computing.

SHARE YOUR THOUGHTS & COMMENTS

Your email address will not be published.