1.2Why use .net core.md 4.9 KB

Why use C# .net core for server-side?

Game server side from the early single service to distributed, the development is more and more complex, the stability, development efficiency requirements are more and more high. The choice of development language has also gradually changed, from C to C++ to C++ + PYTHON or C++ + LUA, and now many companies are using erlang, go, java, c#. At present, it is a blossoming situation.

But if you were to redo an online game server, without considering the compatibility with the company or what is already there, how would you choose? I thought carefully about this issue, there are probably several aspects of this need to consider: 1.

1. Stability of the language (fatal)

The game server is characterized by high load and low latency. So generally the server-side process is with state, once hung means data loss, this is intolerable.

2. Runtime hot more (fatal)

The game server logic is extremely complex and prone to bugs, but it can't be stopped often, so hot shifts to fix bugs are necessary. If a bug occurs, the developer can write code immediately and then fix it with a hot-change, which is not felt by online users at all.

3. Availability of concurrent process support (5 stars importance)

With distributed server architecture, there is bound to be a lot of interaction between processes. Since it is difficult to split the game logic into multiple threads, it is generally single-threaded logic. If there is no concurrent support, a large number of callbacks are bound to be generated and code maintenance will become very difficult.

4. Compilation speed (5 stars in importance)

In c++ development, 30% of the time is wasted on compilation. If compilation is fast or not needed, it will greatly improve development efficiency.

5. Cross-platform (4 stars)

Generally the game server is set up on linux. But the usual development, the use of windows will be more convenient, if cross-platform, development and testing efficiency will be greatly improved, and do not need to get a separate development machine, the local computer can meet the usual development

6. Readability, refactorability (3 stars)

The code can be reconstructed to greatly reduce the difficulty of writing code

7. Whether the library is complete, whether the ecology is perfect (3 stars)

Library is complete, ecological good, you need to build their own wheel is less

8. Unified language with the client (3 stars)

Client-server shared language, the advantages are very obvious, many codes can be reused, logic programmers no longer need to distinguish between the front and back end, both ends can write, a person can complete a function, greatly reducing the time cost of communication.

9. IDE support (3 stars)

Code hints, refactoring and other support, excellent IDE can improve the development efficiency by several times.

10. Language performance (1 star)

Currently server performance is not too much of a problem, but good performance is better than poor performance.

| Languages | C# | C/C++ | Java | Go | Lua | Python | Erlang | | -- | :--: | :--: | :--: | :--: | :--: | :--: | :--: | | Stability | Stable | Easy to hang | Stable | Stable | Stable | Stable | Stable | Stable | Stable | Runtime Hot Update | Support | Difficult to support | Support | Doesn't support | Support | Support | Support | Cross-Platform | Support | Difficult to Support | Support | Difficult to Support | Support | Support | Support | Coroutine | Have | Need to Implement | Bad Support | Support | Support | Support | Support | Compilation speed | fast | slow | fast | fast | no compilation | no compilation | fast | Readability | Good | Fair | Good | Fair | Poor | Poor | Poor| | Game Library and Ecology | Good | Good | Average | Average | Poor | Good | Average| | Client Unified Language | Unity | Unity, UE4 | Not available | Not available | Unity, UE4 | UE4 | Not available | IDE Support | Good | Good | Good | Average | Poor | Poor | Poor| | Language performance | Good | Very good | Good | Good | Poor | Very poor | Poor |

As you can see from the table. 1:

  1. C/C++ has poor stability, slow compilation speed, and fatal flaws
  2. Go does not support hot changes, does not support generics, poor reconfigurability, can not share code with the client, a fatal flaw
  3. poor support for Java concurrency, unable to share code with the client
  4. Lua has few libraries, poor performance, poor code readability and reconfigurability, cross-platform dependence on C/C++, troublesome to handle, and poor ide support
  5. Python poor performance, poor code readability and reconfigurability, unable to share code with clients, poor ide support
  6. Erlang performance is poor, functional style is not easy to get started, ide support is poor
  7. C# .net core is very good in every convenience, but can't share code with UE4

Currently Unity is the hottest game engine, C# server with Unity is a perfect match, basically can not find defects.