Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


C#: Why Do We Need Another Language?

New computer languages are rare and successful ones are rarer still, yet Microsoft decided to create a new language to go along with the .NET Developer Platform. Why weren't existing languages good enough?




Full Text Search: The Key to Better Natural Language Queries for NoSQL in Node.js

Date: 1/31/2018 @ 2 p.m. ET

ver the years the topic of a simpler language entered the discussions of the Microsoft Visual C++ development team. While C++ gives programmers a tremendous amount of power and control, this power often comes at a price. C++ is more complex than languages such as Visual Basic and Java. It may take several more lines of C++ code to perform an operation requiring a single line of code in languages like Visual Basic or Java. These discussions resulted in the search for a way to marry the productivity of Visual Basic with the syntax and power of C++.

After the release of Visual Studio 6.0, a number of factors led the Microsoft Developer Division to a big decision. A decision was made to build a multi-language Common Language Runtime. It was obvious that Visual Basic would be an important language targeting this runtime. It was less clear what to do with C++.

Fast Facts
In February, Microsoft shipped Visual Studio .NET, the Common Language Runtime and launched the C# language. This article explores the reasons C# was created and some of its unique features.

One of the options was to modify C++ to work with the new runtime. When we discussed the idea of a simpler C++ with some customers, they provided some interesting feedback. They were intrigued with the idea of a simpler and more productive language, but they didn't want us to mess with C++. Therefore, we decided to create two languages in the C family. The Managed Extensions to C++ would be a minimal change to the C++ language to support the Common Language Runtime while C# would be a clean-slate language targeted at programmers who know C++ but want a cleaner, more productive language.

A Tool that We Can Use
The vast majority of Microsoft software is written using C or C++, and when we were designing C# we knew that we had to create a language that would be attractive to those programmers.

Attractive is a hard concept to nail down, but two important facets of attractiveness are comfort and capability.

Comfort is all about familiarity. Because C# has a syntax that is similar to C++, it's easy for C++ programmers to read and understand C# code. C# also has a similar conceptual model and there are C++ analogs to many C# design principles. Here's a simple C# program:

public class Example { public static void Main(string[] args) { foreach (string s in args) { System.Console.WriteLine(s); } } }

This code is easily understood by any C++ programmer.

Capability is highly valued by C++ programmers and it's commonly stated that the language gives you enough rope to hang yourself. Java, on the other hand, is a more minimal language, which omits some features that might get programmers into trouble.

We didn't want to omit features that would be useful for professional programmers merely because they could be used incorrectly.
Philosophically, C# is somewhere between C++ and Java. The mere fact that C# runs on a managed runtime means that it can't have as much flexibility and control as C++. We didn't want to omit features that would be useful for professional programmers merely because they could be used incorrectly. Features such as user-defined value types and operator overloading are in this category.

This philosophy was guided by the .NET Frameworks team, who were building their frameworks in C# at the same time we were building the language. They were able to provide us feedback on using C# to write a framework, and on using C# to write framework clients. This dual perspective was invaluable; writing the framework validated that C# could be used for high-end programming, and using the framework validated that it was simple and straightforward to write client code.

We also benefited from the insight of members of Microsoft Research, who provided insight into how language research had attacked certain problems.

And finally, because C# was designed at the same time as VB .NET, the Managed Extensions to C++ and other .NET languages, there was a considerable amount of collaboration between the language and runtime teams. A Common Language Subset was defined, which specified the features that languages can expect other languages to support. This enables interop between languages. (See Sidebar: Why is Language Interop Important?)

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date