The Definitive Guide to Language Selection

Started by
23 comments, last by stimarco 17 years, 6 months ago
This is a long one, I apologize! :) The Definitive Guide to Language Selection Again ( and again and again and again ) we are asked the same question by new developers. What language should I choose! Then again ( and again and again and again ) the thread devolves into another language war. My intention with this thread is to put together as unbiased a list of language features that can be simply linked in response to these questions. Please feel free to contribute unless you are a mindless language zealot, in which case, please check your attitude at the door. However, if you are an advocate of a given language, feel free to contribute a blurb on the positives of that language but drop negative comments about other languages. This isn’t an X vs. Y thread, at least I hope it isn’t. Keep something in mind, to a new user, two veterans arguing arcane points about language X vs. language Y isn’t helpful. In fact, I imagine its quite harmful to their understanding. Hell, to somebody who has yet to write a line of code concepts like JITing, RTTI, early/late binding, etc… are simply Greek to them ( unless of course if they are Greek! Then, lets say… Chinese to them! :) ). First off, to new developers the question you are asking isn’t a simple one, nor does it have a yes or no answer. It is possible that in one situation a certain language is perfect, but in other situations it is not. Also, quite often multiple languages are actually used for different parts of a single game. Another aspect to keep in mind is, do you have experience with a language already? If so, are you comfortable using that language. This is a valuable plus, probably the most valuable plus in language selection. If you are trying to learn the concepts of game programming and already have experience with a certain language you already have a leg up on most new developers. Trust me, its much harder to learn a new language and a new style at the same time. Also, game programming concepts stay pretty static between languages. A game loop looks very similar regardless to the language it is written in, AI is AI, regardless to the language its written in. Heck, the graphic calls you use to put images on the screen will probably end up look very similar. In short, experience you gain using one language to develop a game, will help you in developing future games, regardless to the language you choose. To most veteran programmers, switching between languages is not really that hard. The next thing to ask yourself is, what kind of game are you trying to create. Certain games lend themselves to certain languages. For example, Java is a much stronger language to consider if you are thinking about creating a mobile phone game ( not to condemn Java for non phone games ). Additionally, if you are looking at creating Mac only games, Objective C is a more viable solution, but in other situations, not so much. Lastly, if you are new and are writing a MMORPG, Doom 3 or Baldurs Gate 2, don’t. Granted, that’s a topic for a different thread, but if you are at the point where you don’t know what language to use yet, these game types are far outside of your grasp. Save them for later. Now, onto the languages: ------------------------------------------------------------------------ C++ ------------------------------------------------------------------------ C++ is the grand daddy of all game programming languages. I wont lie to you, probably 99% of commercial windows or console games are written in C++ and there are reasons for this. First and foremost, 99% of games are written in C++ because 99% of games are written in C++. Its called market momentum and it’s a strong thing. Because most games are written in C++, most game tools are written in C++, as are most game SDKS ( software development kits ). Additionally, most game programmers have experience with C++, which means when it comes time to select a new language for their next project… well, its kindof a new brainer. Don’t take this as a ringing endorsement of C++ though, it has its strong points and weak points, like any language. Also, there used to be a time where all games were written in Assembly, so just because it’s the language de jour, doesn’t mean it always will be. As to the strengths of the language, well perhaps the biggest one is, most libraries out there are written in C++, and it’s fairly certain every platform out there ( from Windows, to Linux to the PS3 ) has a C++ compiler for it. This means, with work, you can port your game probably the most platforms of any language currently used. Also, C++ is a fairly low level language or atleast can be. This often means, if you know the language very well, you can write some very fast code. Note though, I am not saying C++ is the fastest language out there, that again is as subjective a statement as “X is the best programming language”. Another big plus ( and minus  ) of C++ is, its rather a jack of all trades language. Theoretically you can do anything in C++. You can access hardware directly, you have full control over memory and assets of your computer. WOW! C++ sounds perfect! Not so fast there. If C++ was perfect, other languages wouldn’t exist. As is often the case, for ever positive, there is a negative. This is true with all programming languages. Lets look at the negatives. First off, C++ is an evolved language from a language called C, which was a VERY low level language. As a result C++ has a lot of legacy “crap” that makes it really confusing for new developers and makes the language a bit less “clean”. Another big drawback to C++ is the system libraries that ship with it are very limited compared to other languages. Things that you will take for granted in other languages ( like string manipulation for example ) are much more difficult in C++. Another big downside is the same as the earlier upside. C++ is a jack of all trades language, it can do a number of things, but that doesn’t mean it does them that well or they aren’t a hack. To accomplish many tasks in C++, you may end up using a library like BOOST, which although powerful, isn’t near as clean as doing the same things in other languages and is often much harder to learn. Lastly, all of the power and control over your computer comes with a price. All memory in C++ is handled by the user, and memory related errors are probably the biggest headache to new ( and experienced! ) C++ developers. C++ gives you a lot of rope, but its pretty easy to use that rope to make a noose! Finally, I don’t think you will find a soul in the world that will tell you C++ is an easy language ( compared to many others ) to learn. If you choose C++, keep in mind you have a pretty harsh learning curve. If C++ sounds interesting to you, here are a few gaming related things to google: 3D graphics: DirectX, OpenGL, Ogre3D, Crystal Space, NEHE 2D Graphics: SDL, Allegro, Direct Draw ------------------------------------------------------------------------ C# ------------------------------------------------------------------------ This is the new kid on the block. In the sake of honesty and in case of bias, I need to mention, C# is the language I do 90+% of my development work in. I am trying to be unbiased in this writeup, but I thought you should know in case I failed at that task. Keep that in mind. I think the first and foremost thing to say about C# is…….. Microsoft developed it. Yes, that Microsoft. For many people, that is reason enough to reject it outright, although I think that is a mistake. First off, C# is standardized by a third party called the ECMA, the same group that standardizes &#106avascript. Second, there is a Linux version of C# called Mono that runs on most of the various versions of Linux, FreeBSD and the MacOS ( version 10+ ). Also, most Microsoft related platforms outside of Windows support a version of C#, including Pocket PC’s, SmartPhones and the Xbox 360. Next thing you need to know is unlike C++ ( to a certain degree, without splitting hairs ), C# needs a runtime component to operate. If you have heard much about C# or Java in the past, you have probably heard things like Virtual Machine (VM) discussed. The virtual machine is the runtime C# needs to work. Here is a brief ( and most likely poor ) description of what that means. When you compile C# code, it doesn’t compile directly to machine code, but an intermediate language the VM executes. Perhaps the easiest way to think of this is, each running C# program has its own little virtualized computer to run in. There are advantages and disadvantages to this approach. It *can* execute a bit slower because of the overhead of being virtualized. That is perhaps the biggest disadvantage. On the flipside, if your code causes damage to the system, it tends to be contained to the virtual machine meaning other programs generally wont crash. Plus memory allocation is much simplified, but we cover that in a minute. However, when talking about C#, many people are actually talking about .NET. .NET is a very confusing topic to many ( for good reason ), but the biggest thing to keep in mind is, .NET is a library of routines to do day to day stuff. Many things you would have to write from scratch in C++ are there out of the box. Working with strings is trivial, creating GUI ( graphical user interfaces ) is much easier, etc… The .NET libraries are massive and are a huge advantage. Next up is the biggest point of contention to most developers. Some people love it, some people hate it. C# is a garbage collected language. This means, if you use a chunk of memory and are done with it, the system will eventually get rid of it. This makes the language itself much easier to work with. Although, to be honest, even though C# makes memory usage more simple, you still need to be wary of it. Improper usage can still bite you in the ass. Remember before when I said the majority of gaming libraries are written for C++? Well this is both a strength and weakness of C#. C# is designed to interop with other languages. This means its pretty simple to call libraries written in other languages. You will find that a number of popular C++ game libraries have C# bindings that allow C# to take advantage of them. Additionally, calling a different languages code ( not just C++ ) from C# tends to be very easy. The downside is, there is a bit of a performance hit for doing so. The biggest selling point to C# is productivity. I can only cite my own personal experience in this regard, but generally I can write and debug C# code a number of times faster then I can with C++ code. As a trade off, you can lose some performance and some control over your hardware and operating environments. Also, imho, C# is a much easier language to learn, although again, this is pure opinion. If C# sounds interesting, here are a few things to google: 3D Graphics: Managed Direct X, Tao, IrrLicht, XNA 2D Graphics SDL.Net, XNA ------------------------------------------------------------------------ I was going to cover Delphi, Python and Java aswell, but I have much less experience with those languages and noticed how damned much I have written already! ;) Heres hoping someone else in the community that favors those languages can write a short blurb in the format above, keep the bias to a minimum. In follow up conversation, please keep comments as unbiased as possible. Feel free to talk about the positives and negatives of a given language, but please try to keep other languages out of it! I would like this thread to be as unbiased and informative as possible resource for people that ask that age old question. Plus, hopefully the time we spend now will eliminate a lot of time in the future have the same arguments again and again. Oh, and if I was factually wrong or showed bias myself, please point it out. Also, please feel free to address points I didn’t. Please try not to get into arcane language issues though that wouldn’t be relevant to someone new to programming.
Advertisement
1. What do you feel qualifies you to write 'The Definitive Guide To Language Selection'.

2. Your guide only covers two programming languages. How is that definitive? Even if someone covers the other three languages mentioned, a guide covering only five programming languages can still hardly be considered definitive; why have we automatically ruled out the entire BASIC family and it's derived languages, countless scripting languages, and C among many other languages.

3. You mention that many existing tools and SDKs are implemented in C++; whil this is to an extent true, I think you'll find that legacy code/libraries/engines written in C are far more common than those in C++.

4. Again, you mentioned the availability of compilers across multiple platforms as an advantage of C++, but there are many platforms which lack C++ compilers or lack a fully-featured standards-compliant implementation; if you're looking for something that should be available everywhere you'll probably find C to be much better supported.


Just a few quick points. If someone hasn't done it later I might take a stab at a brief coverage of the other languages you missed, but I'm still unsure as to the actual value of this thread as a reference.

- Jason Astle-Adams

Quote:Original post by Kazgoroth
1. What do you feel qualifies you to write 'The Definitive Guide To Language Selection'.


This thread hopefully by the time it is closed :) I am not qualified to write such a thing, nobody is. I am qualified though, to get the ball rolling and hope the community can be mature enough to be as impartial as possible, and through community effort make such a guide. Ok, perhaps the title was a bit grand... hey, cant blame a guy for shooting high! :)

Quote:Original post by Kazgoroth
2. Your guide only covers two programming languages. How is that definitive? Even if someone covers the other three languages mentioned, a guide covering only five programming languages can still hardly be considered definitive; why have we automatically ruled out the entire BASIC family and it's derived languages, countless scripting languages, and C among many other languages.


You are right, I only covered two languages. Frankly, I only have years of experience with two languages and prefer to only speak on subjects I understand. I havent ruled out anything, I hope other people pick up the flag and cover their languages of expertise. Ideally I want to see VB, VB.Net, Python, Delphi, etc... all covered in this thread. But like I said earlier, I have no right to comment on the strengths and weaknesses of those languages. Look to this thread as a place for each language expert to argue the weaknesses and strengths of their chosen languages. The two examples I cited were just to get the ball rolling, I hope. I have ruled out nothing, and I hope nobody else does either. Hey, if you have a particular language you want to argue the merits of, please pipe in! I hope this to be a definitive thread we can direct new developers to when they ask "What language should I choose". If I alone answered that question, this thread would be dripping with ignorance and bias already!

Quote:Original post by Kazgoroth
3. You mention that many existing tools and SDKs are implemented in C++; whil this is to an extent true, I think you'll find that legacy code/libraries/engines written in C are far more common than those in C++.

Yes, but I figured that was rather a matter of splitting hairs and very confusing to a new developer. C today, is pretty much C++, although that is a terrible mindset to take! If someone wants to take C on as an independant language from C++, that is their perogative. Although frankly, I think very very few people actually use C anymore.

Quote:Original post by Kazgoroth
4. Again, you mentioned the availability of compilers across multiple platforms as an advantage of C++, but there are many platforms which lack C++ compilers or lack a fully-featured standards-compliant implementation; if you're looking for something that should be available everywhere you'll probably find C to be much better supported.

Really? The fully featured standards compliant part I can beleive ( hell, is their a single fully compliant compiler even available??? ;) ). Frankly though, I cant think of a single relevant ( to gaming ) platform, that doesnt have a C++ compiler available for it. Please inform me if im wrong, but I know of C++ compiliers for Windows, Dos, Linux, BSD, Mac, GameCube, Xbox, PS2, PSP, DS, nGage, and most mobile phones. Granted, C is more available across platforms but I cant think of two many platforms without C++ available to them.

Quote:Original post by Kazgoroth
Just a few quick points. If someone hasn't done it later I might take a stab at a brief coverage of the other languages you missed, but I'm still unsure as to the actual value of this thread as a reference.


That is exactly the point. I want this to be a one stop shop of (mostly) unbiased merits of various languages. Please do so! It beats having the same conversation again and again, let alone devolving into lame language wars. If you can accurately describe the pros/cons of a programming language I havent covered with a minimum of bias, please do so!
Oh, and if anybody with BlitzBasic, DarkBasic, GameMaker, etc... experience feel like chiming in, that would be great aswell. Many new developers ask about the strengths and weaknesses of these environments aswell!
I only skimmed your post, but I want to point out the following.

Quote:Original post by Serapth
.NET is a library of routines to do day to day stuff.


.NET is more than this. It includes the CLR (Common Language Runtime), Microsoft's implementation of the CLI (Common Language Infrastructure). Such inadequate abbreviations of the larger picture constitute the main source of misunderstanding regarding .NET, an issue you appear to be aware of:

Quote:.NET is a very confusing topic to many ( for good reason )


Quote:It *can* execute a bit slower because of the overhead of being virtualized.


It can also execute more quickly, because the JIT compiler can make optimizations relative to the machine the program is being run on.
Quote:Original post by nilkn
I only skimmed your post, but I want to point out the following.

Quote:Original post by Serapth
.NET is a library of routines to do day to day stuff.


.NET is more than this. It includes the CLR (Common Language Runtime), Microsoft's implementation of the CLI (Common Language Infrastructure). Such inadequate abbreviations of the larger picture constitute the main source of misunderstanding regarding .NET, an issue you appear to be aware of:

Quote:.NET is a very confusing topic to many ( for good reason )


Quote:It *can* execute a bit slower because of the overhead of being virtualized.


It can also execute more quickly, because the JIT compiler can make optimizations relative to the machine the program is being run on.


You are right on both accounts, and like you said, it is a topic of which I am aware of. However, im intending this thread to be a primer for new users, so I dont want to get to mired in details. Hell, explaining what .NET actually is could take an entire thread on its own, and still fail! :)
*Raises hand*
I have a question?
Why not do a Wiki article so that people can put their information in an unbais enviroment and edit what of other people they find bias. That's exactly what Wiki is for! Then people could write about as many languages as exist. A link from this forum to the article would also be very apropriate. It could be a Gamedev community driven Wiki-project! Wouldn't that be cool?
I think this thread is retarded. I am a beginner programmer and am interested in such facts.

However, it was stated at the beginning that this thread should be summarising language pro's and con's and NOT getting pedantic about other peoples comments.

So far there have been like 7 posts, yet only one of which is useful (the first). The rest of them have been just snapping at each other and about what X ACTUALLY is. Who the hell cares! this is for beginners, and beginners are not going to notice the minor inaccurate descriptions on peoples posts unless other people point them out. So how about we all shut up and if you have a post with something USEFUL to add for a BEGINNER then do so.

Quote:Original post by DjMaSh
this is for beginners, and beginners are not going to notice the minor inaccurate descriptions on peoples posts unless other people point them out.
It's because those inaccuracies aren't going to be noticed by a beginner that they should probably be pointed out; as a beginner, do you want a simple to understand explanation that isn't correct?

While people should certainly try to stick to the topic at hand and not nitpick minor details too much, I'd suggest that you'll end up with a better resource if people are allowed to point out what they feel are gaps or flaws in the information.

- Jason Astle-Adams

Someone correct me if I'm wrong but I would have thought the Beginners forum is for people who have difficulties with their programming, or ask a questions about certain programming issues realating to games

I don't think this forum is suitable for debating the different kind languages, what each one is good for or how alike they are. This thread would likely cause people to side with their language and ultimately turn into a war of the languages as I have seen in past threads on similar issues.

This topic is closed to new replies.

Advertisement