Alex Netkachov has an interesting post on his blog, giving tips on writing less code. It’s an interesting post, because this is something is very subjective.

First, you want to find out why you want to write less code, less code for the sake of writing less code is dumb, if you really don’t want to write code, then that’s a completely different thing, hire me, or the countless other guys who like writing code :).

What are the benefits of writing less code? Does it make the code run faster? Does it help you save disk space? I’m not really sure.

Tip #2 says use ternary operators.. this is a pet peeve of mine, I really can’t find a good reason why these operators still exist, or are used in high level languages like PHP, but I personally think the use of ternary operators in 99% of the situations I’ve seen, is just the programmer thinking he’s being clever. Eventually ternary operators make code less readable, but again that is subjective, not authoritative. I find lots of things unreadable, but they’ve made the best seller lists, so.. what do I know?.

Tip #3, I really don’t see a benefit of using for vs while, again this is subjective, I think it boils down to what one puts more priority on, one line of code, or more readable code.

He does make the comment about writing better documentation in your code, but I really don’t see why the two have to exclusive..

I think S0enke put it best in the comments.. “Writing less code is not about writing less lines. It’s about avoiding copy-and-paste programming and no formatting-paradim but more a question of programming skills.”

If your code is executing faster because you have fewer lines of code, than you did in version 1, you have a bigger problem than you realize.