Nonsensical Programming

By

When it comes to development there is a programming language for every situation.  Languages are optimized for metrics like speed and usability while doing their best to minimize the tradeoffs.  New languages are built from their predecessors, correcting past mistakes and inventing new paradigms.  While these noble languages have produced many solutions in a wide variety of fields, not all languages are created equal.  Some languages shouldn’t be used for any projects.  Esoteric Programming Languages are known to be incredibly complex, unusable and nonsensical.  At the same time, many of these languages are Turing Complete, meaning they can solve any computer problem a regular programming language can.  Let’s look at a few of these impractical monstrosities.

Befunge

Befunge is a stack based language where the goal was to be as difficult to compile as possible.  The code uses arrows to control the program flow where the characters <  ^ v  > point in the direction of the next command to execute.  The code can also modify itself, meaning the app may perform completely differently by the time it terminates.  Here is an example that computes a factorial:

The program starts with user input with the “&” character.  It pushed numbers 5 thru 1 in onto the stack using a “loop”.  Then it loops through the stack again multiplying the values together until it outputs the factorial.  Though the goal of this language was to be as hard as possible to compile, developers like a challenge and several working compilers have been created.  In fact, this language has been extended further in a child language called Funge.  The largest difference is you are no longer limited to a 2-dimensional plane to write your code.  If this code wasn’t already difficult to understand you can now write the directional code in 3 or more dimensions!

Whitespace

Developers have a wide range of preferences when it comes to formatting code.  Many discussions have devolved to vicious arguments over using tabs vs space and how to indent your code.  Most languages will ignore formatting to accommodate personal tastes.  The next language, Whitespace, completely reverses this concept.  The Whitespace programming language ignores everything but spaces, tabs and new lines.  Different combinations of whitespace characters perform different actions in this stack and heap based language. Below is the classic “Hello World!” function in Whitespace:

It’s impossible to read without syntax highlighting and comments, takes many lines to do anything, and extremely difficult to debug.  I wish you the best of luck if you ever attempt to use it.

GolfScript

As you can see these languages tend to be very difficult to read.  It seems like readability is an important and necessary trait for a “real” programming language.  However, every problem is different and sometimes being unreadable can be advantageous.  There is a popular developer game called “Code Golf.”  The object is to write a function to solve a problem as concise as using the fewest amount of characters.  Typically, people would write functions in popular languages like C, JavaScript and Python and took advantage of little-known tricks in the language to produce short code.  However, Code Golf presented an interesting problem and eventually developers created concise programming languages to get better and better scores.  GolfScript is one of these languages, and though esoteric, it has a valid use case.  By using a combination of overloaded operators and very extensive built in functionality, GolfScript creates very concise, hard to read code that is great for Code Golf.  The following prints out the first 1000 digits of PI:

Programming languages come in all shapes and sizes.  Unorthodox languages provide an interesting look at what programming paradigms are possible.  It is fun to mess around with Esoteric Programming Languages to see what unique solutions can be created for simple problems.  Don’t forget, the code might look different but in the end it is all 1s and 0s.

About The Author

Tom Duffy is a Lead Consultant on the Software team.