Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What advantage does C++ have over .NET when it comes to to game development and apps like VirtualBox

Tags:

c++

.net

This is an attempt to rephrase a question I asked earlier. I'd like to know why C++ seems to be the language of choice for certain thick client apps. The easiest example I can think of is video games and my favorite app VirtualBox.

Please don't close this post I'm just trying to understand why this is the case.

like image 522
Agile Noob Avatar asked Jan 22 '09 16:01

Agile Noob


2 Answers

As a profesional game dev working on AAA titles I can tell you. Reason number 1 is C++ and C will compile and run on any platform say a PS3 or an NDS. Next platform makers only provide robust C libraries to interface with hardware. The reason behind this is C and C++ are free, and not owned by one corporation, and because they were designed for close to the metal low level programming. This means game devs need to know C/C++ which forms a feedback loop. However many devs nowadays make their toolsets in C# or Java, but that's because performance isn't critical.

Now this posture might seem fanatic to most web developers, but games need to process entire slices of complex simulations and rendering upto 60 times per second, few web apps are bound to stay within that latency rate, so the needs are different.And same reason few web services are produced with C++.

However high level AI, and gameplay( the rules ) are scripted because of the development speed increase and ability to fine tune the game. Also because this amounts to about roughly 15% of the resources, so we can splurge here, and let the designers do their job. Also note that coding a fexible rule system would take about the same resources anyways even if done in C++. Oh and not all platforms allow Jit code which would be nice :)

And of course as mentioned memory control, if you use even 1 byte more memory than provided by the hardware, it doesn't slow down like a PC. It crashes. So we love our naked pointers, custom allocators and RAII.

like image 64
Robert Gould Avatar answered Oct 12 '22 22:10

Robert Gould


There are lots of potential reasons:

  • Speed increases either perceived or real.
  • Previous knowledge. There are a lot of people out there that have been programming C++ for 20+ years. Not so with C#.
  • Existing code. It is true that .Net has a lot of capability wrapped up in the framework. Even then it still doesn't compare to the decades of libraries that exist for C++.
  • Cross platform development. C++ is much easier to port.
  • Determinism. I will shamelessly steal from ctacke's answer. He sums it up best, but being able to determine exactly what happens when at a very low level can be very necessary for programming something like a game that is time critical.
like image 44
EBGreen Avatar answered Oct 12 '22 23:10

EBGreen