Jump to content
  • Advertisement
Sign in to follow this  
Lawtonfogle

C++ or C#(XNA)?

This topic is 3712 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

Outside of the RPG Maker series, I have only created the most basic of games, all of which had not graphics outside of their GUI. As such, I have decided to start preparing to make a few, actually wroth presenting, items to add to my portfolio. I have heard a number of times that C++ is the main language used, I am still debating which to use. While I have much more experience in C and C++ than C#, I have even more in Java, which is quite close to C# compared to C and C++. Also, with C#, I have XNA at my finger tips, taking care of a great burden which I am not sure how to take care of with C++. Being that I still have a good sum of pre-game work to be done before I even get to using a computer (a good deal which is reading some resources I need to finish), this isn't a pressing question yet and I still have plenty of time to decide. What I am hoping to do is to make a simple FPS with a easy to use level editor and at a later point, add some multiplayer support so I can actually test it out with my friends. What I am wanting to have when I am done with the first step is a complete version, but which can have many man-hours(weeks) spent upgrading over time. I'm actually think the first characters will just be cubes which move around, but I digress. Anyways, one last consideration is that I could use Torque game engine, but being I only have the Demo and I don't know the limitations of the Demo or how it even compares to XNA of C++, thus I'm not really considering it. Thanks for any input.

Share this post


Link to post
Share on other sites
Advertisement
I think you'll definitely get a lot of things up and running quicker through C#/XNA. It certainly gets in your way a whole lot less than C++. If you're worried about not knowing C#...don't. It didn't take me very long at all to make the switch over from C++.

Share this post


Link to post
Share on other sites
Well, I've been using both and my answer is... C++. Not only is C++ the industry standard (I'd hazard a guess about you getting more mileage out of C++ than XNA as C++ is multi-purpose whereas XNA is a half-assed game development bolt-on for C#), but it'll make you a better programmer in the long run.

Whilst XNA does a lot of the dull, difficult, boilerplate stuff for you and saves you a lot of time, it comes at a cost. That cost, to me, is the way in which you're forced to structure your code. With C++, you start with a blank canvas and are free to structure things as you please such as define your own gameloop and how and when you want things to happen.

Not only does C# follow a fairly rigid OO paradigm, XNA takes it that one giant leap further and gives you a load of functions which you basically have to use. It gives you a Load(), Initialize(), Update(), Draw() function etc. and the brutally verbose canned comments tell you what you're supposed to put in where... no, I don't want that, I want to do things how and when I want thank you very much. In my experience, it's very clumsy and it often feels like you're shoehorning stuff into places because you think that's the best place for it rather than actually giving careful consideration to design, and all that happens is these pre-defined functions just end up with large amounts of repeating code such as:



spriteBatch.Begin();

spriteBatch.Draw(/*shizzle*/); // Player sprite
spriteBatch.DrawString(/*shizzle*/); // Number of remaining lives

foreach (LoadOfShite los in ListOfCrap)
{
// Draw each LoadOfShite in here
}

...
...
...

// Many lines later...

spriteBatch.End();


Of course, the obvious solution here is to perhaps store everything for the HUD e.g. remaining lives in an object of its own to cut down on repeating code, but then again you're not saving any time as you'd have to do that anyway in C++.

C++ may require more donkey work on your part but at least it gives you that added flexibility. The seeming lack of flexibility in XNA due to this approach made me find stuff that was usually trivial e.g. OO-state management much harder than it needed to be... out goes my lovely C++ OO-state management system and in comes endless ugly, hackish switch statements.

Also with XNA, remember your distribution is only free on PC, and even then you can't redistribute Games for Windows Live components without permission from Microsoft and a publishing agreement. On the 360, you're paying $100 in the US and £60 (~$120) in the UK per year just to be able to run code on your own 360, but it does offer value for money in that you can distribute your games via the Creators' Club with a mandatory charge attached to your games in terms of Microsoft Points. Another issue with XNA is, althoug I've never done it myself, that XNA's floating-point performance running on the 360 apparently leaves something to be desired.

Personally I find XNA gives you a hell of a lot to play with, but equally I find it overrated, verbose and unwieldy. Also, the freely downloadable samples from MSDN are less than impressive for a learner; sure, they do a lot of cool and exciting things, but just look at the code! Basically no comments, everything's so tightly coupled and specific for that particular example that it makes it much harder to extract the concepts from it as it's usually been brutally hacked to work with that particular example and sometimes even uses code that isn't covered in any other tutorial I've seen, and I'll say in general that I've been programming on and off for eight years and I'm still genuinely struggling to follow what's going on in half of them. A class diagram, a proper readme instead of stating the bleeding obvious, even some more useful comments would be nice. I'm not trying to say that C++ game development has nothing but perfect tutorials and everything's great, but if MS are going to trumpet about how great XNA is for game development then they should just back it up with some useful resources to go with it.

In defence of XNA, it does get you off the ground quicker due to the boilerplate stuff being done for you - however would you rather get to your destination quickly and crash the car, or have a slower, more careful journey with an intricate and challenging driving experience? XNA is great for professionals prototyping stuff and rumour has it that's what it was originally designed to do, until MS realised they can shovel it out to the public and make $$$ out of it. I'd rather take longer and use C++ seeing as, if you ever get to use an official console devkit, they're basically all using C or C++. XNA is basically a toy.

IMO C++ is a more useful skill to have if you're intent on making a serious go of programming; people see XNA as being some silver bullet to make game creation easier, but I don't see how it makes anything any easier if it has that horrible shoehorning approach with crap tutorials and examples to boot.

I dunno, I just don't find XNA exciting, cool or rewarding to use. It's the hot ticket right now, I know everybody loves XNA and I'm about to get torched as a heretic, but to me it feels like a typical, poorly designed MS cash-cow and for some reason people are throwing themselves onto the bandwagon.

The choice is, as always, yours. If you want to use XNA because you want to take care of a "great burden" then so be it, but I personally don't find it makes anything a whole lot easier, especially if you're working in 2D, 3D perhaps. I'm just as happy with C++ and SDL, or the Irrlicht engine; both suit my needs perfectly and I've got a completely free distribution model without vendor lock-in.

Share this post


Link to post
Share on other sites
I would love to see your game that, when broken down, does not contain Update(), Draw(), and Initialize() functions of some sort. That's seriously a god awful critique of XNA.

Also, if you're "shoehorning things into place and not thinking about design" that's not XNA's fault. That's your fault for not thinking about design. You can create very elegant programs with their framework. If a given program doesn't do that it's not XNA's flaw, it's the programmer's.

Learning C++ won't make you any better of a programmer than learning C# will. It will just make you a better C++ programmer.

Share this post


Link to post
Share on other sites
Almost all of ukdeveloper's post was a complete load of crap. I don't normally join in on posts like this, but this is For Beginners, and it would be quite easy for an impressionable beginner to get the wrong idea from his post.

Quote:
Original post by ukdeveloper
Well, I've been using both and my answer is... C++. Not only is C++ the industry standard (I'd hazard a guess about you getting more mileage out of C++ than XNA as C++ is multi-purpose whereas XNA is a half-assed game development bolt-on for C#), but it'll make you a better programmer in the long run.


As stated in the post above me, learning C++ does not automatically make you a better programmer. Also, XNA is not any more "half-assed" than SDL or Irrlicht is "half-assed".

Quote:
Whilst XNA does a lot of the dull, difficult, boilerplate stuff for you and saves you a lot of time, it comes at a cost. That cost, to me, is the way in which you're forced to structure your code. With C++, you start with a blank canvas and are free to structure things as you please such as define your own gameloop and how and when you want things to happen.


XNA forces you to do absolutely nothing. If you want, you may make use of the provided Game structure to take advantage of a proven and well tested framework for your game. Otherwise, you can choose to ignore it and create the graphics device on your own.

Quote:
In my experience, it's very clumsy and it often feels like you're shoehorning stuff into places because you think that's the best place for it rather than actually giving careful consideration to design, and all that happens is these pre-defined functions just end up with large amounts of repeating code such as:



spriteBatch.Begin();

spriteBatch.Draw(/*shizzle*/); // Player sprite
spriteBatch.DrawString(/*shizzle*/); // Number of remaining lives

foreach (LoadOfShite los in ListOfCrap)
{
// Draw each LoadOfShite in here
}

...
...
...

// Many lines later...

spriteBatch.End();


Of course, the obvious solution here is to perhaps store everything for the HUD e.g. remaining lives in an object of its own to cut down on repeating code, but then again you're not saving any time as you'd have to do that anyway in C++.


This doesn't even make sense to me. If you're duplicating code, it's because you're a bad programmer, not because your tools are bad. And then saying "oh, XNA is no good because you need to manage your code which you would have to do in C++ anyway" makes no sense either.

Quote:
C++ may require more donkey work on your part but at least it gives you that added flexibility. The seeming lack of flexibility in XNA due to this approach made me find stuff that was usually trivial e.g. OO-state management much harder than it needed to be... out goes my lovely C++ OO-state management system and in comes endless ugly, hackish switch statements.


Once again you aren't making sense. XNA forcing you to use switch statements? What the heck are you talking about?

Quote:
Also, the freely downloadable samples from MSDN are less than impressive for a learner; sure, they do a lot of cool and exciting things, but just look at the code! Basically no comments, everything's so tightly coupled and specific for that particular example that it makes it much harder to extract the concepts from it as it's usually been brutally hacked to work with that particular example and sometimes even uses code that isn't covered in any other tutorial I've seen, and I'll say in general that I've been programming on and off for eight years and I'm still genuinely struggling to follow what's going on in half of them. A class diagram, a proper readme instead of stating the bleeding obvious, even some more useful comments would be nice. I'm not trying to say that C++ game development has nothing but perfect tutorials and everything's great, but if MS are going to trumpet about how great XNA is for game development then they should just back it up with some useful resources to go with it.


The Creators Club website has a metric ton of tutorials, examples, starter projects, free tools, articles, and just about anything else you need to get going on your game. I'd say it's one of the most impressive learning experiences on the internet.

Quote:
In defence of XNA, it does get you off the ground quicker due to the boilerplate stuff being done for you - however would you rather get to your destination quickly and crash the car, or have a slower, more careful journey with an intricate and challenging driving experience?


That's an absolutely terrible analogy on your part. C# (and inherently XNA) is far far safer than using C++ to create your game. It's one of the reason managed languages were invented. So basically, the question rather becomes "would you rather get to your destination quickly and and smoothly, or slowly with a lot of headaches?" You may, of course, choose the latter, but don't expect us to think you've made the right choice.

Quote:
I dunno, I just don't find XNA exciting, cool or rewarding to use. It's the hot ticket right now, I know everybody loves XNA and I'm about to get torched as a heretic, but to me it feels like a typical, poorly designed MS cash-cow and for some reason people are throwing themselves onto the bandwagon.


Once again you aren't making sense. XNA is a cash-cow? Microsoft gives away all of their XNA libraries for free. Sure, you can pay to upload content to your 360, but not only is that not required, the price is so low there is no way Microsoft is making anything significant out of it.

Please, if you are going to bash something, come up with legitimate arguments and try not to sound completely retarded when doing it.

Share this post


Link to post
Share on other sites
Quote:
Original post by ukdeveloper
Whilst XNA does a lot of the dull, difficult, boilerplate stuff for you and saves you a lot of time, it comes at a cost. That cost, to me, is the way in which you're forced to structure your code. With C++, you start with a blank canvas and are free to structure things as you please such as define your own gameloop and how and when you want things to happen.


*sigh*

You don't have to use XNA's Game class.

I see people complain all the time about how the Game class makes the XNA Framework so limiting. It's just a convenience class, there for you to use if you want to get something up in running quickly. It's very limited in terms of flexibility, but it's not supposed to be flexible! It's supposed to be convenient! If it doesn't suit your purposes, you can create window for your game any which way you'd like. You can use Windows Forms (like I do for my map editor), or if absolutely demand control you can go ahead and call CreateWindowEx via P/Invoke.

This applies to the entirety of the XNA Framework: it's all quite seperate and you can use whichever components you want. If you just want D3D9 graphics, you can just use the classes in Xna.Framework.Graphics. Just want the input stuff? Go ahead. Don't want to use the Content Pipeline? Then don't use it.

I'm really getting tired of seeing people spread this kind of misinformation and FUD all over the place.

Share this post


Link to post
Share on other sites
If you don't like XNA, use SlimDx.

If you don't like C#, then use Python or Java... there are numerous better alternatives to C++ these days.

Share this post


Link to post
Share on other sites
After using C# and XNA for a while now, I'd say go for that combination. I get things done so much more quickly than I used to in C++.

Share this post


Link to post
Share on other sites
Quote:
Original post by ukdeveloper
Not only does C# follow a fairly rigid OO paradigm

....

OO-state management much harder than it needed to be... out goes my lovely C++ OO-state management system and in comes endless ugly, hackish switch statements.


Wait.. what?

C# is more OO yet you disregarded OO to create you state management?

Are you familiar with the old robot saying "does not compute"?



C# is no more limiting than C++ and at the same time removes alot of bother from programming.

C++ is the main language used in the industry for two main reasons;
1) legacy
2) consoles

You won't be caring about (2) and in the PC world (1) just involves you finding a wrapper to get at most of the libs out there.

Also, you can learn C# now and always learn C++ later is needs be; and before everyone starts jumping up and down about 'getting a job' (which, the OP never mentioned, some peope do this for fun you know so what the 'industry' does really doesn't matter) one of the guys I work with is mainly a C# programmer and he came straight out of uni and into a job working with C++ in the games industry. He knew some C++ but he was no means a master (and between myself and others has learnt a fair amount) thus my point is even if people do want to get into the industry you don't have to be a guru to do so.

Hell, most of the guys I work with code C++ C-style (as in variables delcared up front, that sort of thing) so once again are by no means C++ gurus either.

In short OP, go with C#.
As to if you use XNA or another library with it is another matter completely but as someone who knows C++ and has recently started focusing his time away from work on C# I can tell you I wish I could use C# for games because it's that much easier and quicker to get things done.

Share this post


Link to post
Share on other sites
Quote:
Original posts by the other posters in this thread
... taking the blowtorches to me [sad] ...


Well, I have given XNA more than a fair chance and I hate it; however, my primary programming motivation isn't actually games so this isn't a serious issue for me. Each to their own, as the phrase goes. If it's the best thing since sliced bread for you then I wish you all the best of luck and enjoyment in using it.

For the record, I think C# is great as it stands. It's a real joy but I can't say the same about XNA from personal experience.

To top it all off, I enjoy using C++. Not C, though.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!