C# 4.0 goes dynamic

Anders Hejlsberg is explaining new features in C# 4.0, a future version, at Microsoft’s PDC. The big new feature, he says, is support for dynamic typing. Currently C# uses static typing, which means that when you call object members like methods and properties, the compiler checks that they exist or raises an error if they do not. By contrast, with dynamic typing you can call any old method or property, and they are not checked until runtime.

C# 4.0 will support dynamic typing through a new static type called “dynamic” (this raised a laugh at PDC). In other words, if you declare a variable as dynamic:

dynamic obj;

then you can call what you like as if it were a member of obj, and it will be resolved at runtime.

Hejsberg showed in his demonstration how this simplifies interop with other dynamic languages like JavaScript or Python.

Other new features are named parameters and optional parameters. This is a big win for COM interop – automating Microsoft Office, for example, from C# has always been painful because COM was designed to support optional parameters. C# got round this with an ugly hack “ref.missing”. All gone in C# 4.0.

Technorati tags: , ,
VN:F [1.9.3_1094]
Rate this post
Rating: 0.0/10 (0 votes cast)

Related posts:

  1. Native code interop in Adobe AIR vs Microsoft Silverlight
  2. Dynamic language slowdown at Microsoft?
  3. Silverlight 4 with COM can do anything – on Windows
  4. Speeding page load with dynamic JavaScript
  5. Hyper-V disk I/O: performance of dynamic vs fixed virtual hard disks

3 comments to C# 4.0 goes dynamic

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>