This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: Yet more typing confusion
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Joshua Marinacci confuses weak typing and dynamic typing. Smalltalk - for instance - is strongly, but dynamically typed. You can't get a type error of the sort you can see in a weakly typed language - like C++. In Smalltalk, if an object doesn't understand a message, you get a well understood exception. In C++, you can get an actual attempt to execute, followed by an ugly crash. Here's an example of his confusion:
I've seen lots of arguments on the merits of weak typing. It encourages flexiblity. It lets me write code faster. I don't worry about the details until later. I can do cool runtime tricks.
I don't buy it. I use a strongly typed language because the code it produces is more robust. Typing solves a slew of common programming errors all at once. It ensures that my code will always do exactly what I mean, no more and no less.
And yet... I can see the advantages of weak typing too. Java is a better prototyping language than C++ but it's no where near the speed of Perl for whipping up something quick.
Except.... C++ is weakly typed. With Casting, you get the worst of all possible worlds - the strictures of manifest typing, along with the runtime's utter inability to cope with a missent message. He continues to miss the point:
Why do we have strong typing anyway? I can only think of two things. First is performance. If you better specify what you want then the compiler can make faster code. The second is for people. The computer doesn't really care if this string really contains a number. It's all just bits in the end. The typing is for you, the programmer. To help you avoid mistakes. To express what you want the code to do to another programmer. It could be someone using your API, or someone modifying your code, or even yourself hacking on your own code in the future. Typing is a more detailed expression of what you want. But creating that expression can be time consuming and constraining.
Odd then, that Smalltalkers almost never run across the sort of typing error he touts as one of the two top reasons for having manifest typing, isn't it? 50% of his argument is crap, because that kind of error just doesn't happen that often. As to performance - the words premature optimization come to mind.