Hacker News new | ask | show | jobs
by wilg 1441 days ago
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...)

4 comments

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.