The Origins of C#: Microsoft's Answer to Java

•5 min read•

Some languages are born from research, some from frustration. C# was born from a legal fight. In the late 1990s Microsoft had a popular version of Java called Visual J++, and Sun Microsystems sued over how Microsoft had extended it[1] in ways that broke Java's run-anywhere promise. Microsoft lost the ability to ship its own flavor of Java. Rather than retreat, it decided to build a modern language of its own, free of anyone else's control, and to put a whole new platform underneath it. That language was C#, and the decision to build it turned out far better for Microsoft than winning the lawsuit would have.

Born from a Java fight

The Sun lawsuit left Microsoft needing a strategic answer. It wanted a language with the productivity and safety that had made Java popular, the object orientation and garbage collection and strong typing, but one it fully owned and could evolve on its own schedule. It assembled a team and put Anders Hejlsberg in charge of language design[2].

Hejlsberg was an obvious choice. He had created Turbo Pascal, led the Delphi project, and had, until shortly before, been the architect behind Microsoft's Java work. C# was announced in 2000 and released in 2002[3] alongside the first version of the .NET Framework. The family resemblance to Java was clear and intentional. So was the ambition to do better.

The .NET platform

C# never ran alone. It was the flagship language of .NET, a platform built on the same idea that made Java portable. C# code compiles to an intermediate language, which runs on the Common Language Runtime[4], a managed environment that handles memory, security, and execution. The runtime was designed from the start to host more than one language[5], so Visual Basic and other languages could compile to the same intermediate form and share the same libraries.

That shared platform mattered. A team could use one enormous, well-designed class library regardless of which .NET language they wrote in, and the runtime provided garbage collection and safety across all of them.

Learning from Java and then passing it

Because C# arrived a few years after Java and had a strong architect, it could learn from Java's early mistakes and then move faster. It did exactly that. C# 2.0 added generics with a cleaner implementation than Java's. C# 3.0, in 2007, introduced LINQ[6], a feature that let you write queries over data, collections, databases, XML, directly in the language with real type checking.

var adults = people.Where(p => p.Age >= 18)
                   .Select(p => p.Name);

That style of expressing data queries as ordinary, checked code was ahead of its peers and widely copied later. Over time C# gained a reputation as one of the better-designed mainstream languages, evolving quickly while staying coherent.

The feature the web borrowed

C# 5.0, released in 2012, introduced the async and await keywords, a clean way to write code that waits on slow operations like network calls without blocking or tangling your logic into callbacks. The model was influential well beyond C#. JavaScript adopted the same async and await syntax a few years later[7], and it is now how most of the web handles asynchronous work. If you write modern JavaScript, you are using a pattern that C# helped make mainstream. It is a good example of how ideas move between languages, and of how a language built as a follower ended up leading.

Breaking free of Windows

For its first decade C# had one major limitation: it was tied to Windows and to a proprietary, Microsoft-controlled stack. That was fine for enterprise shops already committed to Microsoft and a dealbreaker for everyone else. The company eventually recognized the cost of that boundary and changed course dramatically.

Starting around 2016, Microsoft released .NET Core, a rebuilt, open source, cross-platform version[8] of the platform that ran on Windows, Linux, and macOS. The language and runtime became genuinely open, developed in the open on GitHub. The separate editions later unified under a single modern .NET. A language that had been a symbol of Microsoft's closed ecosystem became one of its more credible open source efforts.

What it means today

C# is now a strong choice for building web applications, through ASP.NET Core, a fast and well-regarded framework for APIs and server-rendered sites. It also reaches the browser through Blazor, which runs C# on WebAssembly so you can write front-end code without JavaScript. Beyond the web, C# is the language of the Unity game engine, which makes it one of the most common languages in game development, and it remains heavily used across enterprise software.

C# is a case study in turning a setback into an advantage. Blocked from shipping Java, Microsoft built something it controlled, learned from its rival's errors, and eventually opened it to the world. The language that started as Microsoft's answer to Java outgrew the question, and much of it now runs far from any Windows machine.

Sources (8)
  1. Wikipedia: Visual J++
  2. Wikipedia: Anders Hejlsberg
  3. Wikipedia: C Sharp (programming language)
  4. Wikipedia: Common Language Runtime
  5. Wikipedia: Common Language Infrastructure
  6. Wikipedia: Language Integrated Query
  7. Wikipedia: Async/await
  8. Wikipedia: .NET