Disconnected Mutterings of a Random Geek

Tue, 28 Nov 2006

Ranting about Types

I'm sitting here reading Joel on Software and he is talking about using Hungarian notation, where you encode infomation about the varible in the variable name. For example, an index is coded as starting with id. This code lets a developer check for mistakes visually, which he discusses here. His ASP compiler also uses this infomation. This is all well and good.

There are two things about this that bug me. The first is that having people check your code for errors of that sort seems daft. Why not write a program to do it for you? The second is that the varible names have to have this encoding and you have to write id before every index or rgwch before all your arrays of Unicode.

Lets imagine a world where you ran a program to check that the semantics of your varibles matched. Lets futhermore imagine a world where you didn't need to state in the varible name that the varible held a recordset and instead the system could work it out for you. It would easily fix the two problems people have with Hungarian notation, getting people to be good at it, and the wierd conventions.

Such a world exists. Its called haskell, and its been kicking around for ages. A haskell programmer would never have to read though his code looking for wrong bits, ghc would just poke him in the eye when it didn't type check. Haskell coders have this habit of saying that if the code type checks, then it works. Guys like Conor have taken this to its extremes, and let you specify all your program's behavoir in its types.

The thing that gets me about this that Joel, a very smart person, has reinvented the wheel, and got an octogon. He hasn't looked up any of the real CompSci behind what he is doing. And to paraphase the well-known saying: Those who do not understand CompSci are forced to rediscover it, poorly

posted at: 15:21 | path: /computing | permanent link to this entry

Made with PyBlosxom