An Architect's View

CFML, Clojure, Software Design, Frameworks and more...

An Architect's View

Strong Typing - Good or Bad?

October 10, 2006 ·

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

  • 1 pan69 // Oct 10, 2006 at 10:00 PM

    Havn't read the Aria Media blog, but there is no question about this ofcouse, strong typing is always the favour over weak typing. Basicly, when you design a weakly typed language your shifting the problem from compile time to runtime. Yes, your language might be more approchable by non-programmers (or the not so good programmers among us) but does that realy solve the problem? When you get suck you get suck. I'm rather stuck at compile time then runtime, any day.
  • 2 Campbell // Oct 11, 2006 at 1:10 AM

    Yeah I find compile time errors much easier on the grey matter than run time errors. Besides when your looking at a fish its nice to know your looking at a fish, that and intellisense style drop downs make me love strong typing ! :o)
  • 3 Peter Bell // Oct 11, 2006 at 2:06 AM

    @Pan69 - Well, if you want to handle things at compile time, you're going to need to bid farewell to ColdFusion. Strong Typing in CF documents improves the documentation value of the code and moves the runtime errors round a little bit, but the lack of static typing and a compiler means you don't get the full benefits of strong typing.

    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.