This article was originally published to GameDev.net back in 2000. It was revised by the original author in 2008 and published in the book Beginning Game Programming: A GameDev.net Collection, which is one of 4 books collecting both popular GameDev.net articles and new original content in print format.
We'd like to update this document once again from its 2008 version, so please use the comments to add new language sections and we will place them in the article. Additions and updates to current sections are welcome as well!
CThe C Programming Language is either the direct parent or a heavy influence to every other language discussed in this article. While it was itself derived from a couple of other languages that have fallen into disuse, C is now considered to be one of the "root" languages of computer science. Some other languages that predate C (COBOL, FORTRAN, Lisp, Smalltalk) are still in use today and owe nothing to C, but just about every language that's been produced since the 1980's owes at least some of its syntax to C. C is a classic "brace language", which is to say that it's a structured goto-less language that uses the open and closed curly-braces to group statements together. It's a structure that's repeated in many of the languages that follow (C++, Java, C#, ActionScript, PHP). One advantage of the endlessly-imitated structure of C, braces and otherwise, is that once you understand how things are done in C, you can carry them over to the other languages with almost no changes. The if(), while(), and for() statements in C and PHP, for example, are basically identical. For that very fact alone, it is recommend that you familiarize yourself with C syntax, as it is something that you can keep with you. Advantages: C is good for writing small fast programs. It is easy to interface with assembly language. The language itself as well as the library routines are standardized, so moving programs to other platforms can be a straightforward process if you plan ahead. Disadvantages: The ability to write small programs quickly also works against C, as C is not normally used for object oriented programming[sup][note][/sup], which is a method of structuring your code that's better suited to large programs with distributed development, and large C programs can grow disorganized easily. While many very large projects have been written in C (Unix, Windows, Oracle), managing a large C-based project requires more discipline than in languages that are built around more modularity. Portability: While the core of the language itself and the ISO function calls are very portable, these calls are limited to control flow, simple memory management and simple file handling. Modern user-interface constructs, like menus, buttons, dialog boxes, etc., are not portable between platforms, so you will need to either write your code to work with a third-party UI toolkit or plan to write your user-interface twice. While the language was ahead of its time when it was created, the C library is showing its age. Many non-trivial library functions, like memory management and strings, have a simplistic syntax that has been significantly tuned up in the language's successors. While C has been redesigned and re-standardized several times to keep up with the times, some of the syntax is counterintuitive by necessity. Some of the quirkier language constructs remain for the sake of compatibility with existing code. Suitability for Beginners: Not very good. While the core of C is fairly compact and easy to grasp, many of C's library calls are antiquated and are easier handled in some of its successor languages. Resources: While Kernighan and Ritchie's The C Programming Language is the "classic" book on the subject, the book does cover topics fairly quickly, and it might be too quick for a rank beginner at programming. Other well-recommended books include C How to Program, C Programming: A Modern Approach, and C Primer Plus
C++C++ is C's most established "child" language. It was designed in the 1980's as an extended version of C with support for "classes"[sup][note][/sup], which are abstract data structures that aggregate primitive data types and algorithms into something that is better able to model real-world (or in the case of games, simulated-world) objects. C++ classes also support the concept of "data hiding" in which you can hide the underlying implementation of an object from the rest of your program. While this method seems a bit inscrutable, it is extremely useful when programming in a team environment. It allows you to agree on how the object's interface is intended to work without regard as to how the object works internally. It's a bit like saying "I'm giving you a job, and I don't care how you do it as long as it gets done, and the result looks the way I want". Advantages: Supports the object-oriented (OO) paradigm very completely, which is much better than C for supporting large projects. Unlike C, it contains a very well-designed library of common data structures and algorithms. Disadvantages: The syntax of C++ has grown larger and more complicated with each iteration, and the language is absolutely byzantine now. The syntax lends itself very easily to abuse and, while the language does support team programming very well, its huge and deep syntax can make code difficult to read. Portability: Despite its roots in C, C++ has better portability than C[sup][note][/sup]. This is because most modern portability toolkits are implemented as C++ object libraries rather than the old-style C function libraries. In addition, C++'s standard library and very useful Boost library is very standardized and cross-platform despite the complexity of both. Suitability for Beginners: While the memory management and I/O operations in C++ are significantly easier to understand than C, C++ has a pretty high learning curve just from its sheer size. Thankfully, one doesn't have to learn the entire language to be productive with it. Resources: A perfect beginner's book for C++ is C++: A Dialog by Steve Heller. It's very well-paced and approachable, and it's perfect for beginning programmers. For a more comprehensive approach, Bruce Eckel's monumental two-volume Thinking in C++ series will tell you all you need to know about C++ in only 1,600 pages. As an added bonus, these books are available for free download. Google for them, and you should have no trouble finding the official sites.
There has since been a new standard released, C++11[sup][note][/sup] (to be followed by C++14) that should be considered when learning this language. See the reference note on some ideas for resourcesC or C++: Short of "DirectX or OpenGL", this is one of the most-asked questions when getting ready to learn the language. C++ is, with a couple of very minor exceptions, a proper superset of C. That means that all that C does, C++ does the same. Every C++ compiler will also compile C, and C-only compilers are very hard to find nowadays. While those facts might make it seem logical to start with C and then learn the "rest" of the language later, it is a better idea to learn classes and OO programming early on rather than having to "unlearn" techniques that don't model the environment (real or simulated) very well.
Objective-CObjective-C is an object orientated, strongly typed programming language with a dynamic runtime. In it's nature, it is a superset of C. It inherits the majority of it's basic syntax rules from C, while having some more major changes to the structure as well. That for instance would include method calls, overall definition rules and so on. Objective-C is the primary language for MAC OS X and iOS programming and is an Apple exclusive. It supports a wide variety of development techniques, functionalities, libraries and many other bonus features that make this language stand out (for more information, see reference). The language supports a really wide range of built-in libraries for handling 2D and 3D graphics (OpenGL based) which can help a junior game developer in building his/her first game bu using a powerful, yet native solutions. Other libraries help game development as well, especially for mobile. Another standout feature is the reference counting garbage collector, working in a close collaboration with the very sophisticated memory management system (see reference). Advantages: Objective-C is a powerful superset of C and can produce and run very powerful and flexible applications. It can utilize C/C++ code and through that it is easy to port new projects and extend the power of already existing such. The language possesses a really wide variety of helpful libraries and one of the best development environments in the face of Xcode. This is a powerful OOP language that can be used in many ways. Disadvantages: Objective-C is an Apple exclusive, thus you need an Apple computer, running the latest version of Mac OS X in order to develop your applications. Another thing to note is that some of the syntax rules of the language can end up being confusing for the beginner to intermediate programmer. The method calls are far from the standard, the class definitions are also going to cause some confusion for beginners that have no experience in C/C++. Something else to note - knowledge of memory management on a higher level is absolutely required if you plan to develop apps for iOS. Portability: There is none. What ever is written in Objective-C stays within the Apple products. You cannot port an Objective-C project to another platform without completely re-writing it in another language. The bottom line here is - Objective-C is only suitable for Mac OS X and iOS development. Suitability for Beginners: Objective-C is not the most beginner friendly language, though it's not the hardest one as well. You'll have an easier time learning C# or Java, yet getting proficient in Objective-C is relatively easier then C++. A beginner will most certainly need to put in a lot of reading into concepts such as memory management, so on and so forth and that can be a painful process to go by if you are just starting out, however it will pay out in the long run. Resources: Aside from the official Apple guides, there are a lot of free e-books on onlineprogrammingbooks.com - http://www.onlineprogrammingbooks.com/objective-c/ References: Objective-C basics: http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html http://www.otierney.net/objective-c.html http://mobile.tutsplus.com/tutorials/iphone/learn-objective-c-day-1/ Objective-C memory management: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html Objective-C for game development: http://people.oregonstate.edu/~doneb/downloads/iPhone%20Game%20Development%20Developing%202D%20%26%203D%20games%20in%20Objective-C~tqw~_darksiderg.pdf http://www.idevgames.com/articles/for-beginners/2 Objective-C compared to Java: http://assoc.tumblr.com/post/28261068461/objective-c-versus-java Objective-C compared to C++: http://www.mactech.com/articles/mactech/Vol.13/13.03/CandObjectiveCCompared/index.html General iOS development compared to Android development: http://java.dzone.com/articles/android-vs-iphone-development
JavaJava is, for practical purposes, the first "post web" language. While some languages like Perl suddenly found their string-handling capabilities to be a natural for retrieving values and sending display-able HTML to web browsers, Java initially found its footing in the browser itself, first in the very interesting but monumentally quirky HotJava browser (written in Java itself), and later in the form of extensions for existing browsers. Java, while on its face structured similarly to C and C++, behaves very differently on the "back end". The Java compiler, rather than compiling Java source code to native machine-code, compiles to "bytecode" that is run by a Virtual Machine or VM. The Java bytecode is an assembly language of sorts, but it is not an assembly language that is married to a particular processor. The Java VM, which is actually a runtime interpreter of bytecode, will then interpret the bytecode for your machine's target processor. The advantage of this approach is that Java bytecode can be moved from machine to machine and executed without changes provided that the target machine has a compatible Java VM or, as Java promised, "write once, run everywhere". The disadvantage of this approach is that Java bytecode is not native machine code, and while technologies such as "just in time" compilers can improve VM performance, the fact is that you're doing some level of interpretation at runtime, and that does entail a minor, but measurable performance hit. The other disadvantage is that realities of Java have not lived up to the language's early promises. While the idea of executing games inside web-pages captured everyone's hearts almost immediately, the reality quickly set in that Java VM's aren't as compatible with each other as they should be, and a Java application or applet written on one machine using a particular VM may or may not run nicely on another machine with another VM version. "Write once, run everywhere" was snarkily renamed "write once, port everywhere", which is to say that once you finished writing your Java code and it's running beautifully on one platform, you then had the non-trivial task of making sure the application will actually run well and look nice on all systems. The third disadvantage of Java came with its GUI. While the first "pass" at making a Java GUI used native OS controls (buttons, scroll bars, etc) and was reasonably small and fast, it wasn't very deep. The next pass, Swing, looked better but performed worse and was entirely different from the original controls. And, worst of all, Sun (Java's parent) was slow to add OS features that had been in existence in the underlying OS for years, like support for ClearType font rendering. Hence, Java applications always seemed to look a few versions away from state-of-the-art. There is one place, though, where Java took a good hold and Java's advantages outweighed its disadvantages, and that was in server programming. One big advantage of a VM is that since it's not an actual processor but just a simulation of one, crashing the VM isn't much of an issue. If you do manage to completely confuse the Java VM, that doesn't really affect the parent operating system, and you can close and restart a session without having to reboot the entire machine. Couple that with the fact that Java's memory management scheme is a generation evolved from that in C++ and C, and suddenly problems like allocating memory without releasing it back to the system became much less of a problem. And a system like this is perfect for a server environment. A server can pop up and kill VM's as necessary without affecting the underlying OS. Also, the GUI problems don't really apply, as it doesn't matter if your server software doesn't look spectacular unless you just want to impress server-admins. Today you'll find many commercial Massively Multiplayer games that use Java on the server side. A good example would be the multiplayer games by Three Rings that are fully Java on the client as well as the server-side. Another place where Java has very strongly caught on is in the mobile phone market. J2ME[sup][note][/sup] (Java 2, Micro Edition) is a "miniature" version of the Java VM with a significantly truncated class library which is designed to run on mobile phones and other small devices. In fact, if you include the mobile phone demographic, Java is one of the most popular platforms in existence. Advantages: Java's Virtual Machine coupled with its memory management and automatic collection of no-longer-needed memory allows you to make software that is very robust and crash-resistant. It also has a strong tradition of extensive documentation[sup][note][/sup]. Disadvantages: Java's "write once, run everywhere" promise wasn't fulfilled. The Java class libraries have been rewritten multiple times without removing old calls, so while the libraries are very backward-compatible with old code, there seems to be three ways of doing everything, all but one of which are discouraged as being "obsolete". Portability: Fairly good, but not as good as it should have been. Making an application in Java that is portable and uses the underlying OS's latest features is almost as difficult to do in Java as in C++. Suitability for Beginners: Reasonably good. While figuring out the "right" way to do things without bumping into a deprecated object is a bit of a pain for beginners wading through the language, the core of the language itself is well-designed and easy to understand. Also Java is a standard language for many university courses. Resources: Oracle Inc., the Java authority, has plenty of great resources for Java programmers.
.NET Languages (specifically C# and Visual Basic).NET (pronounced "dot net") is basically Microsoft's answer to the Java VM. Actually, .NET is the name for the overarching technology. The actual VM's name is CLR (common language runtime), and everything that was said earlier about the Java VM also applies to the CLR with one significant exception: the CLR was designed from the ground up to not be "married" to a single language, as Java was. And because of this, there are a whole host of languages that use the CLR to do the back-end processing. Everything from ancient legacy languages like COBOL and FORTRAN to modern languages like Python can target the CLR. Mind you, some of the CLR projects out there are little one-man projects, so don't get too excited if you find your favorite language in a CLR version, as some of the compilers are far from mature. C# and Visual Basic, both developed by Microsoft, are the most popular CLR-based languages. C# is a language clearly derived from Java, and it shares about 90% of Java's syntax despite sounding more like something derived from C or C++. C# does have several nice language extensions that Java has been slow to add as well as a completely rewritten class library. Visual Basic, which was briefly renamed VB.NET, is a CLR implementation and replacement for Microsoft's established and popular Visual Basic environment. While it is still called "Basic" and is no longer in all-caps, it bears very little resemblance to the old BASIC interpreters that were burned into the ROM of just about every computer sold in the 1980's. The syntax is now structured similarly to the other languages in this list, although it still doesn't use braces to group statements. It also uses the more object-oriented "dot notation" to call functions rather than the large function library of the pre-CLR versions of the language. Advantages: While Java does have a couple of minor efforts to compile languages to the Java VM, the CLR is designed from the ground-up to support this. Hence, there are several CLR-based languages, and it's relatively easy to get them to communicate with each other. The .NET technologies are very well-supported by Microsoft's Visual Studio environment, which is a very mature and feature-rich development environment. C# is the premier programming language for Microsoft's XNA technology, which is a method of making games that are portable between Windows and the XBox 360 game console. Disadvantages: Unlike Java, CLR applications can't run as applets within web pages. While the "Silverlight" technology does allow this, it's fairly late to the game and is not entrenched in browsers the way that Java and Flash are. Silverlight has also been discontinued after release 5. CLR-based applications are much less portable than they should be. Portability: While there are third-party efforts to port the CLR to operating systems other than Windows, the efforts in that direction are significantly smaller than the work being done in Windows. So while you might be able to create a very robust .NET application for Windows, your Mac and Linux efforts won't be nearly as smooth. Suitability for Beginners: Good on both counts (C# and Visual Basic). Both languages are straightforward and easy to understand. In addition, their tight integration with the Visual Studio environment makes setup fairly easy. Resources: Microsoft.com
PythonPython, unlike the previously-mentioned languages, did not start out as a large corporate or university project. It was much more of a grassroots effort among university students and, later, among people in the industry who liked the language's structure as well as its lack of legacy features. The language itself is fairly compact and is easy to use. It is also easy to embed a Python language interpreter into existing projects, which is why you'll see Python as an embedded scripting language in many games. Python also functions well as a server language as it features many of the server-friendly attributes of Java. In fact, Python compilers exist that can compile Python code to both the Java VM and Microsoft's CLR. Many services that you would recognize (YouTube, Google, and Yahoo) use Python extensively for back-end processing. Python is also becoming quite popular in the gaming community with the user-supported PyGame library. PyGame is an object library that abstracts the well-established SDL cross-platform graphics library into something friendly and easy-to-use from Python. Several impressive arcade games have been written entirely in Python. Advantages: Free and open-source. Very dedicated user community. Integrated fully into Google AppEngine, which is Google's "pay to play" processing server. Disadvantages: Virtually everything is handled not by a large corporation but by its user-community, so it might be a hard-sell to get a company to sign off on a Python-based project, although some very big players are now invested heavily in Python so Python now looks like much less of a "hobby language" than it used to be. Portability: Pretty good. Most of the third-party libraries made for Python are built around portable technologies like SDL and OpenGL, so it's not too difficult to write something in Python that will run on several platforms. Suitability for Beginners: The Python language has an easy-to-follow syntax and is easy to learn. In addition, there are several good community-written tutorials out there. Resources: Python.org is a well-organized home for all things Python. It is also the home of many active community forums where you can get your questions answered.
Assembly LanguageThere are two things that you must know about assembly language.
- The name of the language is "assembly". The name of the tool that converts assembly language into low-level machine code is called an "assembler". It's a common mistake, even among experienced programmers, to call the language "assembler". So please start out on the right foot by calling the language by its proper name.
- Assembly language is, by default, the smallest and fastest language in this article. Since it is not a high-level language but is actually a mnemonic representation of your CPU's instruction set, there is nothing written in a higher level language that can't be done faster in assembly