Elegant Code? PDF Print E-mail
Written by Alex   
Wednesday, 10 September 2008

I often hear about it, but it's a pretty vague term. I definitely think smashing too much into 1 line fails to qualify. Anything 'elegant' has to be easily understood, as the word implies that you're taking something seemingly complex and making it simple.

There's readable, which is often long.
There's short, which is often dense and unreadable.

short + readable == elegant

This is my own take on it. I was definitely inspired by a comment I read on Slashdot a while back.

The problem here is that small != mean efficient.
Parsing the code is not what makes a program slow, and
we don't code for 1K or RAM anymore.

"impressive" oneliners completely fail to impress me.
Lines are cheap.
Time is not.
And bugs are expensive as hell.

...

If you feel it is childish to write code like
  "find A"
  "find B based on A"
  "generate C based on B"
  "silently fail for some values of C"
  "replace B with C"
-rather than one giant, brittle regex-replace, I submit that you are the childish one.

Last Updated ( Wednesday, 10 September 2008 )
 
< Prev
Random Deanspot Image