Static versus Dynamic Languages - Attack of the Clones

Very recently there has been an ongoing debate between static and dynamically typed languages.  Since it seems that there has been some Star Wars references, I thought I'd add my own.  I originally wanted to cover this as part of the future of C#, but I think it deserves its own topic.  There have been many voices in the matter and I've read all sides and thought I'd weigh in on the matter.  I find myself with my feet right now in the statically typed community right now.  I do appreciate dynamic typing and it definitely has its use, but to me the static verification is a key aspect.  But, of course I do appreciate dynamic languages, especially those of the past including Lisp, Erlang, etc.

Here are some of the salvos that have been fired so far:

The Salvos Fired

First, Steve Yegge posted a transcript from his talk at Stanford called "Dynamic Languages Strike Back".  In this talk, he talks about the history of dynamic languages, the performance, what can be done, and the politics of it all.  But at the end of the day, it comes down to the tools used.  It was a pretty interesting talk, but of course dredge up some pretty strong feelings.  In turn, you had responses from Cedric Beust coming out in favor of statically typed languages, and Ted Neward, Ola Bini and Greg Young analyzing the results of the two of them.  I won't get into the me too aspect of it all, but I encourage you to read the posts, but also the responses as well.

I think Cedric lost me on the argument though is when he brought Scala into the argument.  To me, it was kind of nonsensical to mention it in this case.  And to mention that pattern matching is a leaky abstraction is unfortunate and I think very wrong.  The thing that functional languages give us is the ability to express what we want, and not necessarily how to get it.  Whether it puts it in a switch statement, an if statement, or anything else doesn't matter, as long as the decision tree was followed.  I don't see any leakiness here.  So, that was a bad aside on there.  I'm not a huge fan of Scala either, but for entirely different reasons.  First off, the type inference isn't really as strong as it should be and the syntax to me just doesn't seem to be as functional as I'd like.  F# and Scala tackle the problems in vastly different ways.

Ola Bini, who has been advocating the polyglot programmer for some time, summed up the Steve versus Cedric posts very concisely in these two paragraphs:

So let's see. Distilled, Steve thinks that static languages have reached the ceiling for what's possible to do, and that dynamic languages offer more flexibility and power without actually sacrificing performance and maintainability. He backs this up with several research papers that point to very interesting runtime performance improvement techniques that really can help dynamic languages perform exceptionally well.

On the other hand Cedric believes that Scala is bad because of implicits and pattern matching, that it's common sense to not allow people to use the languages they like, that tools for dynamic languages will never be as good as the ones for static ones, that Java generics isn't really a problem, that dynamic language performance will improve but that this doesn't matter, that static languages really hasn't failed at all and that Java is still the best language of choice, and will continue to be for a long time.

It seems that many of the modern dynamic languages are pretty flexible, but also not as performance oriented as the ones in the past.  Why is this?  It's a good question to ask.  And what can be done about it?  Of course Ola takes the tact, and I think correctly so that the tooling won't be the same or as rich for dynamic languages as it is for statically typed.  It simply can't be.  But that doesn't mean that it needs those tools won't exist, they'll just be different.  But at the end, Ola argues for the polyglot programmer and each language to its strength.  He talks a bit more about this with Mike Moore on the Rubiverse podcast here.

Impedance Mismatch?

There was a topic discussed at the ALT.NET Open Spaces, Seattle fishbowl on the polyglot programmer which talked about the impedance mismatch between statically typed languages and dynamic ones.  What's great is that Greg Young got together a session with Rustan Leino and Mike Barnett from Microsoft Research on the Spec# team, John Lam from the IronRuby team, and me.  It was a great discussion which revolved around the flexibility that dynamic languages give you versus the static verification that you lack when you do that.  And there is a balance to be had.  When you look at that flexibility that Ruby and other dynamic languages give you, also creates a bit more responsibility for ensuring its correctness.  It's a great conversation and well worth the time invested.  But one of the benefits we're seeing from CLR and in turn the DLR is the interop story so that you could have your front end be Ruby, service layer in C#, rules engine in F#, Boo for configuration and so on.

Anders Hejlsberg on C# And Statically Typed Languages

As I noted earlier, Anders Hejlsberg was on Software Engineering Radio Episode 97 to discuss the future of C#.  Although Anders has his foot firmly in the statically typed camp, he sees the value of dynamic dispatch.  The phrase that was used and quite apt was "Static Programming but Dynamically Generated".  I think the metaprogramming story in C# needs to be improved for this to happen.  Doing Reflection.Emit isn't the strongest story for doing this, and certainly not easy.

Where I think that C# can go however is more towards making DSL creation much easier.  Boo, F# and others on the .NET platform are statically typed, yet go well beyond what C# can do in this arena.  Ayende has been doing a lot with Boo and making the language, although statically typed, very flexible and readable.  Ruby has a pretty strong story here and C# and other languages have some lessons it can learn.

Another example is that Erlang is a dynamic language, yet very concurrent and pretty interesting.  C# and other .NET languages can learn a bit from Erlang.  I'm not sure Erlang itself will be taking off, as it would need some sort of sponsorship and some better frameworks before it could.  F# has learned some of those lessons in terms of messaging patterns, but no in terms of recovery and process isolation just yet.  I covered a bit of that on my previous post.

Wrapping It Up

It's a pretty interesting debate, and at the end of the day, it really comes down to what language meets your needs.  The .NET CLR has a pretty strong story of allowing other languages to interoperate that nicely compliments the polyglot.  But, I don't think that static typing is going the way of the dodo and I also don't think dynamic typing will win the day.  Both have their places.  Sounds like a copout, I know, but deal with it.  I have a bit more to discuss on this matter, especially about learning lessons from Erlang, one of the more interesting languages that has seen a resurgence lately.


kick it on DotNetKicks.com

No Comments