{ by david linsin }

December 27, 2007

Reading Code or Writing Code

What is more important? Reading or writing code? Neil Gafter thinks it's reading code and I tend to agree!

Java does a great job in terms of readability. If you name your variables and methods in a human readable way, it's quite easy to understand what your code is supposed to do by only scanning through the method signatures of your classes. This is a big advantage and it helps a lot in understanding other people's code.

However, with readability comes verbosity and that's where people see a potential for increasing productivity. Compared to Java, you can save a lot of key strokes using a dynamically typed language, where you don't have to provide e.g. type information. SteveYegge claims he can save up to 50% of LOC rewriting a project of his using a dynamically typed language, instead of Java.

His statement got me thinking: Is readability and thus understandability of code using a dynamically typed language the same as with Java?

One could argue, that if you know the dynamically typed language well enough, you'll probably understand the code as fast as it was verbose. You could also bring forward the argument, that if you are used to the terse code style of a language likeperl or python, understanding it's code will be a no-brainer.

For me this topic is a little conflicting. On the one hand I love Java's readability and it's understandability. My IDE is supporting me with code completion and generation, so that even the verboseness doesn't bother me that much. On the other hand, theflexibility and somehow agility that you gain with the terse syntax of a dynamically typed languages are really appealing.

I still favor readability over terse syntax, especially when it comes to maintaining legacy code. For me, a hybrid approach like Scala is the way to go. I get the best of both worlds.

0 comments:


com_channels

  • mail(dlinsin@gmail.com)
  • jabber(dlinsin@gmail.com)
  • skype(dlinsin)

recent_postings

loading...