Hacker News new | ask | show | jobs
by throwaway675309 1442 days ago
Do you have an actual specific disagreement with c# or are you just venting because you are not familiar with the language?

C# is a robust language with a lot of features like lambdas pattern matching etc. I also find that most of the people who know Swift are Apple developers, so I feel like there isn't a broad enough appeal especially for game devs who are going to be more Windows or Linux centric.

3 comments

Yes, I know C# reasonably well. I use it in Unity for game development, where it is the only option.

C# is better than many alternatives, but Swift is simply a better language in every regard.

C#'s GC is a constant issue for games, and it makes using things like LINQ nearly impossible since it does so much allocation. Swift is designed around automatic reference counting instead. C#'s structs work weirdly and are hard to use.

Swift is so much more ergonomic. C# has added a few nice things lately, but it's much more verbose than Swift.

Swift is also more focused on performance, and is always AOT compiled.

Unity has had to come up with some insane things to get C# to work across platforms – they have their own .NET IL to C++ compiler (https://docs.unity3d.com/Manual/IL2CPP.html) that doesn't always work right. They also have a SECOND custom C# compiler for high-performance programming (https://docs.unity3d.com/Packages/com.unity.burst@0.2/manual...).

I'm also very excited about Swift 6's upcoming opt-in Rust-like lower-level memory management which should help a ton for performance-critical code. (https://github.com/apple/swift/blob/main/docs/OwnershipManif...)

Sounds like you mostly just don't like what Unity has needed to do over the years with the Mono runtime, not the language.
Dotnet Core is significantly faster than the old version of mono that Unity is currently stuck on.

They've recently announced that they're finally upgrade to .net core over the next couple years, so that should help out a lot. https://blog.unity.com/technology/unity-and-net-whats-next

My experience with C# has mostly been working on a personal project WinUI desktop app, and my biggest peeve has been reaching for something I use regularly in other languages only to find that it doesn't exist, and the solutions offered up by googling are usually, "well you can write your own implementation", "[huge utility library] offers that", or "don't do that it's not idiomatic/performant/etc". While none of those are showstoppers they slow development down and act as a source of frustration.
That's strange because I can't think of a language with a bigger first party library than .NET. The breadth of System. and Microsoft. is enormous.
It's funny because I keep seeing "Go is the gold standard of what a standard library should be", when dotnet dwarfs it by a BIG margin.
@jayd16 No, they have dropped the Mono runtime for many cases (which causes some of the problems). The language itself is simply much less pleasurable to program in than Swift, and performs worse in key areas.
I can't speak for the grandparent, but using C# in Unity, the garbage collector is always at the front of mind and dissuades people from using some of the nicer features of C# (LINQ, etc.). Granted my knowledge of this is a couple years old, so maybe the situation has improved, but I'm guessing most Unity developers are still very careful about how they write loops and how/when objects are allocated and all that stuff. Automatic memory management can be more of a hindrance than a benefit if you have to babysit it to avoid GC pauses.
C# needs a fat runtime, has a slow JIT (say hi to micro stutters in your gameplay and increased input latency), has a slow GC and worst of all is owned by Microsoft with a proprietary debugger that you can only use on visual studio (licence they changed overnight because Jetbrains released a C# IDE)

There are much better languages for game scripting (LUA for example)