D或Go用于集群游戏服务器

huangapple go评论89阅读模式
英文:

D or Go for clustered game server

问题

我正在设计一个游戏,但这个问题适用于任何需要在集群和主服务器之间进行双向通信的情况。我对集群还不太熟悉,但我经常使用Go编程,偶尔也用D编程。

我真的想使用一种现代语言(不是C/C++),所以我选择了这两种语言,因为:

  • 数组切片
  • 良好的并发支持
  • 跨平台并且可以本地编译(有多个编译器实现)
  • 垃圾回收(都使用精确的垃圾回收算法)

我已经阅读了https://stackoverflow.com/questions/3554956/d-versus-go-comparison和https://stackoverflow.com/questions/4516283/the-d-programming-language-for-game-development。

从高层次上看,我的游戏大部分处理都在服务器端进行,客户端只是根据他们的视角渲染游戏状态。游戏被设计为可扩展的,所以它需要在集群中运行。组件大部分是CPU密集型的,并且异步更新到主服务器,主服务器与客户端共享游戏状态。大部分计算依赖于用户输入,所以这些事件需要发送到各个组件(因此需要双向RPC)。

我喜欢D的原因:

  • 手动内存管理
  • 模板/CTFE
  • 代码安全性(@safe,合同,输入/输出)

我喜欢Go的原因:

  • 标准库(pprofRPC
  • Go协程
  • go工具(尤其是go get -u用于安装/更新远程依赖)

客户端可能会用D编写,但这不会对服务器产生影响。

考虑到这两种语言之间的选择,你会选择哪种语言来解决这个问题?

英文:

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 https://stackoverflow.com/questions/4516283/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?

答案1

得分: 5

我预计两种方法都可以,并且很大程度上取决于你的偏好,但是如果你用D语言做客户端,我建议你也用D语言做服务器端,因为这样涉及的语言就少一些。如果你使用两种语言,那么任何参与你项目的人通常都必须了解这两种语言,而且目前来说,Go和D的用户群体都相对较小,很少有人会同时了解这两种语言 - 虽然如果只有你一个人在开发,显然你已经了解这两种语言。

然而,我要指出的是,如果使用D语言的问题是缺乏RPC库,那么这并不是问题,因为D语言受到Apache Thrift的支持。所以,D语言确实有一个可靠的RPC库,即使它不在其标准库中(实际上,这是D语言在参与Google的Summer of Code项目的第一轮中的成果之一)。

英文:

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

答案2

得分: 0

如果你的游戏对服务器的并发性很重要,那我推荐使用Go语言。

我在Go语言中开发了一个实现PUSH技术通信的服务器。对于这样的任务,Go语言非常出色。代码简洁紧凑,易于理解。

自动内存管理在并发应用中非常重要。

与服务器应用程序不同,客户端应用程序并发性不高。客户端应用程序应该保持持续的高帧率。

因此,对于客户端应用程序来说,没有全局GC锁的手动内存管理更好。

英文:

I do not know anything about your game, If good concurrency for your server is important then I vote for Go.

I developed communication server in Go that implements communication with PUSH technology. Go is great in for such tasks. Compact clean code that is easy to understand.

Automated memory is important in concurrent apps.

Client apps are not so concurrent like server apps.
Client apps should keep constantly high frame rate.

So manual memory management without global GC locks are better for client apps.

huangapple
  • 本文由 发表于 2012年9月15日 04:20:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/12431451.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定