Sign in to follow this  
Arkanus

Game languages

Recommended Posts

Arkanus    100
Hi, I've decided to start learning a language for 3D-type games and to start an engine (maybe). Which language should I use? XNA in C# or just C++?

Share this post


Link to post
Share on other sites
VizOne    598
Hi,

First of all: write a game, not an engine. Somewhere here on gamedev.net there's a nice article on that topic. [edit: wasn't here, but here] You'll never know what problems an engine has to solve if you've never written a game.

Now to your question. Both languages have their pros and cons. You will most likely find a lot of discussions on C# vs C++ vs [insert language here], so I will not give a detailed list on pros and cons here. My personal opinion is that C# is generally easier to pick up for beginners as there are less frustrating obstacles during development.

Regards,
Andre

Share this post


Link to post
Share on other sites
ToohrVyk    1595
Here are a few answer elements:

  1. Are you most familiar with one of the languages? If you are, then use that language. Using a language you know is almost always be easier than learning a new language for the same task (especially when choosing between C# and C++).

  2. Learning C++ from scratch is difficult, due to the nature of the language: unlike C#, most errors in C++ are ignored by the compiler, so you cannot try to learn the language by "trial and error" since the error part will happen days or weeks after the actual trial. If you choose to go with C++, be prepared to spend more time reading books and references than you will spend writing code, and never ever try to write code which you do not already know for certain is correct.

  3. XNA is a superior solution in terms of ease of use, when compared to plain old DirectX (or, worse, OpenGL + sound and input libraries). Of course, it's also less powerful in terms of expressiveness, but this should not bother you for at least the first six months you spend writing 3D code.

  4. As a general rule of thumb, you will need serious grounding in your language of choice before being able to take on 3D development. If you know no language, be prepared to spend between three months (C#) and one year (C++) before you reach a point where you can actually make responsible decisions about using 3D in your code.

  5. Writing an engine is the most frequent application of the EYODF (Eat Your Own Dog Food) principle: whenever a programmer writes code to be used by another programmer without first trying to use that code himself, the resulting code is unusable. Without exception, an engine designed by a programmer who has never written a game will both provide useless functionality that will never be used in a game, fail to provide functionality which is omnipresent in games, and provide whatever is useful in a manner which is overly complicated and obscure. In general, the only way which works is to design an engine by refactoring a game.

Share this post


Link to post
Share on other sites
Krohm    5030
Quote:
Original post by VizOne
First of all: write a game, not an engine. Somewhere here on gamedev.net there's a nice article on that topic. [edit: wasn't here, but here] You'll never know what problems an engine has to solve if you've never written a game.
I want to quote this as that's absolutely true. Engines are difficult and will never pay for themselves in the first place if you don't design them correctly since the beginning.
Quote:
Original post by VizOne
XNA is a superior solution in terms of ease of use, when compared to plain old DirectX (or, worse, OpenGL + sound and input libraries). Of course, it's also less powerful in terms of expressiveness, but this should not bother you for at least the first six months you spend writing 3D code.
As a long-standing GL user I have to admit I do not recommend GL. It's a shame to say but corrent GL is just dead - I can grasp it because I've been there since GL1.1 but starting today the amount of extensions is terrible.
Sure, you get the possibility to port to MacOS, so what? If you want to learn it you're better focus on a single os - I bet that's win.

Share this post


Link to post
Share on other sites
Arkanus    100
looks like I'll start with C# then, I just got a book on using XNA to make an engine.
I have used a couple of engines before, namely torque (only a little bit) and Genesis3D, so I do know how to use an engine (duh)
Anyone got a good starting tutorial?

Share this post


Link to post
Share on other sites
remigius    1172
The XNA Creators site has a number of starter kits with source codes to complete games. Maybe it's a good starting point to tinker with those and get familiar with some game architecture first. Then, as many folks have lamented, I'd still start trying to make my own game instead of an engine. Trust me, using one is a lot easier than designing and implementing one [smile]

Share this post


Link to post
Share on other sites
Arkanus    100
yeah but I can't sign up because Microsoft is being stingy by only letting Xbox360 owners sign up

PS Is there a way to get the Vicious Engine? Can't find any links..

Share this post


Link to post
Share on other sites
remigius    1172
Quote:
Original post by Arkanus
yeah but I can't sign up because Microsoft is being stingy by only letting Xbox360 owners sign up


You can download most samples and starter kits without even signing in. The XBox Creators club membership is only required for premium content afaik, like the Ship game.

Quote:
PS Is there a way to get the Vicious Engine? Can't find any links..


With clients like Warner Bothers and Sega, plus the ability to run on just about all contemporary platforms, I doubt you're gonna find a free legal download link, if at all... You have your language suggestions, you know how to use (and presumably get) various engines, so I'm a bit puzzled what you're looking for now.

Share this post


Link to post
Share on other sites
Cromulent    398
Quote:
Original post by ToohrVyk
and never ever try to write code which you do not already know for certain is correct.


Unless you mathematically prove the correctness of your code (I seem to remember it is a part of some maths centric computer science degrees / PhDs) you are never 100% sure your code is correct and even if your code is 100% correct then you are not sure that the code it relies on is 100% correct (i.e the operating system).

Share this post


Link to post
Share on other sites
bgilman    122
Quote:
Original post by Arkanus
Hi, I've decided to start learning a language for 3D-type games and to start an engine (maybe). Which language should I use? XNA in C# or just C++?


First, I wouldn't start off doing games in 3D, you are biting off way more than you can swallow. Second, I would learn C++, as opposed to C#. At this point, it's just a flat out a more valuable language to know. I would try making some simple 2D games, using C++ and SDL, then moving on to bigger and better things.

Hope that helps.

Share this post


Link to post
Share on other sites
Arkanus    100
thanks, I have learnt abit of C++ before, but I failed to really use it in context. If someone could point me to a way to start my learning curve, that would be great.

Share this post


Link to post
Share on other sites
ToohrVyk    1595
Quote:
Original post by Cromulent
Quote:
Original post by ToohrVyk
and never ever try to write code which you do not already know for certain is correct.


Unless you mathematically prove the correctness of your code (I seem to remember it is a part of some maths centric computer science degrees / PhDs) you are never 100% sure your code is correct and even if your code is 100% correct then you are not sure that the code it relies on is 100% correct (i.e the operating system).


Being 100% correct is not the point: this would involve a complete program analysis that is generally not even computable (reduces to the halting problem or similar). What is important is that no undefined behavior appears: this is much easier to determine, simply by traversing the code in a linear fashion and determining if a given statement breaks any language rules.

C++ has a lot of pitfalls that may not seem immediately obvious to an average beginner, which mostly stem from odd features that are inconsistent. For instance, you can null a pointer by assigning a zero integer constant to it, but not by assigning it zero at compile time. And so, even extremely simple code bears the risk of being inconsistent:

int *ptr = 0; // correct!
memset(ptr, 0, sizeof(ptr)); // incorrect!
ptr = condition ? 0 : new int; // well?


When writing a line such as the third one, it's necessary to check whether the 'zero' in that expression will remain an integer (thus assigning ptr a runtime value of zero, which is not a null pointer) or if it's converted to a null pointer value beforehand (for those who care, 5.16 §5 says it works as expected).

Share this post


Link to post
Share on other sites
Cromulent    398
Quote:
Original post by Arkanus
maybe I should just stick with XNA, though it doesn't support 2008 OMG


The next release will. Should be out sometime in June / July.

Share this post


Link to post
Share on other sites
Arkanus    100
Quote:
Original post by Cromulent
Quote:
Original post by Arkanus
maybe I should just stick with XNA, though it doesn't support 2008 OMG


The next release will. Should be out sometime in June / July.


thanks, Cromulent

Share this post


Link to post
Share on other sites
mutex    1111
XNA Game Studio 3.0 CTP is available which supports VS 2008 as well as Zune development.

I recommend C# + XNA. I've been using XNA the last few days and it's surprisingly simple. I've been using C# for ~5 years now and it's so much simpler and more productive than C++.

Share this post


Link to post
Share on other sites

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