Just been to Anders Hejlsberg’s talk on the future of C#, where he outlined what’s coming in C# 4.0 and (some) of what might come in C# 5.0.
Importantly: C# 4.0 focuses on Dynamic Languages (i.e. the Dynamic Language Runtime (DLR)) and concurrent programming (i.e. programming for multi-core CPUs).
New in C# 4.0 is support for the attic type dynamic.
This allows you to specify a type which isn’t known until runtime.
Under the hood, it all seems to use the whole Type Invoke mechanism (i.e. reflection, which can be very slooooooow).
Which leads me to wonder: dynamics in C# 4.0 look like they’re cool in certain situations, but you end up with perf-problems, and the possibility for difficult-to-find runtime bugs.
For example, if I typed:
dynamic calc = GetCalculator();
int val = calc.App(2, 10);
int val = calc.Add(2, 10);
well.. I won’t know that there is a bug until I get to that line as it’s dynamically executed
At least, that’s my understanding.
It’ll be interesting to see how they address this.
In C# 5.0, Anders showed how they’re re-writing the C# compiler (csc) in managed code – and allowing you to interact with it from code.
Specifically, he showed how to dynamically generate, compile and execute code.. similar to what CodeDOM does today, but much much cooler.