Followers 0

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

## 29 posts in this topic

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?
0

##### Share on other sites
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.
1

##### Share on other sites
Quote:
 Original post by SoldierXBut 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.
0

##### Share on other sites
- 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.
-1

##### Share on other sites
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++.
0

##### Share on other sites
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?
-1

##### Share on other sites
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.
0

##### Share on other sites
I get the whole performance argument, but would Java not be an option (C++ like syntax, cross plattform, some game libraries...)?
0

##### Share on other sites
Quote:
 Original post by SoldierXBut 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.
-1

##### Share on other sites
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.
0

##### Share on other sites
Quote:
 Original post by TelastynC++ 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?

QFT!

Of course, everyone here (myself included of course) is biased so you're only really true answer will come from evaluating the possibilities and making you're own decision. Personally, I'll never touch C++ again. It's just not worth the frustration. I'm not doing cutting edge games and I only care about Windows PC, 360, and soon Windows Phone 7 so C# and XNA Game Studio are perfect.
0

##### Share on other sites
Quote:
 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.

I think you're taking most of these arguments -- at least, most of the valid arguments -- out of context.

I think you are overestimating the impact of the "performance advantage" of C++. It is a language allows for fast code to be obtained decently easily because of its lack of basically any high-level features and it's bend towards paying only for what you use. To write truly stellar code with it, however -- just like with any other language -- you have to know it very well.

C# plus some kind of OpenGL wrapper may be an option (XNA is eliminated by your desire to deploy to Macs and Linux, of course). As are all the other languages mentioned in this thread -- Java, Python, et cetera.

The correct answer is thus to use the one you are most familiar with it -- whether that be C++ or something else -- because that's the one you will be most productive with and the one you will be able to write the most efficient code with.
0

##### Share on other sites
Im just going to say that before you choose your language... DESIGN the program first and do an honest assesment of your abilities. Then you will know what you actually will need.

Having a learning experiance can in fact be a legitimate goal of the program. If you want to be a generalist then you need to aquire experiance in many languages including the dreaded C++. If you prefer to become a specialist then select your language and make all your projects fit it.

ANSI C is an almost universal language but is also an easily abused one. It requires a lot of care and discipline by the programmer to write quality code. Much of what other languages offer is in fact availible to ANSI C as a matter of program design.

0

##### Share on other sites
I would confirm BrianLarsen's statement.
Quote:
 ANSI C is an almost universal language but is also an easily abused one. It requires a lot of care and discipline ...

C++ is neither good nor bad. It gives the programmer full control
and some shortcuts.
Thats the dangerous thing about it. You get seduced to use these
shortcuts rather than doing it the right way which will make your
Python forces you into the "right" direction and ofcourse takes a
lot of work away from the programmer to the VM but my opinion is
that this does suppress the own style of a programmer.
Java is a choice too and a good one for platform-independece but it
has its cons like every VM driven language.
Finally it is mainly a choice of what language is your favourite and
how well you structure your code.
2

##### Share on other sites
My own interpretation of the answers, so far:
-C++ doesn't suck, use it.
-Python is a good way.
-C# has several interesting engines/frameworks.
-Write most code in Python, with some parts in in C++.
-Cross-platform is stupid.
-Any language, blah blah.
-Java is a good way.
-UDK. (?!)
-Java is a good way - again.
-C++ doesn't that much of a "performance advantage". Any language, depending on what you are most familiar with.
-Design first. Choose language depending on what you want to learn.

First of all, thanks everyone for the replies. Secondly - you sure don't agree with each other.

One thing that I find interesting is that some people avoid C++ because it is unproductive. "Write less code and make fewer errors, by choosing this better language", they say, and point at some other new cool language like Python. Sure, I like Python. I really do. And I like C# too. But tell me - is it really that more productive to write something with OpenGL in C#, than it is to use a good mature 3d engine with C++ (Irrlicht, Ogre) ?

The thing is, I havn't come across that many _mature_ game-related libraries for those languages. I will, however, keep looking.

As it seems right now, I will probably stick to C++, using Python for some scripting. I might give C# a chance, if I find a 3d (or game) engine that suits me.

And by the way, I'm not a "n00b" trying to make a new cool mmorpg. Sorry to disappoint you. Just trying to get back to my game development hobby.

0

##### Share on other sites
Quote:
 Original post by SoldierXOne thing that I find interesting is that some people avoid C++ because it is unproductive. "Write less code and make fewer errors, by choosing this better language", they say, and point at some other new cool language like Python. Sure, I like Python. I really do. And I like C# too. But tell me - is it really that more productive to write something with OpenGL in C#, than it is to use a good mature 3d engine with C++ (Irrlicht, Ogre) ?
No. It is most productive to use C# or Python or Java or whatever with an engine. For instance, if you're set on Ogre, you could use MOGRE with C# or Python-Ogre with Python or Ogre4j with Java. Or you could use an engine that's designed to work with your language of choice, rather than being bound to it, such as XNA with C# or Panda3D with Python or jMonkeyEngine with Java.
Quote:
 The thing is, I havn't come across that many _mature_ game-related libraries for those languages.
Maturity is always an issue when looking for open source libraries. Certainly some of the libraries I mentioned up there are crud. 90% of libraries for these languages are crud, but that's because 90% of libraries are crud. Standard crud-avoidance strategies apply.
0

Use D.
0

##### Share on other sites
SoldierX, I think you came to a good conclision.

I kind of miss some level of experience attached to what people write in forums. If someone played around with c++ and decides its not good how strong can such an argument be?

I have been developing games in in C for over 20 years and C++ over 15 years. I am almost programming daily. And frankly can find no argument against the language.

When I first checked out XNA I stumbled upon C#. Later with iPhone Development I saw this funny looking syntax called Objectiv-C. Now I am glad I wrote a nice C++ wrapper for iPhone. My code base compiles on every platform I have been so far. I am sure if you were to stick to anything besides C/C++ this would not be the case.

As for "scripting" languages this is something else. As I don't see them suitable for engine development, but more gamelogic and so forth.

Looking back I am happy with the way I went. (especially since back then people said Pascal would rule the world. lol)
However I can actually not really judge if C/C++ is the right way to go if you start all from scratch. Time is moving.
0

##### Share on other sites
Quote:
 Original post by AntheusFood for thought.

What I would take away from that is that reusing and updating existing code as needed is good. Reusing engines is good.

What I wouldn't take away from that, nor the comments section, are the comments on the 'games industry' as a whole. He, and his commenters, appear to have missed that MANY games do reuse the same engine, just an updated version of it.

My favorite comment cited Valve as a good example of 'engine reuse' which is true... it's just that TF2, L4D and Portal all used an engine which had been updated from the original Half-Life.

So; once again, code and engine reuse good.

And while this guy might be doing well his view that he is the only one doing it places his head firmly up his bottom region I feel [smile]
0

##### Share on other sites
Vogel's comments re: Blizzard/Activision losing money are also entirely off base. Nonetheless, I like the article's primary point about code reuse.
0

##### Share on other sites
Quote:
 Original post by phantomWhat I would take away from that is that reusing and updating existing code as needed is good. Reusing engines is good.

I read it more as making something that users care about. The rest are just tools used to accomplish that.

Regardless of how people feel about Zynga, they've pushed it to the extreme. Everything is tailored around user behavior. They manage it through profiling and split testing, but those are yet different tools of achieving the same goal.

No product in history ever succeeded or failed because of Language X or API Y.

How many people would believe that a PHP MySQL app can affect the lives of half a billion people and transform the web landscape? Also, iFart.
0

##### Share on other sites
Quote:
Original post by phantom
Quote:
 Original post by AntheusFood for thought.

What I would take away from that is that reusing and updating existing code as needed is good. Reusing engines is good.

So true. This is why I kind of hate the game industry: it seems that the code only should exist and work until the game is released, then it doesn't matter anymore. More code (and other assets as well) reuse! :)

0

##### Share on other sites
Quote:
 Original post by SoldierXMy own interpretation of the answers, so far:-C++ doesn't suck, use it.

I really hope no one ever told you that it sucked... C++ doesn't suck. C++ IS hard though. It's not an easy language to learn right, and it's not an easy language to use right. Part of that is due to its design. As demonstrated in a recent thread here, people can think they know what they're talking about in C++ and really have no clue at all. The language is just that complex.

It's mainly due to the design of the language. C++ was build with performance in mind: You don't pay for what you don't use. As such many parts of the language result in undefined or implementation defined behavior to allow compiler vendors the ability to perform optimizations that were either known at the time, or unknown future optimizations. A prime example is that of the evaluation of function parameters, it's unspecified for a reason. However, that very element of being unspecified means that you can cause undefined behavior unintentionally with a single call:
f(a++, a, a++);

It looks innocent enough, but that's actually entirely undefined.
Quote:
 -Python is a good way.-C# has several interesting engines/frameworks.

Indeed, and many other languages have similar frameworks exposed for them. Some are more mature than others, some are easier to use than others. It's really a pick and choose world. Go for what feels the most comfortable to use.
Quote:
 -Write most code in Python, with some parts in in C++.

Not necessarily, but... game code needs to be quick and easy to change, so that you can quickly test new concepts and ideas with minimal setup time. This is why scripting languages are so popular. That doesn't mean everything has to be python, or that even the majority does... Just delegating the gameplay code to python, for instance, will save a significant amount of development time.
Quote:
 -Cross-platform is stupid.

No, cross platform isn't stupid. But it is HARD to do. People like to talk about C++ when they're talking cross platform, but C++ code is rarely cross platform unless restricted to a minimal subset of the language. Compiler differences, library differences, and other issues crop up otherwise. Cross platform isn't something you should strive for in your first project, but if this is a few steps down the road, then it's a good idea to get used to the frustrations related to distribution and building of a cross platform project. That means more than just writing code that builds everywhere. Games are distributed in binary form, which means that if you want it to work on linux, you'll need to package up all of your dependencies.

It's also important to note that many language are perfectly cross platform... Mono project has MonoXNA, Java and JOGL, and so on.
... skipping ahead a bit ...
Quote:
 -C++ sucks. Microsoft platforms is the only good way. Yadda yadda.-C++ doesn't that much of a "performance advantage". Any language, depending on what you are most familiar with.

Microsoft has the best tools for development I've ever used... and having been developing software for a bit over 20+ years now... that's quite an accomplishment. That doesn't mean their compilers are the most compliant, or produce the best code... but the tools you use to develop with are simply the best.

C++ doesn't have a performance advantage, not much of one anyways. Let me explain: You get approximately a 5% performance bonus over C# managed code "some" of the time. Usually in relation to floating point calculations. This is actually not due to any superiority of the C++ compiler over the .Net JIT, but actually has to do with the requirements the .Net standard requires for the JIT. There are limitations placed on the JIT to enforce a certain level of floating point consistency between calculations, it doesn't completely eliminate floating point error, but it does reduce it significantly for most cases.

The reality is, anytime you need truly fast performance, you'll write your code in a highly optimized SSE enhanced manner, and not in plain old C++ or C#. At which point both choices gain the same performance benefits, even if the manner in which you interact with them differ slightly. Combined with tools like my SlimGen project, which allows you to replace method bodies with hand written assembly (for now), you can gain the benefits of native code and the speed of RAD. Also, in C++ your default associative container (that most people think of), is std::map, which is a tree based map with and amortized O(log N) looku , while the default associative container in .Net is the dictionary, which is a hashmap that has an amortized O(1) lookup...
Quote:
 -Design first. Choose language depending on what you want to learn.
Don't have a BDUF. It doesn't work 90% of the time, but do have a design, yes.
Quote:
Exactly.
Quote:
 First of all, thanks everyone for the replies. Secondly - you sure don't agree with each other.
Why should we? Many different levels of experience, many different perspectives, and many different backgrounds.
Quote:
 One thing that I find interesting is that some people avoid C++ because it is unproductive. "Write less code and make fewer errors, by choosing this better language", they say, and point at some other new cool language like Python. Sure, I like Python. I really do. And I like C# too. But tell me - is it really that more productive to write something with OpenGL in C#, than it is to use a good mature 3d engine with C++ (Irrlicht, Ogre) ?
Python's not that new, nor is C#... it's newer than C++ though. But C++ has only been standardized since 1998 and hasn't evolved much since then. Heck, C++0x isn't even completed yet, and after it is completed you can expect to way probably 5 more years before compilers sufficiently support the new feature sets.

Regarding the speed of development: It depends. There are .Net ports of many of those common C++ engines (Irrlicht, Ogre, etc), and they also suffer from many of the problems that their C++ cousins have (Singletonitis comes to mind). Combine that with the fact that it really is hard to write code that is buggy at a non-logic level in managed languages and you quickly find yourself writing a game, not debugging that random crash that happens only in debug mode, and not release mode.
2

##### Share on other sites
Quote:
 Original post by WashuNo, cross platform isn't stupid. But it is HARD to do. People like to talk about C++ when they're talking cross platform, but C++ code is rarely cross platform unless restricted to a minimal subset of the language. Compiler differences, library differences, and other issues crop up otherwise. Cross platform isn't something you should strive for in your first project, but if this is a few steps down the road, then it's a good idea to get used to the frustrations related to distribution and building of a cross platform project. That means more than just writing code that builds everywhere. Games are distributed in binary form, which means that if you want it to work on linux, you'll need to package up all of your dependencies.It's also important to note that many language are perfectly cross platform... Mono project has MonoXNA, Java and JOGL, and so on.

I believe most developers that start out with this requirement (not counting the clueless ones who list Linux as a target and go on to choose something clearly incompatible) do so because of a desire to develop on Linux, and/or to specifically address the small but underserved Linux game market, i.e. themselves. Considering cross-platform issues is a natural goal in that case.

Other than that, I'd just say I think actually getting started is more important than worrying about your language choice. Nobody says you can't take a break from the main project and write a small demo using different tools, and incorporate those tools if you like them. In fact I think having little toy projects on the side is usually recommended so you don't burn yourself out.
0

## Create an account

Register a new account