Java/Ruby does not generalise to static/dynamic
So you were once a Java fanboy and now you’ve apostatised to the Ruby cult. Now you believe you hold veritable opinions about “statically typed languages” and “dynamically typed languages”. How wrong you are.
Java is not representative of static type systems, not even a bit. It lacks some of the most basic features of a static type system. It might even be said that its static type system imposes some of the most impractical insanity that could possibly be conceived. Why do I think this? Because I have pushed Java’s static type system to its limits and relative to its peers, it fails miserably. I’ve seen the language inside-out. I used to work on the JDK implementation for a certain corporation (of questionable ethical standards). I even have the spanky Sun Java Programmer/Developer certifications. Yes I have been drowned in Java Jolly Junkie bullshit and revived.
So you use Ruby eh? It allows you to express things that Java was too rigid to allow, right? That doesn’t mean a thing about static type systems, right? RIGHT?
When you use Java and Ruby as the example for static and dynamic type systems, I am reminded of my children who compare the flight of their scrunched up pieces of paper… er highly aerodynamic, radar-resistant aircraft (sorry boys). Hopefully some day they will learn what a wind tunnel is and what it takes to engineer a fighter-aircraft. Will you?
This kind of enthusiasm is to be encouraged — if you are 6 years old — but you are not, so you just look like you are in an adult’s body. No really, you do. This might be fine with you (who am I to judge?), but if it is not, it might help to know What to Know Before Debating Type Systems. Just a thought — there is plenty of other information available should you desire to seek it, just drop me a line.
Here are some tips to get started; static typing and explicit type annotating are two very different things. Don’t use the two notions interchangeably — not even loosely. Dynamically-typed languages do not produce shorter code, this is a myth. In fact, what constitutes shorter code is often misunderstood — certainly by Ruby (and Python, Groovy for that matter) advocates that I have encountered. I’m tempted to dispense with this myth with a challenge, but I’m not sure if I can be bothered (I have a life outside of whinging on my blog you know). It would also fail to do the topic justice. An entire discussion on what constitutes shorter code is in order.
For the love of GADTs, in the meantime, please stop talking nonsense about static and dynamic type systems. It only serves to hurt other potential learners by perpetuating misinformation. Myths spread by repetition — be honest and break the cycle.
October 16th, 2008 at 8:08 am
Hi, I’m Michael and I don’t know crap about type systems. (Well, I thought I knew a little, but each little bit more I learn I realize how little it really is.)
There. I said it. And feel better for having done so, too.
October 16th, 2008 at 8:54 am
Hi, I’m Pseudonym (not my real name, obviously) and I know more about type systems than any sane person should know.
Tony said:
I don’t know if you meant to word it that way, but while I agree that Ruby isn’t the first or last word on the matter, it’s a damn good example of a modern dynamic type system. Really, it is.
Mind you, I’ve never used Ruby, so what do I know. But from what I know of the type system, it definitely hits a “sweet spot” that other languages with dynamic type systems (e.g. Common Lisp) fall far short of.
FWIW, Java also hits a sweet spot: It’s almost perfectly suited for efficiently and securely running application code transported via a network on 1995-era hardware. So if you ever find yourself needing to do that, use Java.
October 16th, 2008 at 10:26 am
If I were selecting languages to compare type systems, I think I’d choose Zombie as the best example (IMHO) of a Dynamically typed system. Not only is it dynamically typed, but it’s inherently evil.
October 16th, 2008 at 11:35 am
The Chris Smith article was brilliant, thanks!
October 16th, 2008 at 5:28 pm
“what constitutes shorter code is often misunderstood ”
So I am confused. Is ruby code shorter than Java Code?
Is python code shorter than Java Code?
I really dont get the whole point as such. Java is simply a totally different language than ruby and python. Java is much more in the C/C++/C# camp - I think the comparisons are perfectly fine. In fact I believe ruby is one of the closest modern language that would feature a really true dynamic type system, more than any other prototype based TYPE system I found so far.
And Java is about as dynamic as a big stone…
October 16th, 2008 at 10:12 pm
[...] a comment » Tony Morris claims that Java and Ruby don’t generalize to static and dynamic typing systems. He’s right, but it doesn’t really matter. What [...]
October 17th, 2008 at 1:06 am
I couldn’t agree more with you on what constitutes shorter code. Especially when you start to include libraries…
October 17th, 2008 at 1:30 am
Mark,
I think what he means there is that dynamic type system doesn’t necessarily imply shorter code, the reason being that a static type system language can have type inference and there are other factors, apart from the type system, that can make code shorter or longer (like syntax sugar and functional idioms). This is beyond the point of whether “Ruby is shorter than Java or not”.
October 17th, 2008 at 1:56 am
[...] Wie schön er sich doch aufregen kann: link [...]
October 17th, 2008 at 2:29 am
> should you desire to seek it, just drop me a line
It could be nice if you dedicated a blog post to the resources which you are aware of like the C. Smith article. Thanks for the link.
October 21st, 2008 at 6:01 am
“static typing and explicit type annotating are two very different things”
This is a key statement, and I have been looking for a way to express this exact sentiment during my own discussions on static vs. dynamic. I hope you don’t mind if I steal it.
-m
October 22nd, 2008 at 11:34 am
An excellent and interesting reference. I found this point interesting after some of your diatribes (well, that’s excessive) of scala’s misbehaviors:
> Furthermore, there is an ironclad mathematical proof that a
> type checker of any interest at all is always conservative.
> Building a type checker that doesn’t reject any correct
> programs isn’t just difficult; it’s impossible.
October 22nd, 2008 at 2:12 pm
Hi Marvin,
Yes this is a well established fact (known as the Turing Halting Problem). It is also mentioned in “What to Know Before Debating Type Systems” if I remember rightly.