The A-Z of Programming Languages: C#

Microsoft's Anders Hejlsberg reveals the history behind one of the most common programming languages, C#, and what the future holds for C#4.0.

1 2 3 Page 2
Page 2 of 3

What do you think of functional programming in general?

I think that functional programming is an incredibly interesting paradigm for us to look at, and certainly if you look at C# 3.0, functional programming has been a primary inspiration there, in all that we've done with LINQ and all of the primitive language features that it breaks down to. I think the time has finally come for functional programming to enter the mainstream. But, mainstream is different from taking over the world.

I definitely think that there is a space for functional programming today, and F# is unique in being the first industrial strength functional programming language with an industrial strength tooling language behind it, and an industrial strength platform underneath it. The thing that's really unique about F# compared to all of the other functional programming languages is that it really offers first class support for object oriented programming as well, and first class interoperability with the .NET framework. Anything we have in the .NET framework is as easy to use from F# as it is from C# as it is from VB—it does not feel forced.

A lot of functional programming languages have lived in their own little world, and they've been pure and mathematical and so forth, but you couldn't get to the big library that's out there. If you look at languages today, they live and die by whether they have good framework support, as the frameworks are so big and so huge and so rich that you just cannot afford to ignore them anymore. And that's why you're seeing so many languages being built on top of .NET or on top of Java as opposed to being built in their own little worlds.

How do you feel about C# becoming standardized and adopted by Microsoft?

If you're asking from a personal perspective, I think it's fantastic. I've been super fortunate to have Microsoft give me the opportunity to be the chief architect of a programming language and then have the company put its might behind it. That's not an opportunity you get every day, and it's been great.

With respect to standardization, I have always been a strong supporter of standardizing the language and I have always felt that you can't have your cake and eat it too when it comes to expecting a language to be proprietary and also wanting community investment in the language. Be proprietary, but then just don't expect people to build stuff on top of it. Or, you can open it up and people will feel more comfortable about investing.

Now, you can argue that we're not obviously open source or anything, but the language is standardized, and the entire specification is available for anyone to go replicate. Mono has done so, and I think Mono is a fantastic thing. I don't know [if] you're familiar with Mono, but it's an implementation of the C# standard and the CLI standard (which is effectively the .NET standard) on Linux, built as an open source project. And they're doing great work and we talk to them a lot and I think it's a super thing.

And I guess they couldn't have done that had you not put the specifications out there?

Well, they could have but it would have been a heck of a lot harder and it would probably not be as good a product. You can go reverse engineer it... they have reverse engineered a lot of the .NET platform... but all of the core semantics of the language, they were part of the standardization process.

You know most recently we've created Silverlight, which is our browser hosted .NET runtime environment, and the Mono guys have built a project called Moonlight which is an implementation of Silverlight that is officially sanctioned by Microsoft that runs on Linux and other browsers. It's a good thing.

So to focus more specifically on C#, why did you decide to introduce boxing & unboxing into the language?

I may have even touched on that a little bit earlier. What it boils down to is the fact that boxing allows you to unify the type system, and what I mean by unify is that when you are learning C# or approaching the language for the first time, you can make the simple statement that 'in this language, everything is an object.' Any piece of data you have you can treat as an object and assign it to a variable type object. The mechanism that makes that work is boxing and unboxing.

If you look at a similar language such as Java, it has a divided type system where everything is an object except ints and bools and characters etc which are not objects. So you have to sort of immediately dive in and describe the finer distinctions between these classes and types. Whereas when you have a unified type system you can just treat them as objects and then later, if you care, you can start diving into the deeper details about value types vs. reference types and what the mechanics are about and so forth.

We've seen this many times as people that teach the language have come back and said this is great as it allows us to have a very simple starting point. So from a pedagogical standpoint, it flows much better to first say that everything is an object and later we'll teach you about the different kinds of objects that the system has.

Did you intend to make it easy to teach, or was that simply a side effect of the way the language was designed?

I'd say we kept teachability in mind. It's not just teachability that is an advantage of a unified type system, but it also allows your programs to have fewer special cases etc. I would say the motivator here was more conceptual simplicity. But conceptual simplicity is generally a great thing when it comes to teachability so the two kind of go hand in hand.

How do you feel about C#3.0? Were you happy with the release? When is the next release due out?

Yes, I'm very happy with it, I think in some ways C# 3.0 was our first chance to truly do innovation and something brand new in the language. C# 1.0, if you think about it, was like 'let's go from zero to somewhere, so lets build all of the core things that a programming language has to have'. So, in a sense, 'let's build the 90% that is already known in the world out there'. C# 2.0 was about doing all of the things we wanted to do in C# 1.0 but we knew we weren't going to have time to do. So C# 3.0 was the first chance of a green field: ok, what big problem are we going to attack here?

The problem we chose to attack was the mismatch between databases and general purpose programming languages, and the lack of queries and more declarative styles of programming in general purpose programming languages. It was a fantastic voyage, and it was so much fun to work on. The result has been quite unique and quite good really. LINQ is something that is a new thing.

Do you expect C#3.0 to become an ECMA and ISO standard, as previous versions have?

We're certainly open to that. There's no ongoing work in the standards committee at the moment, but it's really more a question of whether the community of industry partners out there would like to continue with that process. I should also say that the standards for C# explicitly do permit implementers to have extensions to the language, so though C# 3.0 is not standardized, it is certainly a complete implementation of the C# 2.0 standard. It is 100% backwards compatible, as all versions are.

What functionality do you hope to add to C# in the future versions?

There are many. I have a huge laundry list, or our team does, of features that people have requested over the years. If I had to name the 3 big trends that are going on in the industry that we take an interest in and get inspiration from, I would say the first is a move towards more declarative styles of programming, and you can sort of see LINQ as an example of that. All the talk we have about domain specific languages, that's one form of declarative programming, and functional programming is another style of declarative programming. I think those are going to be quite important going forward and are certainly areas that we will invest in, in C#.

Dynamic programming is seeing a big resurgence these days, if you look at phenomena like Ruby and Ruby on Rails, these are all of a sudden very popular, and there are certain things you can do with dynamic programming languages that it would be great to also have in more classical languages like C#. So that's something we're also looking at.

Lastly, I would say that concurrency is the big thing that you can't ignore these days because the mechanics of Moore's law are such that it is no longer feasible to build more powerful processors. We can't make them faster anymore because we can't get rid of the heat, and so now all the acreage on the chips is being used to make more processors and all of a sudden it's almost impossible to get a machine that doesn't have multiple CPUs.

Right now you might have two cores but it's only a matter of years before you have 4 or 8 or more than that, even in a standard desktop machine. In order for us to take advantage of that, we need much better programming models for concurrency. That's a tough problem, it's a problem that doesn't just face us but the entire industry, and lots of people are thinking about it and we certainly are amongst those.

There's no shortage of problems to solve!

Speaking of problems, how do you respond to criticism of C#, such as that the .NET platform only allows the language to run on Windows, as well as licensing and performance concerns?

It is possible to build alternate implementations. We are not building .NET for Linux, because the value proposition that we can deliver to our customers is a complete unified and thoroughly tested package, from the OS framework to databases to Web servers etc. So .NET is part of a greater ecosystem, and all of these things work together. I think we are actually running on certain other platforms, such as Mono on Linux and other third party implementations. Silverlight now allows you to run .NET applications inside the browser and not just in our browser, but also in Safari on Macs for example.

As for performance concerns, I feel very comfortable about .NET performance compared to competitive platforms. I feel very good about it actually. There are performance issues here and there, as there is with anything, but I feel like we are always on a vigilant quest to make performance better and performance is pretty darn good. Performance is one of the key reasons that people choose .NET, certainly in the case studies I see and the customers I talk to (productivity being the other.)

What's the most unusual/interesting program you've ever seen written in C#?

Microsoft Research has this really cool application called Worldwide Telescope, which is written in C#. It's effectively a beautiful interface on a catalogue of astronomical images (or images from astronomy) which allow you to do infinite zooming in on a planet and to see more and more detail. If you happen to choose planet Earth you can literally zoom in from galactic scale to your house, which is cool. I've been playing around with it with my kids and looking at other planets and they think it's fun. It popularizes a thing that has traditionally been hard to get excited about.

Do you always use the Visual C# compiler, or do you ever use versions developed by the Mono or DotGNU projects?

I day to day use Visual Studio and Visual C# as that's the environment I live in. I occasionally check out the Mono project or some of the other projects, but that's more intellectual curiosity, rather than my day to day tool.

In your opinion, what lasting legacy has C# brought to Computer development?

We all stand on the shoulders of giants here and every language builds on what went before it so we owe a lot to C, C++, Java, Delphi, all of these other things that came before us...we now hope to deliver our own incremental value.

I would say I'm very happy that C# definitely brought a big productivity boost to developers on the Windows platform and we continue to see that.

I think that C# is becoming one of the first widely adopted multi paradigm programming languages out there. With C# you can do object oriented programming, you can do procedural programming, now you can also do functional programming with a bunch of the extensions we've added in C# 3.0. We're looking at C# 4.0 supporting dynamic programming and so we aim to harvest the best from all of these previously distinct language categories and deliver it all in a single language.

In terms of specific contributions, I think the work we've done in C# 3.0 on language integrated queries certainly seems to be inspiring lots of other languages out there. I'm very happy with that and I'm certainly hoping that in 10 years that there will be no languages where query isn't just an automatic feature: it will be a feature that you must have. So I think we've certainly advanced the state of the art there.

Has the popularity of the language surprised you at all?

It would have been presumptuous of me to say 'so today we're starting .NET and in 8 years we will own half of the world's development' or whatever. You can hope, but I have been pleasantly surprised.

Certainly we have labored hard to create a quality product, so it's nice to see that we're being rewarded with lots of usage. At the end of the day, that's what keeps us going, knowing hundreds of thousands, if not millions of programmers use the stuff you work on day and you make their life better (hopefully!)

What are you working on now?

I'm always working on the next release, so you can add one and deduce we're working on C#4.0!

1 2 3 Page 2
Page 2 of 3
7 secrets of successful remote IT teams