Obfuscation

Obfuscated code and weird programming practices

Modern computer programs are textual languages written in a way that is meant to be understandable — or at least readable — by virtually everyone.

For those willing to get their hands dirty with coding it is essential to be able to “read” a computer program. This means developing an understanding of the computer’s behaviour, and interpreting the significance of the structure of the program when this runs the code, even when this code is purposely intricate and very difficult to read— i.e. obfuscated.

As defined by Wikipedia, software obfuscation “is the deliberate act of creating source or machine code that is difficult for humans to understand. It may use needlessly roundabout expressions to compose statements. Programmers may deliberately obfuscate code to conceal its purpose or its logic or implicit values embedded in it to prevent tampering, deter reverse engineering, or even as a puzzle or recreational challenge for someone reading the source code”¹

Yet, while a computer system may compile code even when this is obfuscated, I believe it is crucial that code should be written in a such a form that can be easily interpreted by people as well. This is a typical perspective on writing code that follows rules of clarity and elegance. It is, in fact, very easy to find programmers praising the beauty of well-written code online. It represents such a common practice which cannot be unseen, and both the web and programming textbooks are inundated with tutorials and tips for writing elegant code.

However, as investigated by Nick Montfort and Michael Mateas with their paper A Box, Darkly: Obfuscation, Weird Languages, and Code Aesthetics, how do we explain the existence of obfuscated programming — either as a software development or as an aesthetic practice — in a world schooled with intelligible coding in mind?²

Some languages, often referred to as weird or esoteric languages, are often specifically designed to make legibility of a program arduous. They aren’t geared towards real-world applications neither are designed for any educational use. Weird programming languages exploit the concept of obfuscated code to “highlight the importance of the human reading of code in software development.”(Montfort and Mateas, 2005)²

With the rise of weird language programming, professional programmers and hackers alike started to organise obfuscated code contests as a mean to get creative with coding, rethinking the way most people perceive this practice (often idealised more as technical and structural, rather than artistic).

We shouldn’t be afraid to associate developers with artists. And yes, while some branches of programming are aimed at “fixing” and “posing the foundations” for the work of other coders (i.e. not what one would usually define as creating coding); there will always be creativity involved in writing code.

The aim of obfuscated code contests is never just about programming software through hard to read code (this is often achieved by introducing layers of complexity into the structure of the code) — they are about pushing the boundaries of the semantics of a language, creating art by playing with the syntax of code itself.

“In 1984 Landon Curt Noll and Larry Bassel held the first International Obfuscated C Code Contest. The contest was a success that has been repeated many times. […] The contest’s stated goals include demonstrating the importance of programming style. […] There is also an Obfuscated Perl contest, run annually by The Perl Journal since 1996.” (Montfort and Mateas, 2005)²

Common theme to all obfuscations is their intent to explore “the play in a language”², eliminating boundaries — or creating new ones — in programming language design.

The code snipped above is written in INTERCAL, a language that parodies other programming languages.

Coding in the realm of weird programming languages is often referred to as multiple coding. An example of multiple coding is Perl Poetry — “often little more than an exercise of porting existing song lyrics into Perl” which “does little to articulate the language of Perl itself”²

Black Perl, a famous example of Perl Poetry

On the other hand, the aim of Minimalist languages is to achieve “universality” while providing the programmer a very limited range of language constructs.

This code is written in Brainfuck, the esoteric minimalist language for excellence. Brainfuck consists of only eight simple commands and an instruction pointer. (Wikipedia)

Other weird languages, rather than simplifying and minimalising code instructions, they play with the syntax to produce literary artifact that can also run as valid programs.

The structure of the Shakespeare language exploits this “play” aspect in all its forms because it actually follows the structure of a stage-play.

Obviously the list of esoteric programming languages doesn’t end here. There are hundreds of weird languages out there, some trending while others almost abandoned.

I find that a useful way to grasp the way these languages work is to read their code snippets for compiling “Hello, World”. Try looking at the length, complexity, structure, and syntax of esoteric code here: https://esolangs.org/wiki/Hello_world_program_in_esoteric_languages


References:

  1. En.wikipedia.org. (2018). Obfuscation. [online] Available at: https://en.wikipedia.org/wiki/Obfuscation [Accessed 9 Mar. 2018].
  2. Montfort, N. and Mateas, M. (2005). A Box, Darkly: Obfuscation, Weird Languages, and Code Aesthetics. pp.1–10.

Francesco Imola is a London-based musician, weekend photographer, and current Sound Design student at the University of Greenwich.

w. http://francescoimola.com/

tw. https://twitter.com/francescoimola