Permalink

André Pang comments on "Modern Static Typing: Less Code, Better Code"

12 JUL 2004

André Pang has made some comments on my article Modern Static Typing: Less Code, Better Code, which was a rebuttal of Bruce Eckel's Strong Typing vs. Strong Testing.

André's comments are very welcome, and make good reading. Of course I have some comments on the comments as well!

While it's possible to have such name clashes with different semantics, in reality I don't think it's a big problem: certainly one not worth spending a few paragraphs on in an article
I agree it probably doesn't happen all that often. On the other hand, isn't it better to be sure the right method always gets called, especially if the cost is low?
It is very cool to program in a language which enables you to separate the code you write, from declaring how that code is used as part of your whole system design.
Yes, very cool indeed! I recently noticed an example by Isaac Gouy on the Nice wiki which shows this off nicely. It shows how Nice can easily handle things that Aspect Oriented languages do (at least in some cases) by rewriting an example from the article AOP banishes the tight-coupling blues in Nice.
Haskell, which enables you to declare a type class to capture common functionality provided by different functions... This is the same idea as Nice's separation of code declaration vs interface declaration, though type classes are a far more powerful and generic concept.
I agree the features are very similar, but I'm not sure type classes are any more powerful and generic. I'll have to look into that in more detail before replying in full.
Objective-C's categories, which enable you to add new methods to existing classes. You don't like it how the NSFileHandle class doesn't have a method to create a new temporary file and return you a file descriptor for it? No problem, just add your own method to do that to the class no subclassing necessary. Categories are possibly the greatest thing I miss about Objective-C when I use any other language (Haskell included: it would be really cool to be able to extend type classes by adding new methods to them!).
This is a feature of most multi-method languages, Nice included. You can add any method to any class or interface at any time, even builtin classes like String. This is different from Haskell (or Java or C++, etc.). The key to understanding this is to stop thinking that classes contain methods. In Nice, methods are free-standing objects in their own right. Interfaces are essentially just names, and each class is essentially just a name plus a structure. Create a new method which takes a certain interface as one of its parameters, omit the implementation, and you've just created a new constraint on the interface - anything that implements that interface must also be accompanied by an implementation of the new method. Or you can provide a default implementation (just like in Haskell type classes) and let people extend it as necessary. This is sufficiently different from the usual way of looking at things that I'm thinking of writing an article on the subject to explain it in more detail, with examples.
He remarks right at the end of his article that "We need both strong testing and strong typing" - I think he means static typing, not strong typing, considering that was what his entire article was about
Yes indeed! I was of course talking about static typing, I just phrased it that way to underscore the false dichotomy in the title of Bruce's article. Factual accuracy would probably have been a better choice. :-)