Cook Computing

.NET/C# Generics History

March 22, 2011 Written by Charles Cook

.NET/C# Generics History is an interesting post from Don Syme — designer and architect of F# — in which he describes how generics in .NET and C# in their current form almost didn't happen because features such as running CLR code in SQL server were given higher priority.

It's a good example of how you sometimes need to put it in a lot of work to get your ideas adopted:

It was only through the total dedication of Microsoft Research, Cambridge during 1998-2004, to doing a complete, high quality implementation in both the CLR (including NGEN, debugging, JIT, AppDomains, concurrent loading and many other aspects), and the C# compiler, that the project proceeded. Product group resourcing for the feature was low until 2004, and remained sparse, leading to major overload on MSR Cambridge employees, though ultimately the code, designs and specifications were fully transferred into both the CLR and C#. Today, the future of the CLR is firmly in the hands of those in Redmond.

Don speculates what would have happened if he and his team had not persuaded Microsoft to adopt generics:

What would the cost of inaction have been? What would the cost of failure have been? No generics in C# 2.0? No LINQ in C# 3.0? No TPL in C# 4.0? No Async in C# 5.0? No F#? Ultimately, an erasure model of generics would have been adopted, as for Java, since the CLR team would never have pursued a in-the-VM generics design without external help.

On the other hand if generics had not happened then perhaps .NET would have seen other interesting languages becoming popular, for example as Scala and Clojure are in the JVM world. Not saying that would have been any better, just different.