September 6, 2008

Balanced Tokens in Many Languages

Tony Morris blogs about his solution to the problem of validating ‘balanced pairs’ of tokens in a command line argument

Read both the article and the comments. Then come back here. Don’t worry, the browser will wait patiently for you.

My thoghts:

  • Tony Morris believes that he demonstrates that Haskell has better functional composition than Java. But given the examples of others in the comments, he has only demonstrated that he does not know how to produce well-designed Java.
  • His Haskell example has a high complexity/size ratio (technical density, if you will) and it would be very difficult for anyone but a Haskell expert to decode it.
  • There are lots of examples written in the comments, in various languages, many of which are more elegant (easy to understand, yet effective in small spaces) than anything Tony wrote

It’s clear from the article that Tony wrote these in a hurry, and I don’t want to sound like I think he’s a bad programmer or a bad person because I disagree with him about the ‘lesson’.

What is interesting is that Tony wrote the code with a certain mental model of what ‘success’ meant. And the comments exploded with people coming up with different definitions of success, and different ways to succeed.

As an Agile Project Manager, if I can define success the right way (for me): “I want a balanced token matcher, that’s easy to maintain“, then I can step out of the way, and let the developers figure out how to meet that goal.

Kudos to Tony for bringing up this interesting discussion.

(Hat Tip: Ragenwald)