CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Darrell Norton's Blog [MVP]

Fill in description here...

It's not dynamic vs. static typing

Bruce Eckel states exactly my thoughts on static vs dynamic typing:

"I think the biggest problem when thinking about this [thought process] is that static-mind is very deterministic and unforgiving, and says "if I can't find out about it at compile time, all is lost." In reality, you can only find out about some problems at compile time, anyway. Dynamic languages shift the discovery of problems more towards runtime. If you can accept that there are plenty of problems that can only ever be detected at runtime anyway, it's possible to look at this issue with a little more perspective, and to calm down the stridency of the static-mind a bit."


Published Feb 11 2005, 12:47 PM by darrell
Filed under:

Comments

ben said:

I agree with Isaac Gouy's comment on Bruce's post, I think static typing is good because it moves more of the error checking into the compiler, rather than making you find it manually when you are testing. While its true that type-checking is done at runtime as well, it seems to me that you can benefit more from type-checking at compile, and I believe that those benefits outweigh the costs of static typing.

Bruce makes a good point that generics will help greatly reduce the number of runtime type errors, because it will check that your ArrayList<int> will only contain ints, whereas without generics, the ArrayList could potentially contain any type.
# February 12, 2005 10:38 AM

JosephCooney said:

I like static typing because I think it reduces bugs in my code, but at the same time I realize that sometimes in order to write "generic" code I have to write code that is dynamically typed, and handle type related run-time errors. Is it OK to like both?
# February 14, 2005 4:59 AM

Darrell said:

In response to both comments, yes it's ok to do both! I'd like to see as much static checking as possible using type inferencing, but without the static typing limitations.

Using Python I've gotten spoiled not having to jump through hoops to declare and cast variables to the "right type" in order to make the compiler happy, but which does nothing to actually implement the system.
# February 14, 2005 7:20 AM

ExPostFactor said:

With Static type checking the developer finds the problem while it is still in development. With Dynamic type checking it may be the customer who finds the problem later.
# February 15, 2005 2:08 PM

Darrell said:

If you have a dynamic typing problem that your customer finds instead of you, then you haven't tested your application enough. Static type checking is vastly more limited than actually exercising the program (which you get with dynamic type checking, at least if you test properly).
# February 16, 2005 5:59 AM
Check out Devlicio.us!