Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How did generics influence the design of C# and .NET?

Tags:

c#

.net

generics

This might be a broad question but this is something I am not really clear and very curious.

Often times for certain problems I hear the reasoning that it was because Generics was not available in .NET 1.0. That makes me think either of these 2 things:

  1. Generics was not thought of before, so the developers came up with it after .NET 1.0 which could drastically affect design of C# and .NET but couldn't because of decisions already made (backwards compatibility).

  2. Generics was always planned since the beginning, so the only problem that arise from not releasing it with .NET 1.0 was not being able to use it till 2.0. But other than this, no redundant features were introduced or wrong, irreversible decisions were committed.

I mostly assume #1, but is #2 is the actual case?

like image 585
Joan Venge Avatar asked Feb 23 '11 22:02

Joan Venge


2 Answers

Generics have been around a long time and can be loosely compared to C++ templates, although the concept (and probably implementation in other languages) predates even that.

.Net 1.0 is the first cut of a platform so the plan was to ship something that works reasonably. Generics would have to have been on the "planned future" if any decent architect was on the team, but is something that could be added later. In fact, the paper on implementing generics for .NET came out a year before .Net Framework 1.0 RTM eventuated.

Timeline: (http://en.wikipedia.org/wiki/List_of_.NET_Framework_versions)

2002-03-05 .Net Framework version: 1.0.3705.0 released
~May, 2001 Don Syme's paper on "Design and implementation of generics for .NET"

Microsoft could have taken 10 years to build .Net Framework 4.0 (as version 1.0), but with so much code and so many features out at once, it would take 5 years to find all the bugs and usability issues if the project can even succeed.

So the answer to your question would be #2.

Don Syme primarily designed and implementated generics into C# and .Net.

Resources

  • Language features added to C# over time (C# is the showcase language for .Net features)
  • Design and implementation of generics for the .NET Common language runtime
  • Formalization of generics for the .NET common language runtime
  • Anders Hejlsberg, lead architect of C#
  • Anders Hejlsberg talks a bit about generics

Anders Hejlsberg is my hero - from Wikipedia - original author of Turbo Pascal, the chief architect of Delphi, later lead architect of C#

like image 83
RichardTheKiwi Avatar answered Sep 19 '22 12:09

RichardTheKiwi


I'm almost sure that generics were envisioned from the start. Full well realizing that the job was going to be considerable. The project was headed by Don Syme (of F# fame), his first publication about the design was dated January 2001. The CLR is presented as a given, the paper documents additions to the MSIL, although at the time .NET 1.0 had not shipped yet. That took another year. All and all, it's probably fair to conclude that it took them close to 4 years to hammer this together into concrete shipping software.

like image 34
Hans Passant Avatar answered Sep 20 '22 12:09

Hans Passant