Search code examples
godrpc

D or Go for clustered game server


I'm designing a game, but this question is applicable to any situation that requires bidirectional communication between nodes in a cluster and a main server. I am pretty new to clusters, but I actively program in Go and occasionally in D.

I really want to use a modern language (not C/C++), so I've chosen these two languages because:

  • Array slices
  • Good concurrency support
  • Cross platform & compiles natively (with multiple compiler implementations)
  • GC (both working on a precise GC)

I've read https://stackoverflow.com/questions/3554956/d-versus-go-comparison and The D Programming Language for Game Development.

At a high level, my game will do most of the processing server side, with the client just rendering the game state from their perspective. The game is designed to scale, so it will need to act in a cluster. Components are mostly CPU bound, and update to a main server asynchronously, which shares game state with clients. Most computation depends on user input, so these events need to be sent down to individual components (hence bi-directional RPC).

Reasons I like D:

  • Manual memory management
  • Templates/CTFE
  • Code safety (@safe, contracts, in/out)

Reasons I like Go:

  • Standard library (pprof, RPC)
  • Go routines
  • go tool (esp. go get -u to install/update remote dependencies)

The client will likely be written in D, but that shouldn't have an impact on the server.

I am leaning towards D because manual memory management is baked into the language. While it doesn't have the nice libraries for RPC, I could theoretically implement that, but I cannot as elegantly implement manual memory management in Go.

Which would you use for this problem given the choice between the two languages?


Solution

  • I expect that either will work and that a lot of it depends on which you prefer, though if you're doing the client in D, I'd advise doing the server in D simply because then there are fewer languages involved. If you use two languages, then anyone working on your project generally has to know them both, and both Go and D are small enough in terms of their user base at this point that few people will know both - though if it's just you working on it, you obviously know both of them already.

    However, I would point out that if the problem with using D is the lack of an RPC library, then that isn't a problem, because D is supported by Apache Thrift. So, D does have a solid RPC library, even if it's not in its standard library (in fact, it was one of the fruits of D's first round of participation in Google's Summer of Code).