Why C# XNA When Everyone Wants C/C++

Started by
164 comments, last by Promit 15 years, 1 month ago
Quote:
However, I have some question regarding to which extent you would do this:
I'd use OpenTK as a C# OpenGL binding but on their website they state that calling OpenGL functions in C# is a bit slower that via C++ due to the overhead of transitions from managed to unmanaged code and back (C# binding to driver and back ).

Also, I found this blog where the diagram states that the graphics engine would/should still use compiled (unmanaged?) code.

So, my question is: Would you port the entire engine to C# or the better part of it, leaving the graphics subsystem in C++ (or maybe more generally everything that needs to communicate with the driver many times a frame - like OpenGL calls: draw calls, state changes, binding objects [Texture, VBO, FBO etc.], setting shader parameters etc.)?

I think you should really make a new thread to discuss this, it's way off topic. In brief, yes there is a minor cost to crossing the native/managed barrier, and as such it is often better to do it as little as possible, but by leaving only your renderer in native code you may end up making that transition a lot more than you would if you ported the renderer and only made the transition for the low-level API work (what OpenTK does). It depends. I suggest you create a new thread.
Advertisement
Quote:
Then why do all the big name developers use C++? Or maybe that isn't true? Maybe you can point out some larger development houses that use a different primary language.

Are they a bunch of masochists who like to make things harder for themselves (since C# and other languages are more readable)? Are they just stubborn and set in their ways? There has to be a reason everybody uses C++, and if it is not speed, then what is it?


So I thought I'd jump in on this discussion, and I'm going to preface my response by saying "Save your hate/flame responses about WildTangent for another thread, this thread is about technology, not business."

That being said, I worked for a company called WildTangent for many years. Back when they were a technology company they had an ActiveX graphics engine with a Java interface which was designed to be a flash competitor that anyone could use (we're talking 2000'ish dot-com stuff here.) Our engine, being ActiveX was C++, but all the games were written entirely in Java, a managed language. There were performance penalties for calling through the COM layer, but the rendering on the C++ side, and the game logic on the Java side worked just fine. We wrote a Tony Hawk Pro Skater 2 port "Skatepark Sessions", a "Need for Speed" port, among other games with all the game code in Java... a managed language, and they ran great.

We also solved the C# "issues" around garbage collection and memory management of C++ engine objects when I was there last year. Our C# games ran with ample speed (~1000fps for a racing game with vsync off of course.)

These days, whichever language you choose, I'm pretty sure from personal experience, you can make a viable game with it, from an academic level.

But that's academics, and you're talking "big name developers" which is business. There's development costs which can be offset by using pre-existing company tech, and there's target market issues, where C# doesn't work on PS3 or non-MS devices.

The WildTangent Webdriver as a graphic engine, failed because Microsoft lost the Java war, and XPSP1 made ActiveX objects "scary" to the common user by popping up enough dialog boxes and yellow bars and page reloads to dissuade the user from jumping through all the hoops. From a business perspective, you don't want to write tech, that another company can pull the rug out from under you on. You probably don't want to ship the CLR/JIT interpretor to run your game, in the case that your end user doesn't have the version you need pre-installed. That leaves you with C++.

It's a mature language with the least dependencies on external companies. It's the most portable among devices, and that leaves you with flexibility to target PS3/Xbox360/Wii etc... without too much re-engineering. It makes a LOT of sense as a language of choice for big name developers to use.

Is C# bad to use? Heck no, but in the world of business, targeting more than just XBLA is where it's at.
In these kinds of topics people generally only want to read what they believe. The OP is convinced you have to be a C++ wizard to get any kind of game programming job and several people have backed him up on that. The OP has heard what he wants to and if you make this topic 10 more pages praising C# its not going to change his mind.

As to the topic, I'm not in to trying to create the next super FPS. So whatever "speed increases" C++ has over C# is pretty much overshadowed by the benefits of a managed language.
Quote:Original post by davepermen
Quote:Original post by noe
If company has C++ programmers it can do games for PC, Mac, consoles, handhelds, well for every platform that has C or C++ compier which in practice means for every platform there is.


Except close to any mobile platform, where games have to be in objective-c (iphone) or mostly in java.


Our iphone games are written in C++, with various necessary Obj-C(++) wrappers in order for it to run on the iPhone. The back-end (rendering, gamelogic, network interfaces, etc) are all written in C++. The only exception is when we have to use the Obj-C / NS* objects in order to do something iPhone specific (think finding the path of a file to load). But then that's also nicely abstracted and hidden away.

So, no, C++ does not keep you from working on mobile apps, especially not iPhone :)

Quote:Original post by davepermenjust be aware that c++ on consoles is completely different to c++ on pc's.


Er - what are you talking about? I've worked on consoles, mobile platforms, PC - and the C++ has remained consistently the same all 'round. All that changes is the hardware and the assumptions you can make based on said hardware.


Quote:Original post by capn_midnight
When I was 18, Penn State University no longer cared about C and tried to make me a C++ programmer, and I sucked at that, too. Templates did not exist at this time.


You can't be that old. I remember you posting about college in 2000, so even if you entered school in 97, making you 18 then, then templates still existed at that point. C++ Builder 1 came out that year, and I know for sure that it had template support, and we used gcc with templates for my data structures class that year as well.
This thread's run its course. If you want to keep talking, consider making a new thread specifically about what you're trying to discuss. Remember that C++ vs C# on its own is still off limits.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

This topic is closed to new replies.

Advertisement