Advertisement

Stick with C++ or venture into C#?

Started by September 08, 2013 04:48 PM
19 comments, last by Aspirer 11 years, 5 months ago

Well you could support other os with c# through Mono, but I doubt this to be a good solution.

Since I'm using Mono (altough embedded), I'm interested in knowing what made you reach that conclusion. Can you please clarify?

I certainly wouldn't recommend you switch to C#.

As once you have, you will suddenly start realizing the things that make C++ such a horrifically unproductive language.

In all seriousness, once you've worked in C# for a while ( or even Java ), going back to C++ for many things becomes incredibly painful. The fast build cycle, lack of linker pains and most importantly, sane class libraries are hard to leave behind. As are sensible errors and a much cleaner language syntax.

Advertisement

I would recommend using C# with one warning: Have a plan. If you know ahead of time you know what you're going to do, you'll be able to make the decision to use C++ in those narrow range of circumstances when C# would not be suitable. It sucks to have hundreds of hours into something then realize you're at a dead end.

* C# is inconvenient on your target platform: iOS, Android, Blackberry

* Some third-party library does not support .NET, or some third party tool you want to use produces files in a proprietary format, and the libraries to read the format are not available to C#.

* C# performance, for example, you need very tight control over memory allocations, layout, etc.

You can get around each of these issues if you just have to use C#, and the performance is not likely to be a bottleneck except in the most demanding of games.

I've got something to add about C# and MonoGame: some parts of it are still in development, so you are still dependent on XNA, for example for content building.

Also, MonoGame is a framework, NOT a game engine, so you must search for it.

Since almost all game engines are still made with XNA, your life will be extremely hard to find one.

However, if you want to program your game in C#, I would recommend you Wave Engine (http://waveengine.net).

Use both. I had 7 years professional C++ before my currnet 8 years of C# (not in the game industry). C# is easier to create simple clean code when you don't care about every low-level detail or aren't needing to interact with someone else's low level, non .NET, library. But sometimes you do. So use C++ for that. The last time I hit that situation I created 2 C++ libraries (1 for interacting with windows USB devices and 1 for doing low level audio block management), but then I created a .NET wrapper for each of those using C++/CLI (this took less than half a day to wrap both lirbaries), and then I used those lirbaries in a C# application (where all the other libraries were also written in C#).

C++/CLI is your friend for interating C# and C++ ... but if you like C# and it isn't hurting you, put as much of your logic in C# ... is truly is easier to maintain, primarily because it is more "normalized" and less powerful. So C# libraries tend to follow more common patterns and require less "what the hell was I thinking" moments when you come back to them 3 years later.

Less powerful?

Be careful with the words you choose, as you are reenforcing an already stupid stereotype.
Advertisement

HERE WE GO AGAIN!

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.


Since I'm using Mono (altough embedded), I'm interested in knowing what made you reach that conclusion. Can you please clarify?

Well among the other disadvantages already mentioned above, the user would need to have Mono installed.

Since I'm using Mono (altough embedded), I'm interested in knowing what made you reach that conclusion. Can you please clarify?


Well among the other disadvantages already mentioned above, the user would need to have Mono installed.
That's a non-issue. You don't see things like "I could use Unity, but that relies on Mono libraries." Or "Stupid hundreds of iPhone games that rely on Mono, the end users might not have it." When you build the game you include the libraries as part of the package.

The performance differences between Microsoft's .net libraries and the mono libraries is negligible. Lots of people run benchmarks on them, including the project maintainers themselves. Over the years people discovered the cases when Mono was slower and the maintainers improved their libraries. There will always be slight differences because the products are different, but on the grand scale the minor differences are irrelevant.

Overall there are some quirks and caveats, but mostly they come from people not understanding the costs of built-in features. For example, C# generics take up a little more room than many C++ programmers expect, so generic containers are often surprisingly large to people coming from a c++ background. Iterating with foreach() takes a little bit of memory. Iterator objects with yield returns are often a bit larger than expected for the behind-the-scenes work, and so on. These are not so much because of flaws in the language, they come from the very intentional tradeoff that comes from the safer and generally more productive paradigms.

The tools and language have a small cost in terms of size and performance, but the benefits in terms of more rapid development with less risk of severe bugs typically far outweighs the costs.

Now, my question is for the purposes of starting off on developing games, would I be better served by sticking with C++, something I know more about and is considered the "omnipotent" language by most, or switch to C#, something more modern, less touchy, etc.?

A language is a language is a language. Pop quiz, once you learn a C# or C++ which graphics library are you going to use? What platforms are you writing for? No programming langauge in the world writes code itself. Regardless of which langauge you use, it's not going to make up for sloppy code. In your case, I wouldn't be tinkering with either. You're probably better off using a game engine such as unity.

This topic is closed to new replies.

Advertisement