views:

530

answers:

9

Let's say I want to create FPS game, let's say clone Crysis so everybody understand what type of graphics & performance I'm after. What's the best code to write this game with so it's as easy as possible to port it to all the common platforms? Of course I want the application to feel and be native to the platform. This also means that it should be easy to take advantage of Snow Leopard's new features like OpenCL and Windows 7's new features. I realize that GUI has the written separately for different platforms and that's not a problem.

So my question is that what's the best language for the job. I'm not looking for one-for-all solution but more like language for the core. I guess one way to put it is to say that what's the best language if you need to port the same program to Windows, OS X & Linux? Java is out of the question.

+12  A: 

C (and now for some padding to reach 15 chars)

Traveling Tech Guy
Well, yeah, C is maybe more portable than C++ or other languages, but he probably also wants to finish the game sooner than in 10 years, so I wouldn't recommend it. The half a year you save in porting work by using C is nothing compared to the time you could save by using a more friendly language than C.
Roman Plášil
Roman, you actually hit a spot because I'm experienced PHP coder but I only know the very basics of C so it's a learning process also. Can you recommend any other language that would be easily "portable" in the future?
Jim
I would recommend knowing C++ well and using the things it offers to make development easier. Java wouldn't be out of question for me although it has its problems.
Roman Plášil
C is not that bad - I wrote C code for years that was running both on Win16 and Mainframe :). But I agree with other commenters: C++ is a better way to get reusable code to work across platforms. Also check out Qt (http://qt.nokia.com/products/) as a cross platform UI solution - the latest SDK is even supposed to have a cross-platform IDE.
Traveling Tech Guy
How much is a UI from a game like crysis? Maybe 2 % - in the level editor.
Roman Plášil
+1  A: 

Whatever you use you're going to have to write platform-specific code. Languages like Java or other interpreted languages (Python be my personal preference) are going to allow you to use a lot of commonalities. However, since it's not a quick and simple project, I'd suggest </intelligent-looking-padding> C or C++.

Edit: GUI doesn't necessarily have to be written from scratch for every platform. Check wxWidgets.

Michael Foukarakis
Thanks a ton for the answer and wxWidgets link.
Jim
+2  A: 

C++. You can avoid millions of "if #define"'s for platform dependent things and instead use inheritance (derived classes for each platform and client using/knowing the abstract base class). A few exceptions to this can be made for the performance critical parts.

There are also lots of libraries for cross-platform development.

Peter Mortensen
+9  A: 

Have you ever seen the Blues Brothers? In the movie, Jake and Elwood go into a hick bar to do a gig and ask what sort of music they like, to which the woman behind the bar answers:

We have both kinds: country AND western.

What has this got to do with this question? Well, you want to create high performance 3D graphics and you're asking what language to use?

We have both kinds: C and C++.

cletus
Yeah, as much as I prefer more dynamic languages such as Python or Javascript, you're simply not going to write the core of a modern FPS game in anything less than C/C++, doubly so if the OP needs to learn as they go along (which means using existing libraries and examples, the majority of which will be in C++).
Kylotan
+3  A: 

You probably want C for your lower level graphics performance, either the variant of C89 that Visual C++ supports, or use MinGW and gcc C99 ( VC++ 2008 doesn't support declarations in for loops in C99 code, which is very annoying, but then they didn't do that right in C++ for years ).

Admittedly, if you're taking GNU with you and running full-screen with your own GUI then it's not really cross platform any more.

You also probably want either Lua or Python or another scripting language which plays well with calling C to give a sensible higher level way of controlling the game.

Pete Kirkham
+1  A: 

Most cross platform games are written in C++, because it is very good - performance wise; and its more user friendly than C. Games need maximum speed & efficiency!

You can hide away platform specific stuff behind certain abstractions and API's that you write so that you can port it easily. You can also use a cross platform framework such as Qt or wxWidgets for the window & GUI elements. Adding a scripting language to non critical parts is also nice. :)

Chaoz
A: 

As most have noted here, you are almost certainly going to need C/C++ for your graphics in the end particularly for your high performance (graphics) requirements.

However there might be an opportunity to develop the "core" as you call it, in a scripting language which in turn is easy to embed within a C/C++ application. In which case, the top 2 scripting languages to look into would be Lua and Tcl.

Lua in particular is used in WoW among others I'm sure. Tcl on the other hand has more "batteries included" (libraries).

George Jempty
+1  A: 

I really recommend using Lua for any scripting. It is an ANSI C library so that means that a: it can be compiled in (at least most) C++ compilers, and: if there's a C compiler for the platform then you can use lua. It allows for significant extension of flexibility of your game and if you want it will let your players customize it too!

RCIX
A: 

I'd recommend C++ for large cross-platform projects as well. But I think what's also important are the build-tools you use. For example SCons or CMake can create project files/makefiles for most compilers under Windows/Linux/MacOS.

Maurice Gilden