Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yes, please. Anything but C++. The progress of Rust and Go make me hopeful for the future.


Go (at least as it stands today with its non-generational, stop the world, mark and sweep GC) is wholly unsuitable for video game development where unpredictable latency must be avoided.


I don't completely disagree with your point, and I would not be a person to advocate Go for game development, but "wholly unsuitable" isn't true. A large number of successful games are released that depend on runtimes with similar garbage collectors. Most notably games running on the JVM and CLI. These are "real games" with real performance considerations.

See: Minecraft, Terraria, Magicka, AI War, and many more.


The JVM and CLR both have generational garbage collectors, which reduces the impact of most GC pauses quite significantly.

Go's GC on the other hand is non-generational, which means every GC pause must perform a full scan of all objects in the system.


Sorry, I misread your post as saying GC in general is wholly unsuited for game development. My mistake.


I've updated my post, sorry for the confusion!


Is there a reason why future work on Go's runtime couldn't fix this problem?


I wouldn't say impossible, but yes, there are reasons this is difficult to fix in Go compared to Java and C#, and intentionally so.

Quoting from http://talks.golang.org/2012/splash.article (emphasis mine):

"To give the programmer this flexibility, Go must support what we call interior pointers to objects allocated in the heap. The X.buf field in the example above lives within the struct but it is legal to capture the address of this inner field, for instance to pass it to an I/O routine. In Java, as in many garbage-collected languages, it is not possible to construct an interior pointer like this, but in Go it is idiomatic. This design point affects which collection algorithms can be used, and may make them more difficult, but after careful thought we decided that it was necessary to allow interior pointers because of the benefits to the programmer and the ability to reduce pressure on the (perhaps harder to implement) collector."


To be fair I don't think this is a blocker for Go to implement GGC and CGC. .NET supports interior pointers too, for example. You just have to design your allocator right to allow the card marking to work.

In practice I think that the biggest problems are compiler related and affect both Go and Rust. Go and Rust both use conservative GC on the stack and as a result they take a lot of shortcuts. For example, LLVM (and GCC as far as I'm aware, though someone like DannyBee may correct me here) loses the distinction between integers and pointers by the time they get to the machine instruction level, which makes a lot of optimizations easier to implement but also making it impossible to generate precise stack maps. Fixing this would be a lot of hard work. It's probably easier in the Plan 9 compilers, of course, though I suspect it's still going to be a lot of hard work.


You know a lot more about these things than I do.

That said: Aren't the equivalent pointers in .Net _only_ allowed/usable if you pin your object? If you tell the GC explicitly 'please don't move that, I'm pointing to that thing here'?

That's hard to bolt on to Go, imho. For Go it seems to be implicitly allowed, in .Net you have to ask explicitly?


Go's GC is non-moving, exactly because they can't precisely know what a pointer is and what is just some random int.

So it's basically as if all objects are pinned in Go. I don't expect that to change. There are probably tons of Go code out there which will break in response to a change.

I guess it will be pushed back to some mystical "2.0" release, along with Generics.


I've been following along on golang-dev, and they seem to be making progress on precise stacks.

See https://groups.google.com/forum/?fromgroups#!topic/golang-de... for example.


Not at all, it just takes work.


They could, but I expect their "worse is better" attitude will prevent it.


I haven't looked at the others, but Minecraft stuttered very badly for me. I got the distinct impression that real performance wasn't considered.


Agree for Minecraft, it has definitely "lags" to an extent that there are a lot of forums discussing how to tweak the configuration to improve the performance. The lags are very disturbing and I think it has to do with memory management because it sets in after some time of playing.


It certainly fits the profile of GC stutter. I'm told it makes some bad decisions about handling objects, triggering pathological behaviour in the collector but that's second-hand info at best.


Sounds like a driver issue. Minecraft works quite well for many people.


I disagree with your 'wholly unsuitable', I came across this game engine (Garage engine) written in Go which certainly doesn't jitter due to the garbage collector.

http://www.youtube.com/watch?v=iMMbf6SRb9Q

http://www.youtube.com/watch?v=BMRlY9dFVLg

https://github.com/vova616/GarageEngine

So I say your statement is exagerrated, certainly stop-the-world garbage collectors isn't ideal for games, but it's not 'wholly unsuitable' as long as the gc sweeps aren't costly enough to impact consistent framerate. Had they been 'wholly unsuitable' then the XNA platform would have been dead upon arrival.


When latency matters, just use pool allocation, which makes the GC irrelevant.


That's how people manage to make games despite GC, but I always thought it's a huge hack, having been there. If all you do with your GC is fight it, is it actually a good idea to have it?

One thing that makes me excited about Rust is that GC is optional.


Pools are still traced.


If you pool everything, the GC never runs and tracing is irrelevant. However, getting to there is very difficult. Better is to just make sure you throw almost everything away before the next GC, have a small permanent runtime set of objects and accept 10-20ms stop the world young gen collections.


Targeting 30fps, you have 33ms to render whole frame. Losing 20 ms of that to GC would make things… challenging.

And if you're targeting 60fps, that's 16ms. Stop the world for 20ms, and you've missed 1 and 1/4 of a frame.


There are concurrent collectors that do not stop the world (e.g. Azul's) that you might want to look at for game development.


Just avoid producing too much garbage then?


Why is it everytime people talk about replacing C++, someone always comes in and sticks Go into discussion? What does Go have to do with C++?


One of the original description/assertion of Go was as a "systems language done right". Many have not been able to move on from that to the effective "a somewhat better java".




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: