3 ms·
For a computer game, if you start out by allocating a large block of memory, then manage it yourself, I don't see how this would be a problem.
by xyproto 7y ago
For a computer game, if you start out by allocating a large block of memory, then manage it yourself, I don't see how this would be a problem.
- littlestymaar 7y agoYou're not using the GC at all then. Why use Go (and praise its GC) in that case?
- Skunkleton 7y agoFor the joy of getting the round peg through the square hole of course.
- xyproto 7y agoGo has many advantages over C that are not related to GC.
- takeda 7y agoGo was pushed as a C replacement, but very few C programmers switched to it, it seems like it took hearts of some of Python, Ruby, Java etc programmers.
- Valmar 7y agoGo also has many disadvantages, compared to plain C.
- xyproto 7y agoCan't think of any. Do you have an example?
- littlestymaar 7y agoYou can't call native libraries without going through cgo. So unless you don't want to have audio, draw text and have access to the graphic APIs, you'll need cgo, which is really slow due to Go's runtime. For game dev, that's a no go (pun intended). Additionally, the Go compiler isn't trying really hard at optimizing your code, which makes it several times slower on a CPU-bound task. That's for a good reason: because for Go's usecase, compile-time is a priority over performances. Saying that there is no drawbacks in Go is just irrational fandom…
- xyproto 7y agoYou are only talking about the Go compiler from Google. GCC also supports Go (gccgo) and can call native libraries just like from C. I'm not saying there are no drawbacks in Go, just that I can't think of any advantages of C over Go.
- littlestymaar 7y agoIn a context where you don't allocate memory, you lose a lot of those (for instance, you almost cannot use interfaces, because indirect calls cause parameters to those calls to be judged escaping and unconditionally allocated on the heap). Go is a good language for web backend and other network services, but it's not a C replacement.
- xyproto 7y agoIf you allocate a large block of memory manually at the start of the program, then trigger the GC manually when it suits you, won't you get the best of both worlds?