Friday, July 20, 2007

goto

This comic (over at the brilliant xkcd), is what I consider to be an indicator of the presumptuousness of most Computer Science students (including myself). What Dijsktra proposed in his seminal paper "Goto Statement Considered Harmful" is not even deemed as necessary reading for contemporary students of Computer Science. Instead the goto is frowned upon, abolished almost, without caring to understand its history. Now, I use gotos (only recently and very sparingly, of course) because it helps to alleviate unnecessary restructuring sometimes, the most obvious case being function-exit sequences. Thinking about elegant code structures is what takes up most of my time now than the actual coding session. I cringe when I look back at some of the code I've written, how superfluous the statements, how blunt the case-statements, or crude the nested "ifs and elses". I'm not saying it's the fault of the language, rather the prejudice and the inexperience of the programmer, who understands control flows, but not program flows. It is not easy to lift this weight of past-code-disregard off my mind, but to even realize the presence of such a weight is one step in the right direction.
A well-annotated version of Dijkstra's paper can be found here.

No comments: