Saturday, April 29, 2006
For the love of code
A lot of programming is CRUD, create/read/update/delete -- the usual operations for business applications. A lot of programming is also crud -- ugly.
However, some programming is beautiful.
However, some programming is beautiful.
- Quines
- The Medium is the Message
- Spam Filtering
- Freedom of Speech
A quine is a source code listing which, when compiled and run, outputs... itself. Its self-referential aspect and the intellectual challenge of creating such a beast makes it a joy to create.
e.g., try the following LISP quine out at this online interpreter:
((lambda (x)
(list x (list (quote quote) x)))
(quote
(lambda (x)
(list x (list (quote quote) x)))))
Sometimes, programmers take the idea of programming as an artform too literally. Can you guess what code to display and allow a user to interact with a maze might look like? If you guessed something like this, you're right!
For years programmers tried to deal with spam filtering with a HUGE set of hand-crafted rules based on trial-and-error. These engines would run into the thousands of lines of code. In 2002, Paul Graham proposed a statistical approach to spam filtering.
Its engine? Included below.
(let ((prod (apply #'* probs))) (/ prod (+ prod (apply #'* (mapcar #'(lambda (x) (- 1 x)) probs)))))
There was a little bit of a kerfluffle in the world of computers in 2000. A Norwegian man wrote some code that broke the encryption of DVD videos, allowing them to be freely playable on non-licensed computers (e.g., computers with alternative operating systems). This also allowed people to make non-encrypted copies for backup and stealing to give away to their friends.
The small chunk of code, known as DeCSS, flew around the world. The United States of America moved to quash the reproduction and sharing of this code as it violated the Digital Millennium Copyright Act's provisions that no one should try to circumvent copyright systems. Surprisingly, hackers obeyed -- they didn't share the original source code. Instead, they shared this version, this version, this version, and this version.
To be fair, these last four links are still all code. Surely, they too must be in violation of the DMCA?
But what about this -- a haiku which intermingles a poetic description of the decryption procedure with analysis of the ongoing legal problems?
What about a song describing the procedure?
What about a melody, created by mapping the characters of the decrypt function onto musical notes?
(All resources shamelessly stolen from here.)