top | item 42005197

(no title)

mycocola | 1 year ago

That entirely depends on the game. Recent example is Risk of Rain 2, which had frequent hitches caused by the C# garbage collector. Someone made a mod to fix this by delaying the garbage collection until the next load-screen — in other words, controlled memory leakage.

The developers of Risk of Rain 2 were undoubtedly aware of the hitches, but it interfered with their vision of the game, and affected users were left with a degraded experience.

It's worth mentioning that when game developers scope of the features of their game, available tech informs the feature-set. Faster languages thus enable a wider feature-set.

discuss

order

munificent|1 year ago

> It's worth mentioning that when game developers scope of the features of their game, available tech informs the feature-set. Faster languages thus enable a wider feature-set.

This is true, but developer productivity also informs the feature set.

A game could support all possible features if written carefully in bare metal C. But it would take two decades to finish and the company would go out of business.

Game developers are always navigating the complex boundary around "How quickly can I ship the features I want with acceptable performance?"

Given that hardware is getting faster and human brains are not, I expect that over time higher level languages become a better fit for games. I think C# (and other statically typed GC languages) are a good balance right now between good enough runtime performance and better developer velocity than C++.

Const-me|1 year ago

> frequent hitches caused by the C# garbage collector

They probably create too much garbage. It’s equally easy to slow down C++ code with too many malloc/free functions called by the standard library collections and smart pointers.

The solution is the same for both languages: allocate memory in large blocks, implement object pools and/or arena allocators on top of these blocks.

Neither C++ nor C# standard libraries have much support for that design pattern. In both languages, it’s something programmers have to implement themselves. I did things like that multiple time in both languages. I found that, when necessary, it’s not terribly hard to implement that in either C++ or C#.

smaudet|1 year ago

> In both languages, it’s something programmers have to implement themselves.

I think this is where the difference between these languages and rust shines - Rust seems to make these things explicit, C++/C# hides behind compiler warnings.

Some things you can't do as a result in Rust, but really if the rust community cares it could port those features (make an always stack type type, e.g.).

Code base velocity is important to consider in addition to dev velocity, if the code needs to be significantly altered to support a concept it swept under the rug e.g. object pools/memory arenas, then that feature is less likely to be used and harder to implement later on.

As you say, it's not hard to do or a difficult concept to grasp, once a dev knows about them, but making things explicit is why we use strongly typed languages in the first place...

Rohansi|1 year ago

The GC that Unity is using is extremely bad by today's standards. C# everywhere else has a significantly better GC.

In this game's case though they possibly didn't do much optimization to reduce GC by pooling, etc. Unity has very good profiling tools to track down allocations built in so they could have easily found significant sources of GC allocations and reduced them. I work on one of the larger Unity games and we always profile and try to pool everything to reduce GC hitches.

n4r9|1 year ago

Apparently that was released in 2019? Both C# and dotnet have had multiple major releases since then, with significant performance improvements.