15 years of C#

2002 was the year when Microsoft proudly presented .NET Framework and C#. I have started using the language one year after that and still continue doing that. With C#, I paved my way from student to junior developer, learned much turning into a senior software engineer, and then became a CTO after all (see my coder timeline). So the anniversary is not an empty word here for me.

Sea shark (true story)

Imagine three programmers working in one team writing C++ code in Visual Studio 6. In 2004, we decided to suggest our German customer moving to .NET Framework and C#. That would definitely accelerate software development velocity. And that was our major point for a conversation with him. When Matias (the customer) arrived in Ukraine, we told him about new progressive language from Microsoft and explained why it’s good for him. He was quite surprised and seriously asked us:

What’s the language name you are saying? Sea shark?

C#: from 1.0 to 6.0

It has been a quite dynamic development of the language since 2002. We can again compare C# against Java which made progress from Java 4 to Java 8 only.

Please don’t think me being a Java hater :) I actually like using it in Atola products very much together with C#. Therefore it is easy to come up with a well-thought comparison.

Here are key historical changes of the language for the whole 15-year period.

Why C# is better than Java

C# emerged when Java had already been on the market. It inherited many Java ideas as well as received lots of cool features one cannot find in Java. Here are the most significant differences having a large impact on a core development process.

Properties

Methods with get/set prefixes in names are so boring. Typical boilerplate code. There is no need to write it in C#.

public int Seconds { get; set; }
public double Hours
{
get { return Seconds / 3600; }
set { Seconds = value * 3600; }
}

Structs

There are no structs in Java. Structs in C# are stored on stack enabling higher performance and better memory use.

public struct CoOrds
{
public int x, y;
    public CoOrds(int p1, int p2)
{
x = p1;
y = p2;
}
}

Event handling

public class Publisher
{
event EventHandler<float> OnTemperatureChanged;
    public int Temperature
{
set
{
_Temperature = value;
OnTemperatureChanged?.Invoke(this, value);
}
}
}

Asynchronous programming

Async/await are extremely convenient and help writing asynchronous code.

async Task<int> AccessTheWebAsync()  
{
HttpClient client = new HttpClient();
Task<string> getStringTask = client.GetStringAsync(addr);

DoIndependentWork();
   string urlContents = await getStringTask;  
   return urlContents.Length;  
}

That’s all for now. Thank you for reading!

There’s more to come on the blog, so just sign up to keep tuned.

Like what you read? Give Vitaliy Mokosiy a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.