Reputation: 2335
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.
Upvotes: 9
Views: 1492
Reputation: 2335
Seems to me like this is good summary of the answer:
Upvotes: 0
Reputation: 24561
In the cases you are mentioning, the main reasons are easier access to low-level system API, speed and portability.
Upvotes: 1
Reputation: 69835
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.
Upvotes: 28
Reputation: 37730
There are lots of potential reasons:
Upvotes: 8
Reputation: 67178
For a large set of applications it comes down to speed and determinism.
Native code simply runs faster because you have a compiler that can take it's time to do the best possible job at creating machine language. The only person that has to wait is the developer. Managed code has to go from IL to machine language while running. Getting it done quickly is more important than getting it in the best possible form, because the user has to wait while it's happening. Better speed == better user experience.
Determinism is key in many things (like games) because you'd like to know, exactly, when things that take time are going to happen. When I make a memory allocation or deallocation, it takes time. I'd like that to happen when we're loading up a new game level and no one will notice, not while the user is strafing left getting his ass shot off by his friend in an ultimate death match. A stutter there ends up with cussing and a game controller on the other side of the room. With native code, you explicitly control when these things happen. With managed code, the GC decides when that happens, and there's no way to exactly know when or how long that may be.
Upvotes: 5
Reputation: 421988
Primary reasons might be:
Upvotes: 2
Reputation: 37137
It's easier to make the app cross platform with c++ than with .net (huge advantage in my point of view as you can aim the game to mac users also for example)
Upvotes: 3