Hacker News new | ask | show | jobs
by tarasmatsyk 2215 days ago
I still think C# is one of, if not the best of designed languages exist. Even it moves in much smaller steps than it was before I think it's for good.

I left .NET land at 6.0 and .NET 4.x versions mostly because of Windows eco-system (small open source community, almost no alternatives to out of the MS things, bad linux support). Since that I've been working with Java, Swift,JS, Python, Golang and I still think that C# is one of the best-designed languages. Very few of them keep evolving through the decades, hopefully it can become the language of the year at some point, always liked to see how new features got implemented under the hood and what kind of features get into next release.

Well done C# team

It's amazing how the language advances over years

7 comments

It really is wonderful. Used it at work years ago and still miss it dearly.

The only thing I don't miss is the lack of community. Many things you can get for free in Java/Python cost money in Microsoft land. Even common stuff like decent excel and PDF support. Its getting better but was still the case last time I looked.

What C# needs is Java interop. The VM and bytecode structures are similar enough for it to work. There was a guy maintaining a library for this until recently :(

Official CLR Java interop would kill Java. Within a few years every new project would be in C#.

The only other places I'm aware Java has a big advantage is GC and monitoring. C#'s GC is old school, has long pause times. Makes C# a no-go for many uses. Java also has better monitoring and profiling support.

Funny you should say that because I wrote an application that has both Excel and PDF output and both libraries were free on NuGet.
there's free libraries, I used a bunch of them. I guess I'm just asking you to trust me that's its not nearly as good as in Java. C# is a better language, there's no question. But I jumped off the MS bandwagon years ago because there just wasn't the community support that Java has, for better (or probably) worse
It's been a lot better for a long time.

There -are- still a couple sore points, PDF comes to mind. But there are at least a couple different good projects out there for working with Excel at this point.

Bigger problem is a larger portion of C# developers and their managers are frightened of shifting away from the Microsoft blessed stack. That's what creates this chicken-egg situation where good projects don't have enough community behind them because there aren't enough people using them.

GC in C# isn't perfect but works fairly well if you understand it. There's plenty of ways to write minimal or zero-allocation code and it's gotten a lot easier with the newer Span types.

Monitoring though... yeah The first time I learned about Blackbox and the like I got a bit jealous :)

I wouldn't expect that to change any time soon. The Microsoft/Sun lawsuit still stings inside the company and has legal impact decades later (https://www.cnet.com/news/sun-microsoft-settle-java-suit/). It's the reason why, for instance, you can't download Windows 98 or Visual Studio 6 on MSDN/Visual Studio subscriptions. Microsoft is now friendlier to open source than it has been, but I would be shocked if they ever got friendlier with Java. (Disclaimer: I haven't worked at MS in several years)
And I'm sure that the Google/Oracle lawsuit hasn't exactly improved things, either. Not to mention the recent licensing changes. Java is such a can of worms legally that it's surprising that anyone sensible would want to touch it with a ten-foot pole.
.NET Java interop is literally Xamarin on Android. Java interop worked for 15 years+, it is just not commonly known and was a community project.
Didn't C# start with Microsoft poaching the lead Delphi architect from Borland? A lot of people loved Delphi back in the day for its design too.
It's funny, the languages I ended up using the most throughout the years are Delphi, C# and most recently Typescript (where Anders is also a lead architect). And my very first lines of code could very well have been written in Turbo Pascal (also by him), if I remember correctly.

As an aside, although common, I dislike the term "poaching" when it comes to hiring. It's negative connotations are inescapable, but also inappropriate when talking about hiring.

Actually Borland's management helped quite a bit believing some Anders interviews.
I’ve been using Delphi before and it looks like a grown/better Pascal. C# is a c-family language which seems weird right after the switch, however you start appreciate C syntax a bit later.

I think C# was an attempt to design MS Java which is better than Java

Your both right, C# was MS Java-but-better designed by the designer of Delphi, who had recently (perhaps specifically for that project) been hired by MS.
The little ugly fact is that Anders was also involved in the Microsoft Java effort.
Feeling the same here. It's elegant, and imo easier to read than most languages. There aren't many choices of libraries in C#, but they cover most use cases. Still I found myself happy to publish to NuGet my own package because I love exploring the language and its features.

Now developing in Python at work, I can find a multitude of packages for every need I have to meet, which is perfect for productivity, but I feel I can never understand the language enough because all I do is to import some packages and get work done.

I really hope C# gets more popular among devs. Where I live only large non-tech companies use it internally, which might explain why there are not many open source libraries in C# compared to other languages.

Though, with all the comments here saying C# is turning into F#, I'm tempted to try out F# as my first functional programming language now.

It's by far my favorite general purpose language. Works well everywhere, and the best tools around.
C# is a very good language. I like it a lot, and Visual Studio is a fine IDE, but the tools pale in comparison to the JVM tools (Maven, Gradle, IntelliJ, Eclipse, Spring Boot, GraalVM, etc)
I am curious why you think this. This may have been true like 10 year ago, but in my experience modern .NET and especially .NET Core has great tooling. What in particular do you find lacking?
I thought Visual Studio 2019 is already great. How does it compare to JVM tools though?
JetBrains Rider is a fine IDE.
> Works well everywhere

Perhaps it's gotten better - TBH I haven't checked in years - but it used to be a horrible bug ridden mess for doing things aimed at Linux (i.e. via mono).

To answer your question first: It's faster on Linux than Windows now (marginally) and completly stable on Linux. I've been running a .net core systemd service for 9 months with 0 downtime (not using the new HostedService class though). It hasn't leaked any memory at all, it's still running perfectly even though it opens thousands of files and thousands of connections to a web service every hour.

It's just a process that picks zip files from the local SFTP service, sends each entry in the zip to an external web service, and writes the result of the file to a new zip in the SFTP directory. Extremely simple, but also the kind of application in which resource leaks become apparent very fast, and it's been far more stable than anything we had on Windows where we had to reboot servers once a month just as a precaution.

A few years ago I was playing with Kotlin when it had been recently released, and I remember thinking that eventually it would be a likely candidate as a default language for new enterprise projects. My reasoning was based mostly on it being a better Java, it solved just the right problems but wasn't too different and thus easy to learn. And at the time the JVM had too many advantages over .NET (multi plataform, open source, supported every technology under the sun)

Fast forward a few years, and .net now supports Linux natively, and is even faster on Linux than Windows. Microsoft has or is open sourcing pretty much everything, and with the rise of Nuget the third party library ecosystem has grown by leaps and bounds. C# has become an amazing language, considering that back in 2000 it was basically Java. While Oracle has regressed and is oppressing the ecosystem in its typical ways.

Even though I still like Kotlin better (purely from a language design standpoint), C# has evolved so much it nearly matches it, while Java is just a kitchen sink of non-cohesive features and libraries. C# in 2020 almost seems as it was designed from the ground up to be a semi-functional asynchronous OOP language with reifed generics, linq, async / await, null safety, and many more features.

That is absolutely mind boggling, because it is a language that made nearly all the mistakes that the originally Java did back in the days (save checked exceptions), and now a days I think it should pretty much be the default plataform for any app that needs to interact with enterprise technologies, and should honestly be considered in all green field projects if the team has development expertise in it. We've stopped being a mix shop and are now pretty much .net exclusively.

> While Oracle has regressed and is oppressing the ecosystem in its typical ways.

Not sure what you're referring to here. Java/JVM has been open sourced for a while as well.

> while Java is just a kitchen sink of non-cohesive features and libraries

I disagree. If you look at the new features coming out (pattern matching, records, green threads/fibers, value types, etc.) the Java designers are taking a very principled approach. Everything fits very well with the language design.

Very interesting. One of the reasons I like the JVM is that it has a good cross-platform GUI system. Does the .NET windows GUI work in Linux as well?
Almost. :)

Right now there is Xamarin Forms which has a community maintained Linux layer.

You can use that today if you write a Xamarin forms app.

From the Microsoft side of things, no, you can't just write a winforms app and use it in Linux.

However, they have announced MAUI which basically lets you write XML/XAML UI Declarations that are platform agnostic and can be translated into the various layers (such as Xamarin Forms.) I believe that's supposed to be a thing sometime late this year or early next (don't quote me on that!)

Other projects to look into are AvaloniaUI and Uno. Those are community projects that try to give you cross platform UI today.

Thanks for the great info. Looks like it's time to take another crack at it.
Yeah I remember the days of subtle mono bugs and segfaults, but the new(-ish, its been out for years) .NET Core brings official support to linux. ASP.NET Core is definitely a solid platform for web apps on Linux now too.
Official support for some .NET things. WinForms are not on linux and won't ever be.

Even the newly announced MAUI is only "community supported" on linux.

Well now you use .NET Core and it works flawlessly :-)
Yeah, now it's an officially supported bug-ridden piece of crap. Just like on Windows. Woo, I guess?
It's about trade off. A language that keep getting new features every year, will make some users happy, but will lose compiler speed and it will be harder to learn.
I love C# and have used it since the beginning (my online handles are often VisualCSharp), but I do worry about the cognitive burden of remembering idioms and dealing with multiple ways to do the same thing. This is already a huge issue with C++, and now it's slowly happening to C#. I work with many, many developers--some overseas--that are still in the string.Format era. The language is starting to show some warts due to inheriting bad decisions from former language maintainers (e.g., nullable value types and nullable reference types being treated completely differently).

I hope for C#'s sake that at some point it can metamorphize--not just evolve--into a new language that can leave some of the crufty decisions behind.

> The language is starting to show some warts due to inheriting bad decisions from former language maintainers (nullable value types and nullable reference types being treated completely differently).

That's being a little too harsh, in my opinion. Even if you were designing both kinds of nullable types right now, it'd be difficult to have them behave the same way without adding runtime support for keeping track of nullability of reference types. And that's quite a big task.

> I do worry about the cognitive burden of remembering idioms and dealing with multiple ways to do the same thing

To me, VS 2019 refactoring suggestions and Roslynator extensions helped a lot to learn and use new syntax capabilities and idioms: you write code in "the same old way" and then often roslyn is able to convert this code using new features, often in a concise, readable but undebuggable way :)

This is one of my biggest pet peeves with C# - it's so annoying that value and reference types behave differently in respect to nullability.
> It's amazing how the language advances over years

I think that with the latest improvements (from v7 to now) Microsoft is trying to "fill the gap" between F# and C#, and let C# developers embrace functional paradigms (at least, some of) without switching to F# itself.

To me C# is the second best designed language, the first being IMHO Kotlin. I'm very interested in what you think would make C# more well designed than the latter :}
Overall I find the syntax to be a little too inconsistent for the sake of conciseness but its a well designed language. It might just be my lack of experience and the amount of features in Kotlin.

Code examples have a lot of what looks like lambda callback hell and I find it hard to read but again, I might just need more practice.

Interestingly, both are done by companies who care about developer productivity. When you here Anders Hejlsberg talking it is all about productivity (C# and TypeScript). I do not know the kotlin designers, but I bet they talk similar.
May I ask why do you think kotlin is best designed?
It has the benefit of 15 years more hindsight.

As an example, during this time the development community figured out that using immutability as the default brings benefits.

Kotlin is designed with this in mind, but C# isn't - e.g. C# has this cool feature for object initialization which is so handy and all developers use it. Except for - it doesn't work with immutable classes (the ones with readonly fields). As an effect developers dislike to use immutable classes since it's not ergonomic in C# and instead use standard POCO.

Another example is that C# still in this age does not support readonly parameters and local variables (which even Java and JavaScript (!) support). In Kotlin "readonly" local variables is the idiomatic code practice which doesn't make code any more verbose. And in the case they decide to add it to C#, it will have to be at the cost of verbosity (similarly to how Java does it) because of backwards compatibility.

> Except for - it doesn't work with immutable classes (the ones with readonly fields).

Well good thing they're adding that in C# 9 then

Oh, cool, I didn't notice that!

Still, they are playing catch-up here.

I mean... if you go that route then I would say Kotlin isn't really ready to be used as a production language in most places due to the severe lack of tooling, especially when it comes to things like static analysis. Sure ktlint is there, but the rules library is lacking.

So from that perspective, Kotlin is playing catch-up.

I think kotlin is ugly hack, if you take away the superficial syntax (?) it will start showing ugly side. I think it only gotten popular because of Googles push due to Oracle Java lawsuit.
I don't think Kotlin is being pushed because of the Oracle lawsuit. Most of Oracle's complaints were at the VM and standard library level, which Kotlin doesn't help with.
Kotlin allows Google to hang out in Java 8 forever. If they want new features they can just add them at the Kotlin layer. Insulates them from OpenJDK and any changes Oracle wants to make. All great opportunities to fragment the Java ecosystem
OpenJDK was always fine for them to pull in, being GPLed. They got in trouble because they based their class library on Apache Harmony originally, and Sun pulled the TCK rug out from under Harmony.
Kotlin is written by JetBrains.
Can you elaborate on ugly side?