Hacker News new | ask | show | jobs
by wilg 1442 days ago
Ugh, not more C#!

I hope one of these projects takes off: https://github.com/migueldeicaza/GodotSwift https://github.com/kelvin13/godot-swift

Excited to try Godot in a couple of years when it's more mature. Hopefully they can be the Blender of game engines – where it started rough and now is better than Maya or other alternatives.

7 comments

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.

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)

C# is really well suited to the task thanks to value types and structs, that gives you back control of memory that is lost in Java for example. It also has a lot of syntax sugar to avoid being too verbose and the memory safety and GC are desirable most of the time and can be avoided with well known tricks, like object pools, when performance needs are more paramount.
I don't know Swift very well, but I seem to recall the creator talking about using automatic reference counting instead of garbage collection as an intentional tradeoff. If that's still the case, I'd much rather use Swift over C# in a game (and I am using C# in a game!). The value types and structs are very limited compared to classes and reference types.
Yes ARC is definitely an intentional and well-chosen tradeoff. Swift has real first-class value types (strings, collections, etc are all value types) and copy-on-write semantics that make it all work quite well. C# value types feel like they are funkily bolted on and aren't really very useful in practice (at least in Unity).
Swift is entirely designed around value types and structs, and has a much more predictable ARC model instead of GC for game programming. Plus, an upcoming feature will add Rust-style lifetimes for more control (https://github.com/apple/swift/blob/main/docs/OwnershipManif...).
Godot's default language is GDscript, which is similar to Python. I'd highly recommend that to new people switching to Godot. I think C# is just cruft for people coming from Unity and stuck in old habits/frameworks.
I tried GDScript and hated it, ended up manually porting what I wrote to C#. GDScript currently only has partial support for static typing, which makes things a much bigger pain in the ass. Using C# was a breath of fresh air after that.
Yeah, I don't want a weird scripting language like Unreal Blueprint or GDScript or Lua. C# beats all of those by a mile. I want a robust, ergonomic, high-performance, compiled language like Swift.
C# isn't the worst but out of the newer languages I've tried it's probably the one I'm least excited to write. Swift or Kotlin would definitely be preferred.
You obviously know this since you linked a Swift bindings project, but for others reading who may not be aware: Godot officially supports multiple languages ("GDScript, C#, VisualScript, and C++ and C via its GDNative technology"[1]), but other languages are supported by the community.

In particular, a sibling comment mentions Kotlin. The docs[2] link to a project that adds Kotlin bindings https://github.com/utopia-rise/godot-kotlin-jvm

[1]https://docs.godotengine.org/en/stable/getting_started/step_...

[2]https://docs.godotengine.org/en/stable/tutorials/scripting/g...

I’ve actually read so many good things about C# lately here and on Reddit that I plan to start learning it in the coming weeks (other reasons include .Net and F# being an adjacent language)

What don’t you like about it?

Why Swift, when searching only, you can see that it performs much worse than C#?