Sign in to follow this  
Intrawebs

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

Recommended Posts

Intrawebs    100
For starters I've been a .net developer since the 1.1 framework. Everything from web apps to console apps, using C# and vb.net (ick). Also, I took C/C++ at a Uni many years ago. I'm looking at getting into game dev. So that leads me to the conundrum below... I've seen threads that suggest new comers to game dev to learn XNA and C# as their way into programming games. I find this very confusing. Looking at the job postings for Bungie, ArenaNet and Blizzard, they all want extensive C/C++ skills. The only mention of C# may be in regards to support of their web based technologies (not games). So, when the big shops want C++ why are many here in these forums recommending XNA and C#? There are more platforms than just WinPC and the XBox. Or am I wrong and the majority of shops are only doing WinPC and XBox dev these days?

Share this post


Link to post
Share on other sites
Imgelling    222
I recommend XNA because C# and XNA are pretty easy to jump into. Even on the GameDev.Net latest news there is a story about a person who knew little of C# and nothing of XNA and made a block destroying game in a very short period.

http://www.gamedev.net/community/forums/topic.asp?topic_id=526722

Being able to make games and sell them on the 360 is just a bonus. Plus you can make games for a zune. Sure there are more systems out there than the PC and 360 and zune, but with 1 framework, you can code it once and basically (there would be a few changes, no keyboard on 360 or zune, smaller screen on zune, etc) compile and distribute on 3 of them.

But that is why I recommend it. Of course, I am not looking to get a job at Bungie/Valve/iD/etc. I would rather work for myself. But that is just me.

Share this post


Link to post
Share on other sites
Promit    13246
Any number of reasons.
* Most people are not learning with the sole goal of scoring a game development job, even if that is an interest.
* C#/.NET/Python/etc are important productivity tools, and good to know even if you are working in the industry proper. My former employer was moving all their tools over to C#. Civ IV is half Python code.
* Most employers value ability and demos are an excellent indicator of ability -- this is well known. It's a hell of a lot quicker to build said demos in an environment like XNA.
* Nowhere is it written that because C++ is The Industry Language (tm), it has to be the first and only thing you know. It's a much more rewarding path, I think, to learn to build a game using C#/XNA, and then go back and learn all the details and irritations that doing it all yourself in C++ can involve.
Quote:
There are more platforms than just WinPC and the XBox. Or am I wrong and the majority of shops are only doing WinPC and XBox dev these days?
Well, the Playstation 3, the Wii, the PSP, and DS are all still relevant. Mac and Linux aren't, for better or worse. But there's a lot more to game development than simply knowing how to vomit out C++ code. Yeah, you'll almost certainly need it to get a job, but what good are you to an employer if you claim to know C++ but have no evidence that you know much of anything about actually puttinga game together?

Share this post


Link to post
Share on other sites
Intrawebs    100
Quote:
Original post by Imgelling
Sure there are more systems out there than the PC and 360 and zune, but with 1 framework, you can code it once and basically (there would be a few changes, no keyboard on 360 or zune, smaller screen on zune, etc) compile and distribute on 3 of them.


Sure, for now. One thing I've never liked about MS technology is that it only works/runs on MS technology. If one takes the route you recommend, then one day may come when they are job hunting and don't have a more generic game programming skill set like C++ to land a job somewhere that is more system/framework agnostic.

Also, this still doesn't really address the issue of game shops job postings wanting C/C++ vs. C#/XNA.

Share this post


Link to post
Share on other sites
PolyVox    712
Because the principles of programming (understanding logic, etc) as as important as knowing ny particular language. Languages like C# make it easier too learn these principles. People can then go on and learn C++ is they wish.

At least, that's the theory. To be honest I'm glad I learnt C++ first because otherwise I doubt if I would have had the motivation to learn C++ as it is so much more difficult to get stuff done quickly.

Share this post


Link to post
Share on other sites
Imgelling    222
Quote:
Original post by Intrawebs
Also, this still doesn't really address the issue of game shops job postings wanting C/C++ vs. C#/XNA.


Yeah, I realized that after I wrote it. Edited it a bit, then saw your post.

Share this post


Link to post
Share on other sites
jColton    134
My preferred language is c++. The truth is that knowing multiple languages never hurts, and they each have their uses.

I find that I do my major projects in c++ but I tend to do my tools and editors (quick things I throw together) in C#.

Share this post


Link to post
Share on other sites
Bru    100
Quote:
Original post by Telastyn
Because C++ sucks.

well,it's only less comfortable than c#,seeing stuff like LPDIRECT3DDEVICE9 is hell annoying to read and remember as a developer,but in the end c++ games are faster than c# games and mostly we only care for the result.

Share this post


Link to post
Share on other sites
swiftcoder    18426
Quote:
Original post by jColton
I find that I do my major projects in c++ but I tend to do my tools and editors (quick things I throw together) in C#.
QFE - while you may prefer to write your engine in C++, or have a pre-existing engine, C++ is a truly horrible language with which to write GUI software. Something like C#'s .NET, Apple's Cocoa/Objective-C, or Python/wxWidgets is a much quicker way to get your tools/editors up and running.

Also keep in mind that being highly proficient with scripting languages is essential, in any programming field. You are going to need to write a lot of scripts over time, for format conversion, build systems, data export, etc.

Scripting languages are also useful for even smaller tasks as well - the other day I was given a homework problem, with the following sub-problem: find the summation of 100000/sqrt(i), for i=1,2,...,10000. Sure, you can solve it through integration, but a single line solution at the python prompt is a little quicker: sum([100000/math.sqrt(i) for i in range(1, 10000])

Share this post


Link to post
Share on other sites
Promit    13246
Quote:
Original post by Bru
but in the end c++ games are faster than c# games and mostly we only care for the result.
And this is precisely the kind of blatant falsehood that is downright dangerous in these forums, and which I and several other moderators (along with any number of long time members) have been working to shut down.

Even if we accept the basic premise that C++ code has the potential to be faster, what the hell does it matter to someone just starting out that an experienced professional developer (or more likely a team of them) can eke out slightly more performance in the end? It doesn't, and you do a disservice to this community when you say things like that.

On the bright side, there are lots of people around to correct these problems, so there's no worry of someone making the mistake of believing you.

Share this post


Link to post
Share on other sites
Telastyn    3777
Quote:
Original post by Bru
Quote:
Original post by Telastyn
Because C++ sucks.

well,it's only less comfortable than c#,seeing stuff like LPDIRECT3DDEVICE9 is hell annoying to read and remember as a developer,but in the end c++ games are faster than c# games and mostly we only care for the result.


Execution speed is only one trait of software. And not exactly something C++ will guarantee you over C#.

Implementation speed is an important aspect. Readability directly impacts the maintainability, number of bugs, and ease of use by new/different developers.

Who cares if it runs fast if it took forever to write and is buggy?

Share this post


Link to post
Share on other sites
scottrick49    455
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?

Share this post


Link to post
Share on other sites
Don't quote me on this. I've never actually worked in game development and so I can't say for sure. But, I'd wager it has something to do with massive code bases all written in C/C++ that are incompatible with newer languages like C#/Python.

Porting large, existing code bases is no quick and easy task. To that I can attest and I imagine it is a large part of the reason C/C++ are still so widely used.

Share this post


Link to post
Share on other sites
swiftcoder    18426
Quote:
Original post by scottrick49
Maybe you can point out some larger development houses that use a different primary language.
Eve online is largely written in Stackless Python - I know it is a tired example, but the fact remains that a very successful commercial MMO is written in an interpreted language.

In general the MMO crowd seem to be a little ahead of the rest of the industry, in terms of language adoption, but this is likely because they are forced to - writing distributed network simulations is hard, and modern languages have evolved many tools to help with this: just look to Google (Python), Yahoo (Lisp) or Microsoft (.NET).
Quote:
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?
Don't forget that there was a time when C++ was considered far too high-level and slow to be useful for game development (vs C) - and there was an even earlier time when the same was said about C (vs assembly language).

There are many barriers in the way of a large company switching to a newer language. Legacy C++ code, programmers already experienced in C++, familiarity with tools and build systems, etc. These are typically not a factor for new developers, so you have the chance to take advantage of newer languages and tools, which may give you that extra edge needed to succeed.

Share this post


Link to post
Share on other sites
Bru    100
Quote:
Original post by swiftcoder
Quote:
Original post by scottrick49
Maybe you can point out some larger development houses that use a different primary language.
Eve online is largely written in Stackless Python - I know it is a tired example, but the fact remains that a very successful commercial MMO is written in an interpreted language.

In general the MMO crowd seem to be a little ahead of the rest of the industry, in terms of language adoption, but this is likely because they are forced to - writing distributed network simulations is hard, and modern languages have evolved many tools to help with this: just look to Google (Python), Yahoo (Lisp) or Microsoft (.NET).
Quote:
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?
Don't forget that there was a time when C++ was considered far too high-level and slow to be useful for game development (vs C) - and there was an even earlier time when the same was said about C (vs assembly language).

There are many barriers in the way of a large company switching to a newer language. Legacy C++ code, programmers already experienced in C++, familiarity with tools and build systems, etc. These are typically not a factor for new developers, so you have the chance to take advantage of newer languages and tools, which may give you that extra edge needed to succeed.


i doubt c# will replace c++ as the main gaming language, its not all about speed but also the fact that c# is bound to windows and the worst : you can decompile c# applications into their source code, and that's something you dont want.

Share this post


Link to post
Share on other sites
Imgelling    222
"but also the fact that c# is bound to windows"

That is not a fact, http://mono-project.com/Main_Page

Edit:
there is also
http://code.google.com/p/monoxna/
which would take xna code and allow it to be used on other platforms. Though I am not sure how far along it is. The last update was February 21st.

Share this post


Link to post
Share on other sites
swiftcoder    18426
Quote:
Original post by Bru
i doubt c# will replace c++ as the main gaming language, its not all about speed but also the fact that c# is bound to windows
C# hasn't been bound to windows for a long time now - I occasionally use Mono on the Mac.
Quote:
and the worst : you can decompile c# applications into their source code, and that's something you don't want.
This is one of those myths you see thrown around regularly, which has no factual basis whatsoever: any language can be decompiled, and a decent programmer can read raw assembly code without much trouble. If your security, etc. relies on obsfucated source code, it is worth exactly zero.

Share this post


Link to post
Share on other sites
jpetrie    13102
Quote:

i doubt c# will replace c++ as the main gaming language, its not all about speed but also the fact that c# is bound to windows and the worst : you can decompile c# applications into their source code, and that's something you dont want.


Wrong. C# is not "tied to Windows' in any way, shape, or form -- no more than C or C++ are. C#, like C, like C++, is standardized by a third party body (ECMA, in this case). Microsoft has people on the advisory board for the standardization committee, but they do the same for C++ as well. So, that's a wash.

Thus, you have non-Microsoft implementation of the CLR and supporting toolchain for platforms other than Windows (see Mono). Just like C++.

Absolutely nothing about C++ makes it "magically portable" to platforms other than Windows and hardware other than PCs. Somebody has to put the sweat and elbow grease into porting the infrastructure. C++ only looks more portable because it's been around much longer (especially since it could piggyback on C in its early years). Given a few more years there's no reason C# wouldn't be just as widespread.

As for your decompilation concerns, they are slightly valid. Sure it's less than ideal to be essentially giving away your code, but there are obfuscation programs that can make it a little harder to read, if you care. Theoretically on fixed systems (consoles), one could pre-JIT (like ngen.exe) the CIL to native code, too. Again -- if you care.

Large developers typically have the legal backing required to litigate you into oblivion should you steal their code (remember, just because a thing is possible or easy doesn't make it lawful or morally correct). So that may be less of a concern for them.

And security? Security via obscurity is no security at all. It should be obvious that having the reverse-engineered C# from a tool like Reflector isn't going to be a big deal to hackers who can already crack native programs before they even hit store shelves.

Do some research next time.

Share this post


Link to post
Share on other sites
Bru    100
Quote:
Original post by Imgelling
"but also the fact that c# is bound to windows"

That is not a fact, http://mono-project.com/Main_Page

tbh even if you can use this mono thing to run .net stuff on non windows systems, you can still say c# is bound to windows. if you make a serious and big game i am not sure you want to make the clients install stuff like that(beside i am not sure its if its very legal advertise mono with your game this way.
dont think i am a complete idiot, i am not talking with confidence just what i belive might be true.

Share this post


Link to post
Share on other sites
Imgelling    222
Don't you have to install the .Net Framework for Windows too?
Don't you have to install the correct version of DirectX9 (according to the SDK the programmers used) to play those games?


Share this post


Link to post
Share on other sites
swiftcoder    18426
Quote:
Original post by Bru
tbh even if you can use this mono thing to run .net stuff on non windows systems, you can still say c# is bound to windows. if you make a serious and big game i am not sure you want to make the clients install stuff like that
How is it any worse than requiring your windows customers to install the .net runtime?
Quote:
(beside i am not sure its if its very legal advertise mono with your game this way).
Please do us all a favour, and take the time to research the topic a little. It is perfectly legal to distribute mono with an application.

Share this post


Link to post
Share on other sites
Drilian    1067
Quote:
Original post by Bru
tbh even if you can use this mono thing to run .net stuff on non windows systems, you can still say c# is bound to windows. if you make a serious and big game i am not sure you want to make the clients install stuff like that(beside i am not sure its if its very legal advertise mono with your game this way.
dont think i am a complete idiot, i am not talking with confidence just what i belive might be true.


Okay. So, let me get this straight:

You can run .net code on non-Windows systems, but you don't count it because...uh...because installers might not want to install the mono runtime?

I think, if you're not confident about what you're saying, it's better to just NOT SPEAK than it is to keep spreading falsehoods and incorrect assumptions as fact.

Share this post


Link to post
Share on other sites
dascandy    216
Quote:
Original post by swiftcoder
This is one of those myths you see thrown around regularly, which has no factual basis whatsoever: any language can be decompiled, and a decent programmer can read raw assembly code without much trouble. If your security, etc. relies on obsfucated source code, it is worth exactly zero.


That's hardly true, now is it. I've made two classes in C++ to wrap mutex handling (mutex and lock class), made a construct involving a for loop and an operator bool() to allow


locked(mutex_name) {...}

to do exactly what you expect. The compiler removed *everything* except for the contents of the mutex_lock() and mutex_unlock() functions.

There's no way you'll get *that* back from the assembly code as it's just plain not there.

IL code is much more directly related to the origin language(s) and can be decompiled much more easily. It's also a higher-level language expressing more about the program - so it's inherently easier to understand. Assembly doesn't know objects and classes, IL does because it has to (JIT type-safety checking).

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this