⇥ The violin-playing software designer

August 18, 2008
22 comments
 
⇥ Permalink

What is beautiful code? Ask ten people, and you will probably get ten different answers. Ask them what makes a programming language beautiful, and you’ve got yourself the beginnings of a holy war.

For example, I have grown very tired of people telling me that PHP is an ugly language that promotes poor coding practices. PHP is, in fact, a great language, and its perceived ugliness is precisely what makes it so beautiful.

To me, at a visceral level, code is art. Beautiful code doesn’t just work well, but is pleasant to look at, examine, explore and understand. Like a painting, coding starts with an empty canvas—your editor window. Your language provides you with the tools and a palette that you can use to sketch, draw and paint your work of art.

Like with a real painting, it’s your personal abilities that dictate the quality of the end result. Languages and development platforms only provide you with the ability to realize your vision—or not.

This is why the best language is one that comes with sharp edges. Imagine someone forcing Leonardo to draw the Mona Lisa with erasable markers because oil-based paint would stain the furniture, or Edvard Munch having to create The Scream with crayons (ok, that’s not that much of a stretch, but stay with me) because he had a habit of eating his brush.

A good language is a language that gives a programmer the ability to experiment while imposing as few constraints as possible. If someone came to you and said “I’ve got this great idea for a painting of a bride… it’s great! It’s even got a violin-playing goat!” You’d probably think they’re insane—but what if they were Marc Chagall? Not so crazy now, eh?

PHP is the ultimate development platform—with the appropriate amount of discipline, you can use it to great truly outstanding code that can adapt to almost any development methodology. Of course, you can write spectacularly bad code with it, too, but that’s part of the bargain. Python is like that, too—as demonstrated by its application to a range of problems as diverse as mathematical research and game development.

It could be argued that not everyone is Leonardo, Edvard Munch or Marc Chagall, and that the vast majority of developers are better served by the paint-by-numbers approach of RoR and the likes. I prefer to think, instead, that the vast majority of developers is best served by a language that gives them a chance to stretch their wings and learn from their mistakes.

This, incidentally, is why I am scared—really scared—of the fact that so many post-secondary institutions have started teaching com-sci using Java instead of C. We are essentially breeding a generation of developers who have no real idea of the underpinnings of low-level software programming. In the short term, this may be good for the industry, but not so good for the future.