Strong Typing - Good or Bad?
October 10, 2006 · 4 Comments
Nando has a fascinating post (and some good dialog with Peter Bell in the comments) over at his Aria Media blog.
I'm still out on this (as a jury). I use weak typing quite a bit but it comes from an instinctive feel for whether I need the types or not, based on experience. Nando's post definitely makes me want to codify my feelings about weak typing. If I can article some of my rules of thumb, I'll blog them!
Tags: coldfusion

4 responses so far ↓
1 pan69 // Oct 10, 2006 at 10:00 PM
2 Campbell // Oct 11, 2006 at 1:10 AM
3 Peter Bell // Oct 11, 2006 at 2:06 AM
Nothing wrong with that as there are many things you can do quicker and more flexibly using dynamic typing (especially a lot of base classes which have indeterminate types), but Nando raises some good points that certainly agree with how I develop code. Hopefully some of the strong typers out there will post some comments here or there to remind Nando and the rest of us "weak typers" some of the issues we need to be aware of so we better understand what we're losing when we gain the flexibility of weak typing within ColdFusion compared to adding type information throughout to our CF code.
At the moment I'm with Nando in not seeing too much of a downside relative to the alternative in CF . . .
4 Ben Nadel // Oct 11, 2006 at 4:55 AM
I disagree with that. While I am not huge into the OOP (yet), weak typing has some great advantages. Just have a look at some of ColdFusion's build in functions, REFind() in particular. REFind() can return an INTEGER - the index of the first matching regular expession, or it can return a STRUCTURE containing the arrays of position and length of the first matching expression in its entirety. This is a really cool feature (although I prefer the Java pattern matcher) and I assume it can only be done with weak typing (returntype="any").
I assume you could do the same thing in Java by always returning something of type java.lang.Object???? But I don't have enough experience and if that is possible, it seems like weak typing to me.
Plus, weak typing has speed advantages. When you are NOT asking ColdFusion to make all kinds of type checking your code runs faster.
Leave a Comment