GHC Wiki on Code Transparency
Posted Under: Programming,Programming Languages,Quote
I first read this in The Little Calculist‘s blog, but I felt that it was such an important point that I wanted to post again to underscore the point.
It’s much better to write code that is transparent than to write code that is short.
Often it’s better to write out the code longhand than to reuse a generic abstraction (not always, of course). Sometimes it’s better to duplicate some similar code than to try to construct an elaborate generalisation with only two instances. Remember: other people have to be able to quickly understand what you’ve done, and overuse of abstractions just serves to obscure the really tricky stuff, and there’s no shortage of that in GHC.
It’s nice to hear this from some of the programmers most entrenched in abstraction. One of the (very few) reasons we use programming languages is to show other people how we talk to the computer. Unless your primary goal is memory efficiency or speed, the primary goal of your code should be to write so that other people can read.
This isn’t to say that there is no use at all for abstraction. With no abstraction, our job as programmers would absolutely suck, and higher order functions allow some very nice things. It’s all a balancing act. There is no silver bullet, and leaning too far in one direction will lead to a fall.
Popularity: 10% [?]
