Saturday, August 29, 2009

Strong vs Weak Typing

Apple says it best:

"If you are used to using strongly typed languages, you might think that the use of weakly typed variables would cause problems, but they actually provide tremendous flexibility and allow for much greater dynamism..."

I've always felt the same way. Its a different mindset but I wish it was more prevalent.


Xiong Chiamiov said...

I don't see what's so wrong with me making a call to str() if I want to be comparing a string, rather than letting the interpreter convert types at will. It leads to all sorts of bugs (I've seen some nice examples in PHP of comparing "true", "false", true and false).

Darren DeRidder said...

Hi Xiong,

There is nothing wrong with strong typing per se. It's designed to protect programmers from certain basic mistakes. In practice, these kinds of mistakes are easy to find and fix, though. Also, test-driven development is really a better way to do functional validation than compile-time errors. To see the benefits of dynamic typing, you need to use it a few times in a language like Lisp, Objective C or Javascript.

Happy coding!