Sign in to follow this  

C # / C++ Not A Debate But Your Advice / Experience

This topic is 4136 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

For someone looking to build casual games, would you recommend C# pr C++? I'm not looking to declare one language the winner or anything like that! :) By casual games, I mean relatively simple 3D puzzle games...maybe a simple driver aimed at children. No Project Gotham Racing or Halo. ;) I've got enough of a handle on C++ that I could probably finish a game in C++. I understand most of books like Effective C++ and have strived to learn "proper" and modern C++. But I've been hearing more and more about C#. I would really appreciate it if you could tell me your opinions and a bit about any experience you might have with either language. I'm not sure why, but I'm worried that if I move to C#, I'll never finish learning C++. Do I need to master C++? I would like to work for a game developer some day (that's probably a vote for C++), but I would prefer to make casual games by myself or as part of a small independent team.. In the end, it won't matter too much as the things I'm struggling with have more to do with structuring my game engine moreso than language specific issues. But it seems to me that C# would be fast enough (don't know much about how it compares with C++ these days) and would save me some time and headaches. Thank you, I look forward to your responses! :)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Personal Opinion/Situation (Your Strategy May Vary):

learn both. i've come to the conclusion that i'll probably be at best always a hobbyist game developer, and that my meat and potatoes is windows programming. even though C++ is still dominant in windows development, C# is coming strong and i realize now that i must learn both to remain competative in this workforce.

my primary concern is work, having a stable job, putting food on the table, etc. so if i was a serious game developer, i would still choose C++ (the jobs are still primarily dominated by C++, though i looked at some job listings recently and saw a number of C# ones too so it's coming along). as a hobbyist, i'm probably going to try fiddling with both.

Y-Go

Share this post


Link to post
Share on other sites
Quote:
Original post by Low Bias
For someone looking to build casual games, would you recommend C# pr C++? I'm not looking to declare one language the winner or anything like that! :)

I would definately recommend learning C# and starting with that building some small casual games. You can always learn C++ later on down the road if you wanteded to go in that direction. Learning the design, algorithms, and generally how to solve game-related problems is much much more important than something like a language choice. I've personally used C++ and C# both in commercial and independant development, and if I were to build casual games I would target C# and the .NET platform right now.

There are pros and cons to all choices. I mean when using a the languages on the CLR you have the .NET framework dependency, your API dependency (MDX/XNA), etc. It is also much faster to develop with, less error prone, etc.

Share this post


Link to post
Share on other sites
I too have used languages both in commercial projects and i would go for C# in your case. The development time is a lot shorter and .Net Framework is a breeze to work with. However, i haven't found any great C#/OpenGL ports, however Managed DirectX + C# works great. So if you plan to use OpenGL i would stick to C++. Otherwise, C#;

I do recommend to keep learning C++ as well, if you plan to work as a game developer, because most companies still require experience with it.

Greetings.

Share this post


Link to post
Share on other sites
Quote:
Original post by Limitz
However, i haven't found any great C#/OpenGL ports.

Out of curiosity (as I have never used it myself) what did you find bad with the Tao.OpenGL library? I have actually heard good things about it and I believe there is one commercial C# game that uses it.

Share this post


Link to post
Share on other sites
I second... er, 12th... C#. With Tao.OpenGL or MDX there is no reason to burden yourself with C++ at this point, unless you feel you need to learn C++ (which, to be fair, is a very real possibility).

I do recommend learning C++ at some point, though. It isn't going anywhere, and most places use it. But it really doesn't offer anything beyond that offered by C# to the average hobbyist developer in terms of performance or features, beyond a LOT of useful libraries when you get into more advanced stuff.

Share this post


Link to post
Share on other sites
Quote:
Original post by Saruman
Quote:
Original post by Limitz
However, i haven't found any great C#/OpenGL ports.

Out of curiosity (as I have never used it myself) what did you find bad with the Tao.OpenGL library? I have actually heard good things about it and I believe there is one commercial C# game that uses it.


Well, I believe i do remember trying it a long time ago, but i coulnd't get it to compile, but i checked it just now and it really seems very mature. So I guess the point of C# not in combination with OpenGL is off the table :)...
Sorry for that :)

Greetings.

Share this post


Link to post
Share on other sites
In my experience, its easier to write, maintain, and debug a MMORPG written in C# then it is to write, maintain, and debug a MMORPG written in Procedural-C.

Share this post


Link to post
Share on other sites
Quote:
Original post by Thevenin
In my experience, its easier to write, maintain, and debug a MMORPG written in C# then it is to write, maintain, and debug a MMORPG written in Procedural-C.


The OP was wasking about C# and C++, not C# and C.

Anyway, from my experience, the differences betweeen C++ and C# are not as big as most people make them out to be. One isn't always faster, one isn't always easier to work with. Since you already have a base in C++ I'd say keep going with that and learn other langauges on the side. It's great to know more than two langauges and once you learn your first, the rest are a lot easier.

Share this post


Link to post
Share on other sites
I'm going to second the "learn both" post. In reality, you should learn a bunch of languages, and then decide for yourself which one suits a particular problem. That's what being a good software developer is all about. You will not get far professionally or intellectually if you limit yourself to just one language. Even if you end up working mostly in one language, like C++, your knowledge of C#/Java/Python/Lisp/whatever will make you a better C++ programmer, because you'll be able to borrow and adapt ideas from other languages. Being a good programmer is about learning the basic principles behind algorithms and data structures, and being able to adapt those to whatever language you are working with. You shouldn't bother trying to become a guru in one particular language until you're comfortable with the idea that you can quickly pick up any new language that comes your way.

All that aside, I'd say C# is probably a little cleaner and easier to learn than C++, but C++ has a wider variety of good libraries and game engines that you can use.

Share this post


Link to post
Share on other sites
Many people argue that if you're planning on making a cross-platform game, C++ is the way to go. This, however, isn't true, for you can use Mono and the Tao Framework to write games for a lot of platforms, taking advantage of OpenGL hardware rendering. It's actually really neat because with Mono, you don't even need to recompile between platforms. There's also, of course, SDL.NET if you're an SDL fanboy.

Another point to make is the recent announcements of Microsoft going global with the XNA Framework. You'll be able to write games for Windows (using .NET and Managed DirectX through XNA), and then easily push them to the Xbox 360. Very neat stuff....

Share this post


Link to post
Share on other sites
Quote:
Original post by Limitz
I too have used languages both in commercial projects and i would go for C# in your case. The development time is a lot shorter and .Net Framework is a breeze to work with.
Can you, or anyone, please explain this. Why, specifically, is it faster to develop with? I've tried using C# and found it to be noting but a pain to work with.

Share this post


Link to post
Share on other sites
Quote:
Original post by Grain
Quote:
Original post by Limitz
I too have used languages both in commercial projects and i would go for C# in your case. The development time is a lot shorter and .Net Framework is a breeze to work with.
Can you, or anyone, please explain this. Why, specifically, is it faster to develop with? I've tried using C# and found it to be noting but a pain to work with.


Care to be a little more specific with "pain"?


13 reasons why C# is faster to develop with (in my experience, ymmv):

1 - C# is consistant. Things tend to follow consistant syntax, meaning I spend less time remembering (or looking up) wether the function I want follows C style, C++ style, takes strings, or char *'s or what. This becomes more important working in teams, since everyone will tend towards being more consistant if the language is.

2 - Garbage Collection. Less time spent doing or designing around ownership management, which is vital to a well written app.

3 - Better text manipulation.

4 - WinForms > win32. Easier to use, event system is more natural to program with.

5 - Syntax is better defined. C++ has truckloads of compilable syntax which yields undefined behavior (or worse). C# doesn't. Further, a good portion of valid, but incorrect C++ code (mistyped pointers, anonymous objects vs 0nary function, scoping issues, ...) isn't possible in C# or caught as a compile time error.

6 - MSDN. All of the standard library, all together, all consistantly documented. SGI's STL page is okay, and boost's is okay in spots, but they're apart, and they're not consistant.

7 - First-ish class delegates. boost::function is good, but far too much code still requires crappy function pointer syntax and stuff to circumvent its awkwardness.

8 - No Templates. Sure, they're useful to have, but generics work for most everything; better yet, the gnarly looking C++ template error messages are replaced with something a little less tedious to wade through.

9 - No (common) buffer overflow/overwrite bugs. Such a pain to track down in C++.

10 - Standard library breadth (threading, diagnostics, serialization, regexes, networking, xml, reflection ...); Sure boost/... have some of these, but not standard and they generally don't interoperate with other standard library or language bits as well as in C#/.NET

11 - Intellisense. The one in 2k5cpp sucks compared to 2k5cs!

12 - Unicode by default. Working with unicode in cpp is a pain!

13 - No .h/.cpp pre-declaration BS. The last thing I should be thinking about while trying to use code is what order I need to declare it in.


Share this post


Link to post
Share on other sites
I've used both languages for a long time (C# since it was usable by the public). The main things that get me:

C# doesn't have "annoying parser hang-ups":
- You don't need to forward function or class definitions.
- Header files are totally gone (due to a much more well defined grammar hierarchy), removing all of the noticable compile time slow-down. No more worrying about making precompiled headers.
- There are no macros or complex preprocessor to hamper intellisense functionality or readability.
- Nobody I know writes their own templated classes unless they're writing a collection class. C# has the slightly more limited (but better geared toward collection class use) 'generics'. Everyone knows that C++ templates confuse the hell out of parsers and spit out absolutely horrible essay-length error messages when they compile incorrectly. Generics are much nicer about both.

C# automatically handles tedious memory management, which is much more of a benefit than many people will admit. C++/CLI can also use the same garbage collection system.
- Even obsessive compulsive experts will make tiny mistakes in C++ that will take days to track down. The only mistake that I've seen in C# that took longer than a minute to fix out was an unintentional reference copy.
- If you pass data to another function, will that function copy it?
- Will you reference count or deep copy?
- Who is responsible for cleaning up dynamically allocated objects?
- How will you track memory leaks?
- Are your functions reentrant, or have you "optimized" them by changing local variables to be static?

C# folds the -> and :: operators into the . operator, which is something that should have been done in C++ since only one of them is legal in any given context.

C# handles the delegate situation where Native C++ falls on its face. (C++/CLI can use these delegates using almost identical syntax.)

VS2005 allows for symbolic search and refactoring in C#, which is simply the most powerful tool imaginable when working on a huge codebase with dozens of other programmers.

The rest of the C# benefit is mainly due to the .Net class libraries, which you can use from C++/CLI.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I write casual games every now and then, and I use C++ for it. Not because it's easier, not because it's harder, not even because it's faster.

C++ might be marginally more difficult, but I feel that's a small price to pay for a bigger potential market. The simple fact is, not everyone has the .net framework installed, and they will not, and I mean WILL NOT, hunt around for huge extra runtime files just to be able to try out a game. The casual game market is a jungle, and C++ offers the advantage of being able to package the whole game in a neat self-contained package, that does not require elaborate third-party frameworks to be installed on the user's machine. Maybe this will change, and maybe soon everyone will have the framework pre-installed - but we're not there yet.

If you had asked about business apps, I would have said C#, or maybe Java, if that were one of the options...

Regards, Anonymous Poster

Share this post


Link to post
Share on other sites
Quote:
Original post by Telastyn
Care to be a little more specific with "pain"?
The fact that classes MUST be references and structs MUST be value types. Why? That’s such a needless restriction and just adds complication. The copy constructor has to be hand written EVERY TIME. I Can't overload any of the assignment operators. Boxing and un-boxing. All member functions MUST be defined inside the class body. No multiple inheritance. Every member’s access level must be individually declared. .Net doesn’t have a set class. OpenGL is a pain to use

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Nypyren
C# folds the -> and :: operators into the . operator, which is something that should have been done in C++ since only one of them is legal in any given context.


I disagree with this item. I think it increases readability because, as you say, only one of them is legal in a given context. So, just by taking a quick look you instantly know what context it is, without even having to think about it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Nypyren
C# folds the -> and :: operators into the . operator, which is something that should have been done in C++ since only one of them is legal in any given context.


This is not entirely correct [grin] as with std::vector<std::vector<int>::iterator>::iterator.

I agree with everything else you said. The main advantage of C# is, in my opinion, garbage collection, which makes the language extremely fluid. You can go and change almost anything in your code in any way you want without risking anything past a compiler error, and that is extremely reassuring when using agile programming.

Share this post


Link to post
Share on other sites
If you plan to get a job in the game industry, I think it's worth learning both. C++ is still the most used language for the core development, but I see more and more companies asking C# skills for tools development.

Regarding the development of commercial casual games as an indie, I evaluated C# for the same exact reason, so here are some ideas...

- Language
It's fine. C# is more powerful than C++ for certain aspects (garbage collector, delegates, introspection...) and less for other (generics are not as powerful as templates, the CRTP idiom is not possible, lacks multiple inheritance...), but this is not relevant because in terms of productivity the two languages are equivalent. It's not like comparing Assembly to C: with C# and C++ your productivity really depends on your experience with the language.

- Performance
C# programs are slower than C++ programs (especially if you use Mono), but fast enough for a casual game and of course things will get better in the future.

- Library support
The .Net/Mono framework easily beats the C/C++ standard library and this can save a lot of time (you have to write less code and evaluate/learn/test/integrate less third party libraries).
Thanks to Tao and MDX the fundamental libraries necessary to develop casual games are there.

- Deployment
So far there aren't native C# compilers, so you need a managed runtime and the choice is between .Net and Mono.
If you choose .Net, you'll be limited to Windows (ok... also X360 in the near future). On Windows, if .Net is not already installed, it's a 23 MB extra download for your customer.
If you choose Mono you have a chance of being cross-platform (Windows, OSX, Linux). With Mono you can precompile all your assemblies in an exe (with the mkbundle tool). For license reasons you can't embed in the exe necessary libraries such as mscorlib, glib, etc..., but you can still package them in your installer instead of requiring a separate download. The added wheight for your installer will be 2 MB or more (depending on how many third party libraries you use).

My conclusion?
Speaking about language, performance and libraries, C# is ok and I can't see any drawback with respect to C++. In the end it could be even more productive than C++, considering the massive standard library.
Unfortunately the deployment is a big issue. Keep in mind that for the success of a casual game, keeping the download size small makes a lot of difference. For small I mean around 5 MB, especially if the game is a puzzle. There are successfull casual games requiring big downloads (Tribal Trouble for example is 30 MB), by they are the exception, not the rule.
Forget about asking your customer to download extra packages such as the .Net Runtime or the latest DirectX. They're more likely to download your demo, realize that it doesn't work, throw it in the trash bin and insult you for wasting their time.
Personally I think that .Net will be an option in two or three years, when Vista will be on every pc with the .Net runtime preinstalled. Meanwhile Mono is a good alternative (and the only option on OSX and Linux)... Those extra 2+ MB in the installer will hurt a bit, but it's not a big deal since internet connections are getting faster.

Just for the record... I evaluated Java for the same reason. It's more or less the same scenario: asking the customer to download the J2SE runtime is not an option, but you can create a (big) native executable with GCJ that once compressed in the installer will add more or less 1.5 MB. The only difference is that on OSX there is a Java runtime integrated in the OS, so you don't have to use GCJ for the Mac. Considering that for many casual games developers more than 50% of the income comes from OSX users, looks like an option to investigate further.

Will

Share this post


Link to post
Share on other sites
Quote:
Original post by Telastyn
13 reasons why C# is faster to develop with (in my experience, ymmv):


For C#

Another reason, is the ease of building DLL's in .NET. Its so freaking easy to build DLL's, which leads to developers more readily breaking thier code into resuable objects. With C++, building a DLL was not trivial, and building COM objects was just a pain in the ass. You really don't have to do anything special to create a DLL in .NET. Just create an library project, and start coding. It can not get any easier the that.

Something no one has mentioned about C++ yet... DirectX 10 is non managed, so more then likely it will be best to just use C++ (Although you can write wrappers to allow DirectX 10 to work with .NET apps. MDX Info already has! In my opinion for the average hobbyists, its over kill to force DirectX 10 into a managed world).

- Bill

Share this post


Link to post
Share on other sites
Thank you all for yoru considered response. This is really helpign with my decision. I'm sure there are others that are getting value from this discussion.

There are so many great reasons to go with C# for now (for me). I've just bought into the whole "almighty C++" thing that I can't shake it! :) At the end of the day I would rather program for myself, but I wouldn't mind working for somebody like Bioware someday [soon :)]...they're here in Edmonton. Not necessarily on the engine, even on tools, etc.

I love C++ and am fairly proficient at it. I don't doubt it's power and presence / importance. I just find myself working on, and worrying about the subtleties of C++ more than I'm worrying about how to structure and build my game. I don't doubt that it's because I haven't mastered the language, but maybe I should try something a bit more efficient / resistant to...well...mistakes? As long as it's OO, I'll be happy.

Would it be a mistake to wait to further my C++ after I've gotten a good handle on C# and got a few games finished? Are the ideas / concepts transferable? They would seem to be...

Share this post


Link to post
Share on other sites
Quote:
Are the ideas / concepts transferable?


Yes. The concepts are definately transferable, and, to be honest, starting with C# or Java will probably make you a better C++ programmer. It exposes you to good OO design, which you will carry with you to C++.

Share this post


Link to post
Share on other sites
Quote:
Original post by smitty1276
Quote:
Are the ideas / concepts transferable?


Yes. The concepts are definately transferable, and, to be honest, starting with C# or Java will probably make you a better C++ programmer. It exposes you to good OO design, which you will carry with you to C++.


That makes sense in the way C# tries to force you to follow certain principles.

Any recommendations (I'm on a roll :P) on a good book to learn good OO practices using C#?

Share this post


Link to post
Share on other sites

This topic is 4136 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this