Welcome!

Eclipse Authors: Paul Miller, RealWire News Distribution, Adrian Bridgwater, Hovhannes Avoyan

Related Topics: .NET

.NET: Article

The Father of C# Improves His Brainchild

The Father of C# Improves His Brainchild

(Microsoft Chief Architect and Distinguished Engineer Anders Hejlsberg, inventor of the C# programming language, which underpins .NET, granted an exclusive interview to .NET Developer's Journal for its premier issue, coming in January 2003. As a preview, Derek Ferguson covers highlights from Hejlsberg's OOPSLA presentation.)

(November 20, 2002) - Anders Hejlsberg delivered a speech to the attendees of the recent OOPSLA conference in Seattle in which he described four new features to be incorporated into the C# programming language. These were: generics, Iierators, anonymous methods, and partial types.

Generics is a technology developed largely by Don Syme and Andrew Kennedy of Microsoft Research. Similar to C++ Templates, generics are much more powerful. For example, in C#, developers will be able to restrict the types of the "wildcards" used to concretize their generics, which is impossible when using Templates under C++.

Iterators are being added to solve a usability problem with the C# language as it currently stands. Specifically, in order to use the foreach keyword under C# now, developers have to make their objects implement the IEnumerable interface. Unfortunately, this is a rather cumbersome interface to implement. Going forward, developers will be able to implement an iterator that will allow the use of the foreach keyword simply by adding a method with the following signature to their class:

public Object foreach()

The third language alteration - which nearly produced a standing ovation from the assembled crowd - was the addition of so-called "anonymous methods." This is a step in the direction of Java's "anonymous classes," which allow entire bits of functionality to be defined at their point of use without even being given a name for later reference. Hejlsberg indicated later (during an exclusive .NETDJ interview) that he feels that this kind of behavior might not always lead to the most truly object-oriented of designs.

Finally, partial types will be introduced to change the existing one-to-many relationship between C# source files and classes into a many-to-many relationship. What is the practical value of this, you might ask? It allows a single class to be defined in multiple files that may then be created and managed via different entities.

For example, an automated code generation tool might be responsible for creating the parts of a class dealing with the user interface, while the human-generated code for this class is all kept safely in another file. In this way, classes can be safely "round-tripped" between generators and human beings with far less danger of accidental code overwrite.

For more information on C#, see www.csharp.net.

More Stories By Derek Ferguson

Derek Ferguson, founding editor and editor-in-chief of .Net Developer's Journal, is a noted technology expert and former Microsoft MVP.

Comments (4) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
David Bennett 01/02/03 10:59:00 PM EST

Horray! These upgrades to C# are great.

Java sucks compared to .NET and in the end everyone knows Microsoft is the champ. The last time I tried developing a Java application my notepad text editor crashed. Microsoft tools are 'just slightly' easier to use.

- David Bennett

Miguel Katrib 11/21/02 06:55:00 PM EST

Hurra! for the generics and iterators inclusions in C#

We propose similar features for Eiffel language see

Collections and Iterators in Eiffel, Journal of Object Oriented Programming, Vol 6, No 7, Nov/Dec 1993, USA.
by Miguel Katrib and Ismael Mart

Brendan Johnston 11/21/02 12:25:00 PM EST

The only "non-oo" feature is anonymous functions. The Inventor of the term Object Oriented, Alan Kay, included anonymous code blocks in the OO language he developed, Smalltalk.

Generics and partial types allow you to create a class. Classes are an OO feature.

Iterators seem to fix an inconvenience in the design of containers.

Brendan

M. Whitener 11/20/02 05:19:00 PM EST

For too long, OO has been held up as an absolute good. This attitude might have been understandable in the late 1980s, but the popularity of Java has extended OO's time in the limelight. These new features of C#, while very useful, have nothing to do with OO, and in fact mostly cannot be achieved using straight OO! Many newcomers to computer science and engineering (Java zealots) will point this out in a negative light. But the fact is that OO is only one useful view of reality. Congratulations to Hejlsberg and MS for recognizing this.