The thing is, I love code. I suspect I love code more than most of my peers. Code is poetry. It's creativity. Code tells a story, and a very complex one at that. Coding is a creative problem solving exercise. A finished program both describes and solves a problem: not only does it describe an algorithm - a recipe for solving a puzzle - but it writes it in a way that a machine built entirely out of principles of physics can actually execute. Good code can even make such a machine flexible and adaptable. Clever or interesting code brings me a thrill akin to that felt by people who enjoy poetry. It is accompanied by the rush of having learned or discovered something new - and appreciation of the design skills and intelligence of the author. In a world of complete imperfection, we have in our hands the ability to create things of near perfection. If one only cares enough, one can create error-free, beautiful programs...
Visually, code is beautiful to me. There is a wonderful symmetry in well formatted code, and when you add pretty syntax highlighting and a nice monospace font, things become... well, I would print and frame code if I had any space to hang it. The uniqueness of the programming design itself is further emphasized by the uniqueness of formatting. I once had a professor tell us that he can recognize when a student submits someone else's code, because the physical formatting of the code changes from previous submissions.
Many people barely format their code - "if it works," they say, "that's all that matters. Formatting is wasting time." Not so, I respond. Code is never eternal - it will need additions and bug fixes and updates. The people that come after you will need to follow and understand exactly what you've done - and clear formatting and comments will aid them in that task. Beauty in code does not exist for beauty's sake: pretty code is easier to understand, maintain and often is faster and more accurate than ugly code.
Formatting code shouldn't take long - it should become an ingrained habit of any programmer worth their salt, and it is certainly made much easier by the use of IDEs that handle things like indentation, comment blocks and even method headers for you. There really is no excuse to produce badly formatted code.
As poetry, code is like a haiku, or iambic pentameter: it has very heavy restrictions, and bad programmers fight these restrictions instead of flourishing within them. Good programmers dance elegantly through the keywords, libraries, paradigms and quirks of the language they're writing in. Good programmers explore every inch of their language, seeking to find gems of functionality. Tracing thoughtful code is an absolute pleasure - it is an intellectual exercise, filled with many "aha!" moments.
Just like with creative writing, each programmer has their own characteristic style. The lens through which they view the world becomes an integral part of their approach to problem solving. Some programmers are clever, others are clear. Some are dirty, others are arbiters of standards. Some programmers seek to squeeze every byte of efficiency out of a machine, while others are relaxed about resource use. A professor once told us that after years of experience tracing other's code, it becomes rather like reading a book: you stop focusing on the words and structure of the sentences, and instead focus on what they are saying. Good programmers get their message across clearly and effectively, just like good writers do. Beautiful code will have delightful concepts and clever solutions laying beneath the literal text of a program.
In the hands of a good programmer, any language can become beautiful. There are thousands of computer programming languages out there - those of broad use, some of specific use, some that seem to exist solely for the amusement of the language author. That's right, some programs and languages contain fair amounts of humour. A great example is LOLCODE. The following example program, in LOLCODE, opens a file and prints the contents, and includes rudimentary error handing:
Another rather amusing example of the... flavour of the programmer is the count of swear words present in the Linux kernel source as the system develops over time. I'm not sure which I like more: that there are over 200 instances of "shit" in the source code, [or almost a hundred of "penguin"], or that someone decided to count them all. Code can be fun, in addition to being beautiful - just like with any art.
Knowledge and beauty is all we have. Intelligence is beautiful. Thoughtful design is beautiful. Simple and elegant solutions to complex problems are beautiful. Code that doesn't lie - that presents itself clearly and truthfully is beautiful. Code is like poetry - and good code is as thrilling and stimulating as good poetry. It is one of my loves...