So you say C++ sucks? What else can I use?

Started by
28 comments, last by guywithknife 13 years, 12 months ago
Nowadays, it's pretty common to see people bashing C++ of various reasons (too complex, etc.). Most of these arguments are totally correct - there are a lot of other programming languages that are more simple, less error prone, and so on. But now I planning to start a rather advanced game project, and I want it both to be cross-platform (Win+Linux+Mac, that is) and have high performance (stunning 3d graphics, yadda yadda). So, C++ fulfills these requirements. But what alternatives do I have? -C#/.XNA. Classic choice these days. But as far as I know, it only runs on Windows (and XBox, of course). Pretty pointless here. -Python. Cross-platform, and a lot of game related libraries seem to exist. But performance-wise? Okay, some of you might say the classic "But just rewrite the heavy parts in C/C++", and I guess you're right. But isn't that a little bit against the whole idea of keeping the code simple when writing in Python? Am I wrong? To me, it would seem more effective to use it to script a C++ game, instead of extending a Python game with C++ code all over. And, if the game is supposed to be a competitive multiplayer game, wouldn't it be a little too easy for the hackers if they just had to change in a bunch of plain-text .py-files? Are there other language choices? Are there any good non-XNA cross-platform C# game/graphic engines that runs on Mono, maybe? Or should I stick good old C++ and just shut up?
Advertisement
C++ doesn't suck. Unfortunately these days it's very popular to bash it, especially by people who don't know the language.

You won't reap the benefits of using C++ unless you pay the price to truly learn it. You can argue that you don't have the time or desire to do so, but don't expect to find something else that has the same advantages (specifically, the excellent balance between high level abstraction and performance) while somehow being "easy" or less complex.

If C++ isn't the right tool for the job, then don't use it. However, if you're looking for a C++ replacement, then you should just use C++ (and invest whatever is necessary to become more fluent). It's not perfect (what is?) but it is extremely good at what it does, which is to provide high abstraction capabilities while maintaining high performance.
Quote:Original post by SoldierX
But now I planning to start a rather advanced game project, and I want it both to be cross-platform (Win+Linux+Mac, that is) and have high performance (stunning 3d graphics, yadda yadda).

At this point, language certainly is not your only problem. Did you think about how to create the content for your game? What about tool support? What about gameplay testing/iterating? What about testing the game on the various platforms and system configurations?

Quote:-Python. Cross-platform, and a lot of game related libraries seem to exist. But performance-wise? Okay, some of you might say the classic "But just rewrite the heavy parts in C/C++", and I guess you're right. But isn't that a little bit against the whole idea of keeping the code simple when writing in Python? Am I wrong? To me, it would seem more effective to use it to script a C++ game, instead of extending a Python game with C++ code all over.

You can go either way - both approaches have advantages and disadvantages. There's recently been some discussion about them on the forums here, but I forgot on which board. Either way, you can take Panda 3D as an example: the engine is written in C++, but Python code can simply use it as a module.

Quote:And, if the game is supposed to be a competitive multiplayer game, wouldn't it be a little too easy for the hackers if they just had to change in a bunch of plain-text .py-files?

You can compile Python code (.pyc files), so at least it's no longer plain text. Or pack them up into some encrypted archive file. Still, everything can be reverse-engineered. Clients should never be trusted. You'll want the server to verify their actions.


EDIT: @strtok: from what I've seen, it's mostly the experienced programmers here that 'bash' C++ - those that have been using it for a decent amount of time. It may be performant (if, indeed, you know how to use it), but it doesn't lend itself well for rapid development. This makes it a poor choice for gameplay code, which often needs to be refined.
Create-ivity - a game development blog Mouseover for more information.
- There's also C#/OpenTK, which runs on Windows/Linux/Mac and opens the possibility for an iPhone port. This is low-level OpenGL/OpenAL/OpenCL but it's about 2x more productive than using the APIs from raw C/C++.

- Alternatively, Unity3d is a great 3d engine that is scripted in C#. Sadly, it's only available on Windows/Mac/iPhone (no Linux).

- Panda3d is a good, solid choice.

- Blender game engine is another solid choice. Bonus points for being integrated into Blender, giving you an interesting development path (create assets in Blender, click on "play" and test).

- Axiom is a C# port of Ogre3d. No idea if it's any good, though.

- KRI engine has some very very interesting features (Boo+OpenTK, usable by .Net languages) but it's not really ready for wide use. I'm keeping an eye out for it, but it's not for the faint of heart, yet.

[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]

Quote:Original post by SoldierX
-Python. Cross-platform, and a lot of game related libraries seem to exist. But performance-wise? Okay, some of you might say the classic "But just rewrite the heavy parts in C/C++", and I guess you're right. But isn't that a little bit against the whole idea of keeping the code simple when writing in Python? Am I wrong? To me, it would seem more effective to use it to script a C++ game, instead of extending a Python game with C++ code all over.


This isn't logical. Adding a small bit of C++ to Python code doesn't ruin the Python code, nor does it make it as complex as having done the whole thing in C++. It just means you have a middle ground.

It would only be more effective to stick to scripting with Python if you feel that writing most of your game in C++ is easier and/or quicker than writing most of it in Python and rewriting some modules in C++. Personally I don't think it would be. Writing most code in Python is so much faster and easier that I wouldn't choose to use C++ unless I had to, and there are many tools to make the Python/C++ crossover easy these days, eg. Cython.

Quote:And, if the game is supposed to be a competitive multiplayer game, wouldn't it be a little too easy for the hackers if they just had to change in a bunch of plain-text .py-files?

Security needs to be done primarily on the server, not the client.

Besides, if you really want extra security through obscurity, we've already established that you can code parts in C++.
C++ sucks. That said, it's probably your best option if cross-platformness is a hard and fast requirement. I would question that requirement though. It forces some of your design decisions and limits your ability to get the game done. For what? Maybe 5% more users in the ideal scenario?
What language doesn't meet those requirements? Just about every language I can think of offers decent performance and a C interface to use libraries like opengl. The slower languages I can think of all offer a way to get a C module loaded to handle performance critical stuff. If I were looking for an easier to use language that wouldn't need to piggy back on another language I would look at C#, Ocaml, C, Haskell, Java, factor in about that order.
I get the whole performance argument, but would Java not be an option (C++ like syntax, cross plattform, some game libraries...)?
Quote:Original post by SoldierX
But now I planning to start a rather advanced game project, and I want it both to be cross-platform (Win+Linux+Mac, that is) and have high performance (stunning 3d graphics, yadda yadda). So, C++ fulfills these requirements. But what alternatives do I have?

UDK.
I agree on the "Java" choice.

I used LWJGL for rendering and it's good enought. Recently I changed to JOGL, wich has a "cleaner" way of doing some tinks, but I recommend both.

This topic is closed to new replies.

Advertisement