What programming language do I use to write a game?
Published May 6th, 2008 in BlitzMax, Games, ProgrammingThe net is full with questions like that, and usually all the kids asking them get the same idiotic answer: C++. Sure. As if they all had the skill set and the will to write their own Quake 5 engine from scratch. As if using the object-oriented abomination of the low-level system language C would really be helpful to somebody who wants to learn how to create a game.
The funny thing is that it’s probably a safe bet to presume that most people giving that advice either have never written a single line of code in their whole life. Or maybe they know how to write a business app (at best), but have only read about game programming.
There’s so much wrong in advising people to start their programming career with C++ that it’s almost impossible to know where to begin with listing all the reasons.
How about we start with what Alan Kay, one of the fathers of object-oriented programming, said:
“Actually I made up the term ‘object-oriented’, and I can tell you I did not have C++ in mind.”
Oops. I guess that is a severe blow in the direction of all those people who recommend C++ –because– it is object-oriented, among zillion other things that it also tries to be, and all of them at the same time.
Another re-occurring argument is that “it gives you full control”. Well, it does not give you full control, it –forces– you to take full control, because you have to manually take care of everything yourself. (Yes, I know that there are garbage collectors available for C++, thank you very much.)
Languages like BlitzMax, Python or Java have a garbage collector built in, so the programmer does not have to clean up behind himself all the time. One of the most important results of this is increased programmer productivity: Actually, the developer can focus on his goal instead of testing his code for memory leaks and unpredictable crashes because of memory leaks. Not having a garbage collector slows you down significantly, while not giving your application/game a noteworthy performance increase in return.
“C++ code runs so much faster than <xyz>.” Maybe, but it is still slower than plain C or Assembler code, and probably also slower than Pascal code. But that does not matter. What matters is that you have to pay a high price for that increased performance, not only because of its low-level nature, but also because of the complexity of the language and its, in my eyes, extremely ugly syntax. And to really obtain and harness that increased performance, you have to really know what you’re doing. And beginners hardly fall into that category of programmers.
A former boss of mine once said something like “whoever uses C++ for application development must have masochistic tendencies”. I’ll put my signature under that.
But ok, we are not talking about applications here, but about game development. And C++ is the de facto standard in the gaming industry, right?
For ENGINE authors, yes. But the game logic - the FUN part - is nowadays usually written in a scripting language like LUA or Python (Civilization IV, for example). Even C# and Java have been used for this.
So unless you really want to learn how to write a game engine from scratch, you might find out that you do not have any need for wasting your time on C++ AT ALL.
And if you’re a real beginner, you neither need nor want a frustrating steep learning curve. You want to see something grow and you need to have fun while you are writing code.
Python is a much better language for learning various programming concepts and for getting something done quickly than C or C++ or even C# and Java, and the pyglet module might be a good starting point for you to enter multimedia and game programming.
BlitzMax is a very popular programming language among successful indie game developers and the Blitz family of products have a long tradition and track record. Take a look a “Eschalon: Book I” by Basilisk Games to see what can be done with BlitzMax, or look at some of the games developed and published by Grey Alien Games. There are hundreds of others. Better just check out the BlitzMax webpage and their gallery.
In the end, it’s more important to actually get a game done than what language you use for it.
Any thoughts on JavaFX and Adobe’s Air Flex? For casual games either might work I think? And for those of us writing business apps… Be interested to hear what you think.
There are a couple of thoughts that I have about Java, and probably none are in real favor of Java the language or Java the platform. Java’s been a failure on the desktop and in the browser - I think nobody can deny that. And when I look at the abysmal performance of Netbeans 6.1 on my Quad Core machine, the lack of acceptance of Java GUI applications does not surprise me the least.
Sun is trying to sell Netbeans 6.1 as the best development environment for Java developers since the invention of sliced bread, and since it is a Swing application, it must serve as a reference for Swing GUI apps. And since it is not only an IDE, but also a Rich Client Platform (BlueMarine, for example, is based upon it), the performance of Netbeans 6.1 is the most relevant benchmark for Java GUI apps that there is. Well, I can only recommend to everybody to download it and see for yourself how slow Netbeans is and what a resource killer it is. You won’t need a stopwatch. And you certainly do not want to make it your everyday environment - at least not on Mac OS X, which has a 64 bit VM (both Java 5 and 6) and certainly is not as bad as Java zealots want to tell you.
So even the most recent incarnations of Swing, in my book, are just continuations of Java’s long history of failure as a desktop platform.
Now JavaFX tries to compete with the Flash platform, which, as we all know, already a long time ago has killed Java applets and actually managed to deliver on Java’s original applet vision. Java was too huge, too slow and too ugly and originally had no multimedia features. Flash is small, has strong multimedia features, is available on almost every platform out there, including cell phones, works and is accepted. Why would anybody want to install a Java runtime (or a Silverlight plugin, for that matter) when he already has a Flash plugin installed on his system that lets him watch videos on YouTube and play all kinds of Flash-based online games?
JavaFX is yet another dead-born, futile effort of Sun to conquer the browser. And Microsoft’s Silverlight will join the same fate. Microsoft only has the advantage of owning 85% of the browser market and so they can push Silverlight to a huge user base. However, Adobe owns the market for web development tools, and there simply is no reason why a web developer/designer would want to switch from the Creative Suite that he or she already owns and studied and masters and that is taught in schools and colleges to a Microsoft tool. And Adobe does not only target developers, they target designers AND developers and have very sophisticated and mature tools for both audiences: Flash Pro and Flex Builder Pro.
So I think that’s already 3:0 for Adobe here - Ubiquity, customer base, tools.
Treat adventure games that were completely done in Flash are the Nick Bounty series. I think they really show off what can be done with Flash:
http://www.otterarchives.com/bounty2/
I also know some great language learning software by PONS that was made with Flash. It was made for the German market and is called “Spanisch Voll Easy”:
http://www.amazon.de/Spanisch-CD-ROM-Windows-Lernende-Grundkenntnissen/dp/312560561X/ref=sr_1_1?ie=UTF8&s=software&qid=1210973975&sr=8-1
I think people are still just trying to figure out the things that they can do with Flash/Flex, especially in the business market. It is a very strong platform, and as I’ve already said, it delivers on all the promises that Java had made for the browser.
When you look at Flash Remoting, it even gets better — your client side ActionScript code can call server side functions as if they were running on the client. And it doesn’t matter if that server code is written in Java, .NET, PHP, Python or whatever else, as long as a compatible bridge is there. That makes it easy to write client/server code and takes away the burden from the programmer of writing complex and compicated communication layers.
I do not yet know how good or useful Adobe AIR will actually be, but the promise of taking a web applet and using it as a regular (offline) desktop app sounds very interesting.
For me, this entire Web 2.0 excitement and those AJAX things are very old hats and actually deliver much less than Flash has already delivered years ago. It’s just that almost nobody ever understood the possibilities of the Flash platform, and the platform has mostly been misused for annoying animated advertisements.
Flash/Flex is the way to go if you want or need to create online GUIs. Only your creativity limits your possibilities.
And, no, I do not own Adobe stocks. It’s just that I’m completely sold on Flash for client side web applications.
By the way, if you need literature, the best books for Actionscript are from Colin Moock, check out http://www.moock.org.
Great reply - thanks! You make a very good argument against Java - which is just what I needed to hear actually, as I’d been wavering very undecided between the two.
I’ll now pour my spare time into learning more about Flex/Air as it’s all too obvious to me that I’m going to need to have my applications more web-friendly ASAP. This Flash remoting business looks well worth a look too - thanks for bringing it to my attention.
Short reply to a long post - sorry about that. But that doesn’t mean your efforts weren’t much appreciated!
You’re very welcome and I’m glad that it’s of some use to you.
For Flash Remoting, you might find this book helpful:
http://www.amazon.co.uk/Flash-Remoting-Definitive-Connecting-Applications/dp/059600401X/ref=sr_1_2?ie=UTF8&s=books&qid=1211070966&sr=8-2
Hope you’ll have success!