Hacker News new | ask | show | jobs
by ianlevesque 1442 days ago
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.
2 comments

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...).