X hits on this document

PDF document

1. INTRODUCTION - page 2 / 10





2 / 10

int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\ o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}

Figure 1. An anonymous entry to the 1984 International Obfuscated C Code Contest that prints “hello, world!”

software into the language

brought code into a legible condition. Cables patched

ENIAC were not themselves legible,





but was.

assembly Human

readability of programs was further enhanced as high-level programming languages, beginning with FORTRAN, were developed.

In the question and answer period after a lecture, Donald Knuth, the famous computer scientist who is author of The Art of Computer Programming, recalls reading the program SOAP from Stan Poley: “absolutely beautiful. Reading it was just like hearing a symphony, because every instruction was sort of doing two things and everything came together gracefully.” He also remembers reading the code to a compiler written by Alan Perlis and others: “plodding and excruciating to read, because it just didn’t possess any wit whatsoever. It got the job done, but its use of the computer was very disappointing.” Knuth says of the aesthetics of reading programs and the reader's pleasure: “I do think issues of style do come through and make certain programs a genuine pleasure to read. Probably not, however, to the extent that they would give me any transcendental emotions.” [6]

This discussion is not about any sentimental effects that code may have on the human reader, but does consider in detail the issues of programming style and the ways in which human readers read code. An aesthetic of code is suggested by Knuth's comments, one that is typified by beauty and grace and is clearly identified by Maurice Black in his dissertation, “The Art of Code”:

box of the program, the source code itself is obscure, contrived to foil human legibility rather than enhance it.


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; judging of the 18th IOCCC was underway when this article was written. Only small, complete C programs can be entered in the contest, which rewards originality and the aesthetic abuse of the C language. The contest's stated goals include demonstrating the importance of programming style (“in an ironic way”) and illustrating “some of the subtleties of the C language.” [4]

An anonymous entry in the first IOCCC (Figure 1) accomplishes these goals in only two lines, and also plays on the conventional “hello, world!” program, a program which is typically used as a simple first example when learning a programming language. Brian Kernighan and Dennis Ritchie (the creator of C) begin their classic book The C Programming Language [5] with such a program:

#include <stdio.h>



printf("hello, world\n");

Computing culture ... has adopted a traditional model of literary aesthetics as a means of effecting change, finding political utility and social value in the well- crafted product that is at once entirely usable and wholly beautiful to contemplate. The distinctions are clearly evident in the respective disciplines' discourses: whereas terms such as “elegant” and “beautiful” circulate freely in computer culture to describe well- crafted code, elegance, beauty, and all their synonyms have been effectively exiled from the vocabulary of literary and cultural theory ... [1] Black devotes a section to Knuth's aesthetic views and his concept of “literate programming,” and another section to John Lions's book-length commentary on the beautiful, elegant Unix operating system. “The Art of Code” clearly establishes the classical aesthetic of programming as the dominant one in the discourse of software development. More recent articles, such as one entitled “Beautiful Code” that appeared in Dr. Dobbs, show that this aesthetic is still going strong: “Instead of searching for some automated measure ... perhaps we should be striving for beauty in our work because we believe that beautiful things are better.” [3] It is fairly easy to find programmers extolling the beauty of programs and code snippets online, and also easy to find suggestions for writing elegant, clearly-written code in introductory programming textbooks.

There is a dark side to coding, however, one in which, even though a person can see into what would otherwise be the black


The obfuscated program prints “hello, world!” as it is supposed to, but in a very tortuous way. To see how this program comments on C programming style and the subtleties of C, it is necessary to discuss the program in detail, and to discuss the C programming language in detail. The explication that follows will be most easily followed by those who know how to program and will be best understood by those who have had some experience programming in C. However, the connection between the obfuscations seen in this code and the particular nature of C should be evident to some extent even to those who are not able, or do not wish, to follow all the details. To begin, here is a clearer C program that prints “hello,


main() { write(0,"hello

, world!\n",14);


Even this simple program comes with a bit more baggage than the BASIC equivalent, 10 PRINT "hello, world!", and it is more complex than the program Kernighan and Ritchie use to introduce C. The system call write is used in this code with three arguments: 0 means the writing will be done to standard output; the second argument is the string to write, which includes a newline character encoded as \n at the end; and the third argument, 14, is the length of the string, the number of

Document info
Document views39
Page views39
Page last viewedWed Jan 18 23:11:21 UTC 2017