App QA
Pricing

Exploring the Advantages of .NET Core for Game Development

This article delves into the features, components, and performance of .NET Core, comparing it to other platforms such as C++ and Mono, and exploring the practical benefits it can bring to game development.

Introduction to .NET Core

(1) What is .NET?

.NET is a collection of various implementations that adhere to the same standard (ECMA), such as .NET Framework, Mono, and the newer .NET Core. C# is one of the languages supported by .NET, and theoretically, any language that follows the Common Language Specification (CLS) can run on the .NET framework.

(2) What is .NET Core?

.NET Core is a general-purpose development platform maintained by Microsoft and GitHub. It is cross-platform, supporting Windows, macOS, and Linux, and can be used for devices, cloud, and embedded/IoT scenarios.

(3) Features:

Automatic memory management, type safety, delegates and lambdas, generics, asynchronous programming, LINQ, and using other unmanaged code such as C/C++.

(4) Components of .NET Core

ü  .NET Runtime: also known as CoreCLR. It is not much different from the CLR of the .NET Framework, with the same process management, GC, and JIT (RyuJIT compiler). However, it has been optimized for server systems. CLR and CoreCLR are updated synchronously, and CoreCLR will dominate in the future;

ü  Framework Libraries: also known as CoreFX. This includes collection classes, file system processing classes, XML processing classes, asynchronous Task classes, etc.;

ü  SDK tools and compilers: CLI tools and Roslyn compiler. They can be obtained through the .NET Core SDK;

ü  .NET App Host: used to select and execute the corresponding runtime, provide component loading rules, and start .NET Core applications. The SDK is also launched through the same program.

(5) Currently Supported Runtime Environments

.NET Core supports various runtime environments, including Windows, macOS, and Linux. This ensures compatibility and flexibility for developers, allowing them to build applications that can run on multiple platforms.

Operating system

Version

Architecture

Windows Client

7 SP1 - 10

x64, x86

Windows Server

2008 R2 SP1 - 2016

x64, x86

Red Hat Enterprise Linux

7.2

x64

Fedora

23

x64

Debian

8.2

x64

Ubuntu

14.04 LTS, 16.04 LTS

x64

Linux Mint

17

x64

openSUSE

13.2

x64

Centos

7.1

x64

Oracle Linux

7.1

x64

Mac OS X

10.11, 10.12

x64

ARM64 and ARM32 are not currently supported.

Differences between .NET Core, .NET Framework, and Mono

(1) The main differences between .NET Core and .NET Framework are:

ü  Application models: .NET Core does not support all application models of .NET Framework; in simple terms, it does not support anything related to Windows UI, such as WPF and Silverlight;

ü  APIs: Many APIs are the same between .NET Core and .NET Framework, but a small portion needs to be modified to be ported to .NET Core;

ü  Subsystems: .NET Core implements a subset of the subsystems in .NET Framework, aiming for a simpler implementation and programming model;

ü  Platforms: .NET Framework only supports Windows, while .NET Core is cross-platform, supporting macOS and Linux;

ü  Open source: .NET Core is open source, while only a read-only subset of .NET Framework is open source.

(2) The main differences between .NET Core and Mono are:

ü  Application models: Mono supports a subset of .NET Framework application models (e.g., Windows Forms) and other application models (e.g., Xamarin.iOS) through Xamarin products. .NET Core does not support these;

ü  APIs: Mono supports a large subset of .NET Framework APIs using the same assembly names and components;

ü  Platforms: Mono supports many platforms and CPUs;

ü  Open source: Both Mono and .NET Core use the MIT license, and both are sponsored by the .NET Foundation;

ü  Focus: Mono's primary focus is on mobile platforms, while .NET Core targets cloud platforms.

No Free Lunch: Microsoft's Profound Meaning Behind .NET Core

(1) Consolidating their power

Since Microsoft acquired Xamarin, they have faced the challenge of maintaining three sets of basic libraries and ensuring platform compatibility. It is quite difficult to do the same thing three times, particularly for a large company like Microsoft. For developers, inconsistent APIs lead to the need for different class library implementations, and code cannot be reused.

To address this, Microsoft is leveraging the design concepts accumulated by the .NET platform over the past decade, incorporating the best of various programming languages and development models to build a high-performance, decoupled, fully modular, and independently self-contained development platform. This platform can be combined with Microsoft's excellent compilation, testing, and team collaboration development tools on different operating systems, making it a crucial product for the future.

As shown in the common image above, the purple .NET standard library part in the middle used to have its own implementation for the three .NET platforms, which will be unified by .NET Core in the future.

However, the .NET Core class library is not yet perfect, and many third-party .NET framework developers have started porting to .NET Core, presenting a great business opportunity for interested parties.

For web developers, the high-performance ASP.NET Core + Kestrel running on Linux is very appealing. Performance comparisons can be found here.

(2) Prioritizing cloud business

Why .NET Core is more suitable for containers and has become a major goal for Microsoft's development

Microsoft's consecutive failures in the mobile and device fields have led former CEO Steve Ballmer and his successor Satya Nadella to focus on cloud business. Financial reports for several consecutive quarters show that Azure's revenue has grown significantly (102% in 2016 Q4, 116% in 2017 Q1), injecting new life into Microsoft's overall declining business.

However, the .NET framework is deeply tied to the Windows platform, making it inherently difficult to be compatible with Linux-based containers.

Container technology, represented by Docker, enables bulk deployment in production environments, creating a lightweight, portable, self-sufficient runtime environment for any application. For more information, refer to the series of articles on coolshell. cn.

To attract more developers and build a more comprehensive ecosystem, developing a cross-platform .NET Core application runtime platform has become an essential part of Microsoft's strategy.

Compared to C++, C# is Experiencing Rapid Development

(1) Starting with language specifications

Language specifications serve as the authoritative source for a programming language's syntax and usage. They are the result of collaboration between academia and industry, continuously driving the development of the language.

C++ originated from C and released its first official standard in 1998 after various disputes. It took 18 years and four standard versions until 2015 to reach its current state.

Under the standards, Turbo C++, Borland C++, Microsoft C++, Watcom C++, Symantec C++, Intel C++, and the dominant g++ and clang on Linux competed with each other, leading to a so-called language "holy war," which made for a tumultuous journey.

In contrast, C# was driven by Microsoft and experienced relatively smooth development. The ECMA standard went through four versions by 2006, with recent updates primarily based on Microsoft's version.

Although frequent standard versions do not necessarily indicate faster language development, many teams still struggle to upgrade or replace their C++ compilers. In terms of development time and frequency of standard formulation, C# and .NET are more stable and consistent.

(2) Embracing open source

Microsoft is not the only dominant player in the C# landscape. Mono was once its biggest competitor (the main contributing team, Xamarin, has since been acquired by Microsoft). Relying on the open-source community, Mono has kept pace with Microsoft and gained a significant advantage in cross-mobile platforms (Unity+Xamarin).

Since announcing the open-sourcing of .NET Core (including C#) in 2014, Microsoft officially released the 1.0 version in September 2016, at a relatively slow pace.

However, it is undeniable that the open-source strategy has promoted the rapid development of .NET Core. More and more people have contributed code, as shown in the following screenshot of the corefx basic library on Github (as of December 5, 2016):

According to official news, about 40% of the performance growth comes from the open-source community. Overall, the development of .NET Core is still very rapid.

Unignorable Performance

The following public evaluation results are provided by http://benchmarksgame.alioth.debian.org/. Specific program functions, codes, and indicators can be found on the website.

(1) Comparison of C++, .net core, mono, and C++ performance in two typical computing tasks: "spectral-norm" and "calculating π":

.net core VS c++

.net core VS mono

 (2) Comparison of multiple languages

13 standard test programs were used, taking the fastest of each program as the base 1, evaluating the time and CPU usage of different languages:

From the first few charts, it is evident that the C (gcc) language outperforms other languages in terms of execution time and actual CPU load, followed closely by C++ (g++). The performance of Ada, Fortran, Rust, and Java is acceptable, with .net core and Go falling into the first and second tiers. .net core is slightly inferior, but the gap is not substantial.

For .net core, the performance gap with C++ ranges between 1.5 and 2 times. The interquartile range difference (box height) is small, indicating that it is relatively stable for most computing tasks. In comparison, mono's performance is significantly worse, with notable differences in various computing tasks, but it is slightly better than the lowest-ranked Node.js.

Development Efficiency and Cost Calculation

(1) Using .net core, efficiency improvements may be reflected in:

ü  Many commonly used basic libraries, such as coroutines, threads, memory pools, locks, etc., do not require separate maintenance.

ü  Consistency between frontend and backend languages, with high reusability, which is very beneficial for anti-cheating measures in games.

ü  Reduced debugging costs, as most game development teams work on Windows and compile and debug on Linux.

ü  Reduced communication costs between frontend and backend, as full-stack engineers don't have to worry about switching languages back and forth.

ü  Lower learning costs for newcomers.

(2) Human cost VS machine cost?

Taking public information as an example, NetEase's mobile game "Peerless Double Pride" uses Unity for the frontend and .net core for the backend, which is said to reduce personnel costs by 30% and increase development speed by 20%. As follows:

Let the data speak and make a simple calculation: assuming there are two teams, the backend using C++ and C# .net core, the cost estimate is as follows:

ü  Production environment refers to AWS's M4.2xlarge (2.3 GHz Intel Xeon® E5-2686 v4, 8G+32G, bandwidth cost not included)

ü  The monthly cost is about $360, assuming self-built data centers can save 50% of the cost, which is $180/month.

ü  Assuming the use of C#, the number of servers increases by 50% (based on the performance estimate above)

ü  Human cost calculated at $38,700 annual salary per person (average cost for NetEase fresh graduates)

Team

Input staff

Number of servers

Human cost

Server cost

Total cost

C++Team

20

100

250000/12*20=416667

116000

532667

C#Team

14

150

250000/12*14=291666

174000

309066

 

As can be seen, the monthly cost of C++ is much higher than that of C#, about 1.7 times.

Considering the actual situation of mobile game development, we assume a development cycle of 6 months, a version operation cycle of 2 years, and 1/3 of the manpower invested during the operation period. The cost of the C++ team is about $1.34 million, and the cost of the C# team is $1.28 million. In terms of cost, C# is still more cost-effective.

Team

Input staff

Number of servers

Human cost

Server cost

Total cost

C++Team

20

100

250000/12*20=416667

116000

532667

C#Team

14

150

250000/12*14=291666

174000

309066

 

At the same time, we have not considered the 20% development efficiency improvement brought by C# and the reduction of machine cost due to Moore's Law. We have also not considered the communication cost brought by the increase in personnel and the salary level of hiring higher-level teams.

Overall, C# is still more "cost-saving."

Returning to Reality: What Practical Benefits can .net core Bring to Development?

(1) Anti-cheating is a very suitable scenario, especially for frontend simulation-backend verification game projects. There is no need to struggle with language porting, model verification, and slow mono virtual machines.

(2) A wealth of general-purpose components and standard libraries can save a lot of time in reinventing the wheel, provided that performance "obsession" is eliminated.

(3) No need to worry about null pointer checks, whether to use class or struct, various memory allocation and recycling issues, and multi-byte string encoding.

(4) Be more confident in handling IO and multithreading, embracing multi-core and heterogeneous computing.

(5) In the trend of larger frontend frameworks, the future will be a world of microservices, lightweight applications, and HTML5 games. It will inevitably favor development ideas and tools with lighter burdens, strong portability, and cross-platform capabilities. In terms of high performance, high throughput, and low latency, .net core is starting to stand out. As shown in the figure below, the performance of asp.net core has already far surpassed Node.js and asp.net 4.

Conclusion

In general, neither .net nor C# are new concepts. Strictly speaking, .net core cannot be considered a groundbreaking innovation.

However, for many C++ developers, it can bring insights into language development, toolchains, patterns, cloud computing, and other aspects, or in other words, provide one of the possible futures, which is already worth our attention.

Latest Posts
1Introducing WeTest UDT: A Tech-Driven Testing Solution WeTest UDT, the Unified Device Toolkit, offers a comprehensive suite of advanced cloud testing capabilities and unified device access solutions for enterprises.
2How To Improve Xbox Cloud Gaming Performance | Overview BOOST YOUR GAMING EXPERIENCE WITH THESE KEY TIPS FOR XBOX CLOUD GAMING.
3Common Issues Concerning CrashSight Integration and Reporting in Windows and Game Engines TACKLING THE NUANCES OF CRASHSIGHT IN WINDOWS AND VARIOUS GAME ENGINES.
4Common Issues Concerning CrashSight Integration and Reporting in Android NAVIGATE THROUGH THE HURDLES OF CRASHSIGHT INTEGRATION AND REPORTING ON ANDROID PLATFORMS.
5Comprehensive and cost-effective, why should you choose WeTest’s Compatibility Testing solution In the face of the global device fragmentation challenge, WeTest Compatibility Testing offers an all-in-one solution that covers a wide range of multi-dimensional software and hardware combinations