X hits on this document

PDF document

1. INTRODUCTION - page 4 / 10





4 / 10

int i;

main() {

for( ; i["]<i;++i){--i;}"] ; read('-'-'-',i+++"hello, world!\n",'/'/'/'));


read(j,i,p) { write(j/p+p,i---j,i/i);


The final program is the above code with all unnecessary whitespace removed and with the resulting line broken in two, using a backslash in the middle of the "hello, world!\n" string.

This example suffices to explain what obfuscations are and how they relate to the programming language in which they are written, although most IOCCC entries do far more elaborate things. Gavin Barraclough's 2004 entry, which won best of show, is exemplary. His program, less than 3600 characters in length, is actually formatted in a “friendly” way, but is cryptically scattered with one-letter variable names. The approximately two and a half pages of code provide, as the hint file explains,

a 32-bit multitasking operating system for x86 computers, with GUI and filesystem, support for loading and executing user applications in elf binary format, with ps2 mouse and keyboard drivers, and vesa graphics. And a command shell. And an application - a simple text-file viewer. [4]


Some of the obfuscations that are seen in IOCCC, and some that can be seen in the “hello, world!” program, can be more or less universally applied by programmers, regardless of language. The use of meaningless variable names such as j and p is always possible. The deceptively-named variable i (which looks like an earlier variable i) and the misleadingly-named read function are other examples of a universal programming pitfall. Whenever variable and function names can be freely chosen, there is always the potential for the coder's choice to be uninformative or misleading. This can be intensified in C, where variable names are case sensitive; some programs take advantage of this to name variables o and O, for instance, inviting additional confusion with the number zero. This play, which can be called naming obfuscation, shows one very wide range of choices that programmers have. Such play refutes the idea that the programmer's task is automatic, value-neutral, and disconnected from the meanings of words in the world.

While these programs often critique or play with programming in general, the winning IOCCC programs also strongly assert their Cness. a[b] and b[a] do not mean the same thing in other languages, so a programmer could not choose the more confusing of the two. Other languages do not define the addition of strings and numbers, or they define it in a

way that




at least to beginning

programmers. But C, by giving the programmer the power to use pointers into memory as numbers and to perform arithmetic with them, particularly enables this sort of pointer confusion. By showing how much room there is to program in perplexing ways

  • and yet accomplishing astounding results at the same time —

obfuscated programs demonstrate that C is powerful, and also that clarity in C code is achieved only with effort.

The “fake ending” to the for loop in the hello world program, which is achieved by embedding a deceptive string "] <i;++i){--i;}", is an example of data/code confusion. This is actually a mild example meant to fool a reader for a moment into thinking that this (meaningless) string is code; other obfuscated programs may transgress the code/data boundary in other ways, by consuming their source code as input, by generating their own code as output, or by modifying themselves as they run.

There is also an Obfuscated Perl contest, run annually by The Perl Journal since 1996. While Perl is quite unlike C, even beginning Perl programmers will be quick to realize the great potential for obfuscation that lies within the language. For one thing, Perl offers a dazzling variety of extremely useful special variables, represented with pairs of punctuation marks; this feature of the language nearly merits an obfuscation category of its own. Perl’s powerful pattern-matching abilities also enable cryptic and deft string manipulations. Perl is sometimes de- acronymized as “Practical Extraction and Report Language,” but has also been said to stand for “Pathologically Eclectic Rubbish Lister.” The language is ideal for text processing, which means that printing “hello, world!” and other short messages can be done in even more interesting ways. Thus, the tradition of writing an obfuscated Perl program that prints “Just another Perl hacker,” arose on USENET and became common enough that a program to do this is known simply as a JAPH. The popularity of these programs is attested to by the first section of the Perl FAQ, which answers the question “What is a JAPH?” [10]

More generally, Perl has as its mantra “there are many ways to do it.” A half-dozen Perl programmers may easily know eight or ten different ways to code exactly the same thing. Because of this, obscure ways of doing fairly common tasks are lurking everywhere. A common, high-level obfuscation technique that is seen in obfuscated Perl and also in obfuscated C (however differently it may be expressed there) involves choosing the least likely way to do it. This could mean using a strange operator, a strange special variable, or an unusual function (or an ordinary function in an unusual way). It could also involve treating data that is typically seen as being one type as some other type, a view that is permissible according to the language but not intuitive.

Perl and C are distinguished by having obfuscated programming contests, but they are not widely despised languages — unlike, for instance, COBOL or Visual Basic. Why are these hateful programming languages not the targets of obfuscatory ridicule? The most obvious explanation is that the programmers who write obfuscated code are Perl and C hackers, often professional ones. They enjoy hacking in these languages, as do many free software developers and creative coders, and would not choose to program in COBOL or Visual Basic for fun. Their play with Perl and C is not pure pillory. In addition to making fun of some “misfeatures” or abusable features of the languages, obfuscated code shows how powerful, flexible programming languages allow for creative coding, not only in terms of the output but in terms of the legibility and appearance

of the source code.







  • naming

obfuscations and language-specific ones, such as choosing the

Document info
Document views20
Page views20
Page last viewedTue Oct 25 13:31:11 UTC 2016