Apr 11 2009
I have no fond memories of that compiler
There’s another post about static typing (amongst other things) just been posted to Reddit.
(Tangent: I’ve just discovered that left- and right-mouse buttons pressed together emulates the awesomely useful middle-mouse button in Gnome, presumably Linux, presumably other Unix variants. Excellent.)
Static typing in programming is a bit like grammar checking in writing. Except better, because grammar checking is a much harder job. Anyway, it stops you making dumb mistakes, but plenty of people object to it because either (a) they don’t make mistakes or (b) they know better than the checker.
I don’t particularly understand the problem many people have with static typing, though I think the problem may be to do with how badly most languages do it. (You can imagine quite going off grammar checkers if you only knew Microsoft Word. But if you had a real live editor to point out your flaws you’d probably appreciate things more. Obviously the comparison is not legitimate but I think you see the gist — if something is done badly it can become more of a hindrance and is better removed altogether.) I have never done anything where static type checking has held me back, but I’m sure such things exist.
One interesting comment to come out of the above discussion regards teaching. Is it better to have a strict language for teaching purposes, or should the novice programmer discover why their malformed program is bad? Despite preferring static typing, I am actually erring towards no static typing for teaching purposes. I think falling off your bike a few times (metaphorically speaking, of course) will go some way to encourage more rigorous thinking, in the way that being told “no! you’re wrong!” before you try won’t. (Actually, I wonder if there is a language that exists which does static typing but will compile all the same. Then you can read any compilation errors and watch your program fail.)
I certainly remember hating the compiler when I was learning Java at university. Hating it. It never seemed obvious or reasonable that the problem was with my code; it was just a capricious bully, that compiler. Maybe if I’d been able to see the disastrous effects of running my ridiculous code I would have learned that the compiler did know what it was doing after all. :-)
The mouse-button thing works in Windows too ;)
Also, I much prefer statically-typed languages, even though they can occasionally be a pain in the ass. It really bugs me that php will happily accept something like
if (count(things > 1))
when you meant to type
if (count(things) > 1)
In my head, there’s no reason you’d ever want to use the first one!