My ‘ah-ha!’ moment for dynamic typing!

If there is anything that I’ve learned, it’s that there are some seriously smart, passionate, and motivated people at Microsoft. So, when I first started running into horrible code on the net using dynamic typing, I was confused. Why is Microsoft writing, and even promoting the idea of dynamic typing? I mean, we all know that in static programming languages, you should use static, strong-typing, so the compiler can enforce that for you, and so you get good intellisense. Yet, I kept seeing more and more Ruby fans coming to .NET, spreading the “loose-typing” dogma.

Earlier today Scott Gu was speaking on the LIDNUG webcast, and even he seems to be a fan of dynamic typing and the dynamic languages. So, that prompted me to see if I could find more (and better) information on the subject. Sure enough, I eventually ran across this video from PDC08, by the legendary Anders Hejlsberg:

The Future of C#

Keep in mind this was during 2008, and he was just then talking about what was coming in .NET 4.0, which is now out. This session covers dynamic languages, optional and named parameters, and parallelism. The first :40 minutes or so go into a good amount of detail about why there is dynamic typing, and also goes into some good detail.

To be clear, he doesn’t talk about the wisdom of dynamic languages who use dynamic types for everything – but instead he’s talking about C#’s ability to support dynamic types (types that aren’t checked at compile-time, and instead just “trust” things will be right at run-time.

In short, here’s what I took away from this:

  • Dynamic typing was added to C#, because .NET languages are ultimately becoming a melting pot of static typing, dynamic typing, and functional programming. So this is just a new feature to make C# more useful for the times when you need this sort of functionality. The ultimate goal would be that you could write your application using static techniques, but you could easily add dynamic or functional programming elements seamlessly, because the language would support that.
  • There are things you can do with .NET that I had no idea that you could do – like interact with Javascript, right from .NET code (and I’m not talking about RegisterScriptBlock() or Response.Write() either – and you can run and call Ruby or Python functions, from inside of .NET code. THIS is what dynamic typing was really meant for. It’s to make interacting with disparate technologies (programming languages) far easier to do. So, I gather that my instinct was right – people using “dynamic” and “var” all over the place, are really not using those identifiers appropriately, but I now understand what the appropriate places are, to use these things.

Anyhow, this shed a whole new light on this topic. The video is around 70: minutes or so, but is pretty good!!

Posted in .NET 4.0, Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Enter your email address to follow this blog and receive notifications of new posts by email.

Join 9 other followers

%d bloggers like this: