DEV Community

Why C# is (one of) my favorite language?

Giovanni Cortés on March 14, 2019

My first approach with C# was when I was studying my career; a guy from Microsoft came to my school to do a chat about C# technologies and one of t...
Collapse
 
turnerj profile image
James Turner

I love C#, it is my favourite language. I actually do like the coding conventions in C#, editing code in Visual Studio is great and .NET Core is fast!

If I had to be picky about what I don't like with it, it is probably the query syntax for LINQ.

For example, I don't like this (query syntax):

var numQuery =
    from num in numbers
    where (num % 2) == 0
    select num;

I prefer this (method syntax):

var numQuery = numbers.Where(num => num % 2 == 0);
Collapse
 
saint4eva profile image
saint4eva

I love method syntax better.

Collapse
 
frothandjava profile image
Scot McSweeney-Roberts

It's not the language that bothers me (it's basically a Java dialect with real generics). It's the idioms - IInterfaces, the start brackets in the wrong place, the casing choices, namespaces that cause a pointless indentation, the lack of a common structure to projects and the build system is an archaic mess. I guess the last two are less of an issue if you're using Visual Studio, but that's another problem that is only slowly resolving - the over-reliance on a single IDE.

Collapse
 
saint4eva profile image
saint4eva

Have you tried .Net Core? Give C# 7 or 8 a try. And the build system has been drastically improved. One good thing about C# is that the language keeps improving and evolving. Notwithstanding, I respect your opinion.

Collapse
 
frothandjava profile image
Scot McSweeney-Roberts

The build system is better than it was. However (and I admit that this could be more my greater familiarity with maven than anything else) there have been times when I've been using dotnet core and wishing I could use maven instead of msbuild+nuget.

Speaking of dotnet core, here's another problem I see (as someone who plays with F# but is otherwise an outsider) - mixed messaging from Microsoft. For example, there's a big song and dance about cross platform but now they're going on about Windows Forms and WPF with v3. That's not very cross platform. It would be one thing if it was clearly defined as something that sits on top of dotnet core and not a part of dotnet core. Maybe it is, but it's hard to tell, at least from what I've heard from Microsoft.

Which also reminds me of another problem I see - practically all the evangelism (at least from Microsoft) seems to be geared towards getting people to not leave. Very little effort seems to be being put into getting people to turn up. Which is kind of sad as I think .net is the "fullest stack" available and a lot of people could benefit from getting into it.

Thread Thread
 
saint4eva profile image
saint4eva

There are other open source community-driven alternative to MS Build - you can use Cake, Fake or Nuke. They are even simpler to use and yet powerful.

Regarding the dotnet core 3.0 support for WPF and WinForms, it has nothing to do with cross-platform. It just that those desktop technology will take advantage of some of the strengths of dotnet core such as performance, speed, signle deployment model and side-by-side deploy. I think Microsoft specifically gave an indepth explanation about this. So asp.net core and dotnet core are cross-platform.

I think this cuts across all the stack, to be hoest. In some countries - even in some county or states - some people love Java more .NET, while in some other countries some people love .NET more than Java. I think the reason Microsoft open sourced .NET was because many companies would love to use .NET but it was not open source. Now it is open sourced by Microsoft and many people are contributing, many people have started using it also. But your statement little "little effort", could you elaborate on that? Note Samsung is adopting .NET, Google etc. By the way, C# is still one of the most popular and loved programming languages.

Thread Thread
 
frothandjava profile image
Scot McSweeney-Roberts

it has nothing to do with cross-platform

That's the problem. In previous versions Microsoft constantly patted themselves on the back about how cross platform dotnet core was. Now they may or may not be doing an about face on that and you have to start to wonder how committed they really are to being platform agnostic.

Microsoft doesn't need to give an in-depth explanation. All they need is some basic product differentiation. Call it something like "The Modern Development Framework For Windows" and only mention dotnet core in passing, as opposed to the "Windows development is coming to dotnet core" messaging that they've been doing. They could even go one better and blow the dust off some of Mono's Linux-y bits (like GTK support) and port that to dotnet core as the "Modern Development Framework for Linux". OK, maybe not call it "Modern" because of the UI connotations and the Windows and Linux specific products should have fairly different names to avoid confusion, but hopefully you'll see my point that the platform specific code should be highlighted as not being the same thing as the platform agnostic core product.

As for "little effort" - watch any .net related video on YouTube with an evangelist from Microsoft and there's little effort put into why someone who isn't already using .net would want to start using it. If anything, the emphasis is put on why you shouldn't leave. It's always "you don't need to learn JavaScript" or "you don't need to learn Swift and the native iOS platform". There's practically never anything on why someone with a JavaScript or iOS or Java or whatever background should want to come over to dotnet.

In some ways the mixed messaging over Windows development in dotnet core is also part of the low effort to attract outsiders. It might make perfect sense to people who are already on the platform, but if you were evaluating the platform cold it looks like there's no clear direction of where it's headed and when you combine that with Microsoft's mercurial track record it really doesn't look good.

C# might still be popular and loved, but from the outside looking in it looks really, really insular.

Thread Thread
 
saint4eva profile image
saint4eva

You have already said you are a Java developer. So I rest my case.

Collapse
 
cout970 profile image
cout970

I dislike C# not because is bad, it's pretty good compared with other languages, but I hate the Microsoft coding conventions, especially functions and methods starting with uppercase characters. I tried several times to start projects in C# but for me it's really hard understand the code, even when I'm used to program in other of languages with worst readability (looking at you java).

Also the lack of support for hotswapping code at runtime makes the coding experience less enjoyable.

Collapse
 
giovannicodes profile image
Giovanni Cortés

I agree that Microsoft has a weird code convention, especially in C++ (the Hungarian notation is not for modern times) but, once you get used to that format, is not so bad.

Collapse
 
jonathanhiggs profile image
Jonathan Higgs

I think the worst convention is sticking Exception at the end. InvalidArgument has everything you need in the name without extending it to InvalidArgumentException, it is just extra characters that take up space

Thread Thread
 
giovannicodes profile image
Giovanni Cortés

Sometimes C# is very verbose, but not at the level of Java

Collapse
 
lmolivera profile image
Lucas Olivera

I learnt C# because my job demands it and I have to say I would have prefered to meet .NET with it instead of Basic. It is a powerful language I feel.

Collapse
 
saint4eva profile image
saint4eva

I love C#. It is an OOP language with excellent Functional language qualities. And I love it multi purpose nature and excellent tooling it provides.

Collapse
 
giovannicodes profile image
Giovanni Cortés

:)