Justin du Coeur (jducoeur) wrote,
Justin du Coeur
jducoeur

Future of C#

One more for today. This is less crucial for all programmers, but probably interesting to anybody who is working in the .NET stack or might be doing so.

The last presentation consuming my time today is Anders Heilsberg describing The Future of C#, mainly C# 4.0. I wouldn't say that there is anything dramatic happening here, but they are continuing to add major new capabilities to the language.

The big enhancement this time around is dynamic typing. Basically, while they are still focused on strong static typing, they've acknowledged that dynamic languages matter, and that you often want to mix C# with dynamic languages like Python or Javascript or Ruby. So they've formalized the way these interact, behind a consistent interface, so that you can simply declare a variable "dynamic", and it gets typed dynamically at runtime instead of statically typed. Static and dynamic objects can be used together intuitively, with the runtime dealing with conversations as necessary.

I have to say, I'm amused by this one, simply because the world seems to be finally realizing that the static vs. dynamic religious war is stupid. I mean, I'm currently working in ActionScript 3, which is more or less the current version of Javascript. That comes to much the same conclusion from the other direction -- it's a dynamic language that has wound up going *mostly* static, but allows you to still use dynamics when it's appropriate.

So I think this enhancement to C#, making it clean and easy to use dynamic components within the overall static framework, is a fine acknowledgement of reality, and should make integration generally easier.

There are several other new features, less crucial but still useful. They've added the long-begged-for optional parameters for methods, as well as named parameters. COM interoperability has been considerably improved, making it significantly less painful to write .NET programs that work with traditional Microsoft tools. (He shows an example of working with Excel, and how it's a more natural programming experience now.) And they've added some fairly subtle new concepts to support co- and contra-variance in parameter types, which allow certain types of obvious generic programming that weren't previously possible.

In the last few minutes, he talks about where things are going in future releases, 5.0 and further. Suffice it to say, they're starting to take metaprogramming seriously, opening up the compiler, turning it into a proper API so that you can do code at runtime, hook and enhance the compiler, generate strongly-typed objects at runtime, and so on. While this is old hat in many languages, the idea of having a Read-Eval-Print loop is pretty radical in C# (he shows the fairly modest code to write a dynamic C# command line, as one expects in dynamic languages). I suspect that this is going to open up a bunch of use cases for C# that were not previously practical.
Tags: programming
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments