Tuesday, December 9, 2008

Type-safe Traffic

I imagine that someone looking down from a great height onto the tuk-tuks, motos, and Lexus SUVs buzzing around the streets of Phnom-Penh would be reminded of a bee-hive -- a seemingly random, crowded press of motion which in some incomprehensible way allows the participants to get where they wanted to go. I, being the computer nerd that I am, came up with a programming metaphor.

There are, roughly speaking, two types of programming languages: type-safe and non-type-safe. In a type-safe language, if you create a variable that's an integer, it stays an integer. If you try to stick a decimal number into an integer variable, the compiler will wave it's finger at you with a nasty tsk-tsk-tsk. It's constraining, but it forces you on a basic to be organized in your thinking.

Non-type-safe languages, on the other hand, don't pay attention to variable types. Any variable can carry any data. Programming in these languages is a liberating experience. You want to be an integer? You're an integer! Wanna be a string? No problem!

Phnom Penh traffic is totally lawless in the same kind of liberating way. Want to go the wrong way down that street? Great! Need to turn into oncoming traffic? Go ahead! In Phnom Penh, the shortest route to your destination is always the best route. And if you're in a tuk-tuk and late to a meeting, it's a happy experience.

Non-type-safe languages are more efficient to work in and you get faster results. The only problem is, if you don't impose your own discipline, the applications you write tend to crash a lot more often.

No comments: