Irregular Injection of Opinion
RSS 2.0|Atom 1.0|CDF

 Monday, 27 October 2008
Anders and the Future of C#

This is a REALLY long post. Was a great session and will be worth watching the video when it’s available.

December marks the 10th anniversary of the inception of C#.

Today looking at C# 4.0 and a little bit @ C# 5.0

3 Key Trends Shaping the Industry

  1. Declarative 
  2. Dynamic
  3. Concurrent

The Uber trend is language paradigms borrowing from each other.
E.g. C# 3.0 borrowed a lot from functional langauges


Declarative Programming
The whole What vs How

Impertivie is VERy explicit which means that it is much harder to optimize.
Contrast this with the more declarative model like LINQ- easier to optimize. Easier to parallelize.

Dynamic vs Static
Lots of religious debates about each.
Both have good qualities. Want attributes of both.
Going to see lots of languages borrowing from each other

The elephant in the room!
Hard to do. Moores law has allowed us to stick our head in the sand for decades.
Moores law, in terms of clock speed, has stopped. We are still getting higher transistor densities, instead we get more CPUs. The onus now falls on us as to what to do with them.
No Silver bullet… no /parallel switch on the compiler :-)

Current models of concurrency typically focus on coarse grained concurrency- multiple logical things on fewer CPUs than you have things to do. We are not getting to the flip side- taking single logical things and running them, splitting them, onto multiple CPUs. Language designers need to find ways for users to be able to do this.

There are interim solutions such as the ParralellFor statement that takes upper and lower bound and a lambda in the Parallel Toolkit for .NET

C# vs VB
Blah blah.. usual tree huggy waffle.
Says co-evolution will continue to be the model.
Goal remains to be to maintain feature parity… The goal is such that if one language has a feature it should not be impossible to do something similar in the other language.
E.g. Given is XML Literals in VB vs LINQ to XML in C#


C# 4, Key theme Dynamic Programming
In the broadest sense of the word. i.e. talking to anything that is not a statically typed .NET class.

Key featres

  1. Dynamically types objects
  2. Optional and names parameters
  3. Co-Contra variance
  4. Better COM interop


Dynamically typed objects
Talking a it about IronPython and the DLR.
DLR designed to unify Dynamic languages in the same way CLR does for static languages

In 4.0 C# and VB will support the DLR explicitly.

Under the DLR there are binders for other things.
E.g. Binders for .NET, Javascript, Python, Ruby, COM

Calculator calc = GetCalculator();
int sum = cal.Add(10,5);


object calc = GetCalculator();
Type calcTye = GetType(calc);
//Reflection blah blah

Javascript would be similar… but different.

C# 4 introduces a new static type… of dynamic

dynamic calc=GetCalculator();
int sum = calc.Add(20,10);

In above, .Add returns dynamic result. = sign performs a dynamic conversion.

This all comes down to should it be painful to talk to dynamic ‘stuff’ outside of C#?
Or should it be easy?

When operands are dynamic we defer member selection to run time- e.g. can do dynamic overloads


Anders then did a demo sowing a cool interop with Javascript from Silverlight. Interopping out of Silverlight into Virtual Earth *.js files. He also showed a quick cut and paste of *.js into *.cs file and the small changes required.

2nd demo showed C# calling out to Python. Showed a calculator example and the ability to basically pass ANYTHING into the calc.Add method. Remembering that Python being dynamic can work on any variable type that has an operator ‘+’ defined for it.

Back to Slides
All the above is based around the idea of IDynamicObject.
Out of the box support for COM and .NET. Dynamic languages can implement the IDynamicObject interface themselves too or indeed you can implement it yourself in your own .NET code. E.g. you want to implement your own property bag with dynamic properties.

dynamic propBag = new MyPropBag();
propBag.whatever = 12345;
dynamic x = propBag.whatever;

So DLR can dispatch to a statically typed object to… e.g could pas in an anonymous type to a dynamic method.

Optional and named parameters
The usual pattern in .NET is to =declare a primary overload that has all parameters.
Then declare a BUNCH of overloads that call with default.

Can now just define defaults on optional parameters.

Supported in .NET since the beginning and of course supported in VB. Anders says ‘he relented’.

Can now also pass in names arguments (after positional arguments). No compiler overhead.
Can do funky things such as putting named arguments out of order…. which in urn can be a bit intersting if you hav side effects.

COM Interop
Anders mea culpa.
Basically trying to combat the HUGe issue with Office still being COM. and as such interop being poor.
No more file.SaveAs(fileName, ref missing, ref missing…….) crap.

Key new features
Option and named parameters and dynamic types lets us write code as it’s meant to look.
Can now omit ref in many cases
Indexed properties
Supports an automatic mapping of type object to type dynamic when you import COM objects.
Compiler able to embed interoperability types- no need for PIA any more.


Did a demo showing all the fun ‘oddities’ of COM interop.. i.e. some fugly code and how it now becomes nice looking code.

Co- and Contra-Variance

This is a bit geeky for me :-( Me non Grok it.
Something to do with the ability to pass less derived array types.
Says co-variant arrays in .NET are not safe.

Supports safe co and contra variance.

Ability to safely support less derived objects as more derived when using read only interfaces.

C# 5.0 Initial Thoughts
Talking a it about meta-programming.

Lots of use of code gen. Reflection.emit.
Need a modern approach to meta programming.

E.g. what is driving the success of Ruby on Rails is that it’s a good meta programming language.

A focus for beyond 4.0 is to actually write the C# compiler in managed code.

Initially compiler written in C++. It’s a classical compiler.

Want to provide ability to allow people to hook into the compiler. Will end up with a true object model for C# source code. Compiler will no longer just be a black box.


So with compiler in managed code we can now call it as an API. Pass in a string, return some cobiled binaries, walk these with reflection.

Anders wrote a simple C# evaluator.

First Evals a simple for loop.
Next Evals to create a delegate, Evals a refernece to that delegate then statically calls through the delegate from the main block of code. You kinda gotta watch the video :-)
Well worth scolling to this bit of the video to bend your brain!

he uses dynamically evaluation to new up a windows form and then adds buttons and event handlers and things… Incrementally bui8lding the application… this is gonna be such cool tech to work with…. Like just VERY cool.

We *may* get this out of band. i.e. before .NET 5.0



Anders on stage.


An Anders session is always a popular session. No one wants to be presenting against Anders (same time slot). Like my cheap arse panorama :-)

Goodies Gone Burger

PDC08|Monday, 27 October 2008 22:36:36 UTC|Comments [0]|    

SQL Services

So, SQL Server Data Services has morphed into SQL Services. You may well have seen me present on SSDS at user groups or TechEd.

SQL Services will eventually offer a really broad platform but at the moment it’s just the SSDS bits warmed up by the looks.

Forthcoming will be:

  • ADO.NET Data Services (Astoria) endpoint being announced.
  • Database – Still the flexible ACE model. Expanded capabilities, queries, joins other operators
  • Datasync
  • Reporting (Later)
  • Data mining (Later)
  • ETL (Later)


Bob Muglia who is a pretty good presenter.


Some guy from Red Prairie who did a less than compelling demo.

System Center “Atlanta
”Bob showed off a cool new Silverlight based System Center control panel.
It basically allows agents on Ops Manager servers to feed messages back through the Service Bus.
It’s then stored in SSDS.


PDC08|Monday, 27 October 2008 16:47:02 UTC|Comments [0]|    

PDC Questions….
  1. How many people are going to get laid through Bluehoo @ PDC08?
  2. Did Microsoft really choose a brand name, Azure, that nobody knows how to pronounce?
PDC08|Monday, 27 October 2008 16:21:47 UTC|Comments [0]|    

Windows Azure

So Ray Ozzie has just announced Windows Azure. Build an ASP.NET Application, WCF Service, Windows Service and host it in the cloud.


This is Microsoft’s new Cloud Services platform and basically wraps up things like:

Sql Data Services
Microsoft .NET Services (Formerly Biztalk Services)
Live Services (Mesh etc…)
SharePoint Services (As web services more than as UI)
Dynamics CRM Services (As web services more than as UI)

Key Strata Themes
A flexible services platform at Internet Scale.
Simple scenarios are simple – Complex scenarios are possible
Hosted in MSFT data centers
Designed for high availability and scalability

Based on Internet Standards
This week releasing .NET/Java/Ruby SDKs. More to follow.

Extends Existing Investments
Familiar tooling and standards
Provides choice of on-premise, in cloud or hybrid.
Integrate with existing assets such as AD and on premise applications

Windows Azure Manages the Entire Global Data Center Infrastructure
Primarily containerised data centers.
Spending several hundred million dollars per data center.
Adding thousands of servers per month.

Fabric Controller
Maintains the heart of the service- Fabric controller applies the necessary changes through the cloud.
Manages services and not just the server. No need to think about virtual machines etc… Full abstraction applied.
Developers just think in terms of the same service and interface models we’ve used in the past.
Very different to the whole EC2 model. You are not dealing with physical machines, rather an abstract resource- it’s an Operating System more like a mainframe than like a typical x86 server.

Cloud Simulator
There is a desktop based cloud simulator.

For those of you who remember my Red Shoe Days!


The Azure Team look to be wearing Red Shoes for the event… I’m guessing a nod to the code name for this technology – Red Dog.

PDC08|Monday, 27 October 2008 16:14:57 UTC|Comments [3]|    

A few early photos of the PDC08 Keynote

So JB, OJ and I are sitting in the keynote getting ready for it to start.

Had a good pre-briefing yesterday from the Cloud Services folks… interesting to see what they actually call their new platform…

Will stick some toughts up here as we progress, in the meantime look at how big this room is!


And how small OJ is in comparison… Sorry OJ… like the Yellow!


PDC08|Monday, 27 October 2008 15:57:09 UTC|Comments [0]|    

The Maggots from

Like flies to a carcass, SalesForce decided that the first morning of PDC would be a great time to have their promo girls* and promo guys giving out T-Shirts and flyers on South Figueroa Street. Kind reminds me of these folks really.


*Not as hot as usual promo girls…

PDC08|Monday, 27 October 2008 15:30:15 UTC|Comments [0]|