Skip to main content
gamedev.net
🔒 Locked

is c++ really a must?

Started by Subalee Jun 19, 2013 at 7:36 PM 51 replies 9.3k views
Original Post
Subalee
Subalee

Hey everyone, i was wondering if c++ is really a must in game industry. Not that because i'm not able to learn it or anything like that. The thing i'm aware of is spending my time on learning language which i may not use like ever.

Today, I came across this interview which really made me thinking and really don't know what to make of that

http://harmful.cat-v.org/software/c++/I_did_it_for_you_all

The reaseon i'm not sure if i should study c++ is the possibility that i may not end up in a game industry at all (small european country, not US unfortunately)

Do you think c++ will be standard for many years to come (10-20) or will it be replaced since the hardware power is increasing so rapidly?

Another question i had is about unity and their scripting languages. Unity seems like a good starting point but which language should i script in? I build some websites from time to time, but i don't know any JS yet and i'm worried that unityscript, which is some sort of old JS (correct me if i'm wrong), will teach me some bad habits. C# seems like a much more usable not only in game programming but in other development. The problem with C# is that it's .NET based, but tha'ts just my opinion...

So anyway looking forward to any answers that could point me in the right direction

Promit
Promit

Setting aside the satire -- YES, knowing C++ is a must for being in the industry. Not all games are written in C++ and not all game programmers know C++, because there are many types of games and game programmers. But if we're talking about anything resembling the mainstream game industry, C++ is mandatory even if the game is not written in it. It's a core part of the relevant education and I wouldn't even think about hiring someone who is not fluent in it.

SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
frob
frob

Lots of people make games in Java, Flash/ActionScript, C#/XNA, Python, JavaScript, and many other languages.

You absolutely can create games without knowing C++.

But that is not quite what you asked.




Do you think c++ will be standard for many years to come (10-20) or will it be replaced since the hardware power is increasing so rapidly?
That is a dramatically different question.

The answer is 'yes', but only for some types of games.

There are many kinds of games. Most games, from Tic Tac Toe to Farmville, do not seriously tax the hardware. They can be written in any language you like. Some games fall into a very different class of software; these games fall into the range of High Performance Computing (HPC), and they push the limits of what computer hardware can do.

Although you can write non-HPC games in any languages, your choices are very limited when it comes to HPC games. Even C++ was shunned until the mid 1990s for HPC of all sorts.

Let's consider just one aspect of modern programming languages that is a real issue in high performance computing engines: The use of virtual functions.

Many common patterns in C++ such as the common use of virtual functions, such as using virtual accessors and mutators. On today's hardware the cost of a virtual function is roughly 7 nanoseconds over the cost of a direct function call; back in 1995 the cost was around 100 nanoseconds. But how big is that in the engine?

There has only been one real comprehensive study of the costs of the language, and it was done back in '96. A paper called The Direct Cost of Virtual Function Calls in C++ studied the actual cost in several compute-intensive open source solutions, and found that the "spend a median of 5.2% of their time and 3.7% of their instructions in dispatch code." There is no evidence that the numbers have changed dramatically since then.

For non-HPC games that 5% of your compute time is not an issue, the games have compute cycles to spare. But when you are working on a high performance engine, the simple use of virtual functions that cost you a 5% performance penalty is a real concern. You can certainly use virtual functions, but you do so in cases where alternate solutions are more expensive.

This is why many game programmers, especially game optimization engineers, tend to be stuck in a "C with classes" view of C++; the cost of the feature is incompatible with high performance computing.

It is not that the feature is bad. In most cases virtual functions are great. They reduce development time and solve many real problems. But they have a cost, and if you are in the middle of a performance-critical area the cost is frequently unacceptable.

It may not seem like much, but it does add up in performance critical code. Do you want 5% more eye candy?

That is just one issue of the many issues you get in a HPC game engine. HPC engines will continue to extract every cycle they can, even turning to hand-tuned assembly in those most performance critical loops. That is the nature of the type of game.

Video game consoles, the PS4 and XBox One, are going to be the standard for the next five or more years. These consoles focus on HPC games to maximize eye candy. The core engines will continue to be "C with classes". On the PC, there will always be AAA games that push the hardware to the limit. These are HPC games. They will also continue to be "C with classes" in their core engines.

As processors become more powerful games can do more without becoming HPC games, but that does not mean that HPC games will cease to exist.

Madhed
Madhed

Learn programming, not languages. When you have mastered different programming paradigms (object oriented, procedural, functional, ...) it shouldn't take you too long to pick up a new language. It's mostly syntax.

SimonForsman
SimonForsman

Hey everyone, i was wondering if c++ is really a must in game industry. Not that because i'm not able to learn it or anything like that. The thing i'm aware of is spending my time on learning language which i may not use like ever.

Today, I came across this interview which really made me thinking and really don't know what to make of that

http://harmful.cat-v.org/software/c++/I_did_it_for_you_all

The reaseon i'm not sure if i should study c++ is the possibility that i may not end up in a game industry at all (small european country, not US unfortunately)

Do you think c++ will be standard for many years to come (10-20) or will it be replaced since the hardware power is increasing so rapidly?

Another question i had is about unity and their scripting languages. Unity seems like a good starting point but which language should i script in? I build some websites from time to time, but i don't know any JS yet and i'm worried that unityscript, which is some sort of old JS (correct me if i'm wrong), will teach me some bad habits. C# seems like a much more usable not only in game programming but in other development. The problem with C# is that it's .NET based, but tha'ts just my opinion...

So anyway looking forward to any answers that could point me in the right direction

I'm fairly certain that C++ as we know it today (C++11) will start to be replaced in less than 10 years, however it will most likely be replaced by a newer version of C++. (C++ is severely lacking both as a high level language (no good support for parallell programming for example) and as a low level language (why do we have to use non portable compiler specific intrinsics or worse, inline cpu specific assembly to execute basic SIMD instructions ?)

C++ really is like frankensteins monster, stitched together pieces from a whole bunch of different languages and paradigms where you can pick and choose which pieces you want to use (and more importantly for cutting edge game engines, what parts you are willing to pay for), it is far easier to stitch a few more pieces on the monster than it is to move millions of lines of code over to a new language so it will most likely stick around, in one form or another for a very long time.

Learning C++ is a good idea because of its popularity but its not the only language you should learn nor is it likely to be the only language you will use, do not worry about learning the "wrong" language, there is no such thing and there are valuable lessons to be learnt from using almost any language that exists.

[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
proto_typical
proto_typical

C++ is not needed, however it's a very popular language for console games and if console game development is your goal, the answer is simply - YES.

Learning C++ certainly isn't going to be an irrelevant endeavor, and what you learn is highly relevant to any other Object Oriented Language.

But certainly if you decide to learn Objective C, Java, C#, there is a wealth of conceptual knowledge of both making games and programming in general that are applicable to developing games in any language.

The question for you is... What do you want to do ? If you want to make console games, start learning C++ now.

If you want to make mobile games, you might want to learn Java, C#/Unity, Objective-C or C++.

If you want to make web based games, you might look at Javascript or Flash/Actionscript.

I also agree with what one poster said, learn "programming". Once you have learned one object oriented language, picking up another is not nearly as intensive as learning the first.

ChaosEngine
ChaosEngine




Do you think c++ will be standard for many years to come (10-20) or will it be replaced since the hardware power is increasing so rapidly?

Hardware power isn't actually increasing that rapidly. Certainly not for consoles anyway. If we look at the last few generations:

the gap between the ps1 and ps2/xbox was massive

between ps2/xbox and ps3/xbox 360 less so

and even less so again between current gen (ps3/360) and "next gen" (ps4/xbone).

Basically it's a law of diminishing returns.

So yeah, C++ will still be required for AAA titles (at least until something better becomes more common).

But as previously pointed out, you can still happily make games with plenty of other languages.

Besides, knowing C++ is only half the battle. I'm a pretty fair C++ programmer (have worked professionally with it for over a decade), but I know very little about programming a games engine. There's learning about 3d math, component systems, etc.

if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight
alnite
alnite




The thing i'm aware of is spending my time on learning language which i may not use like ever.

You will use the knowledge you learned in C++ in other things. Don't assume that learning C++ only applies to C++. You will surprised how much of the little things can be applicable to other languages. Identifying performance issues, ambiguous syntax, memory allocations, are some of the FUN things that you learn in C++.

Dynamo_Maestro
Dynamo_Maestro

Why does this question keep getting asked? Is there some organisation out there determined to discourage everyone programming games in a different language OR are people just not using the search function?

RLS0812
RLS0812

The thing i'm aware of is spending my time on learning language which i may not use like ever.

You will use the knowledge you learned in C++ in other things. Don't assume that learning C++ only applies to C++. You will surprised how much of the little things can be applicable to other languages. Identifying performance issues, ambiguous syntax, memory allocations, are some of the FUN things that you learn in C++.

By fun, you mean spending weeks trying to find an obscured memory leak caused by an imposable to find pointer ?

I cannot remember the books I've read any more than the meals I have eaten; even so, they have made me. ~ Ralph Waldo Emerson
Bacterius
Bacterius

Why does this question keep getting asked? Is there some organisation out there determined to discourage everyone programming games in a different language OR are people just not using the search function?

Because C++ has symbols in its name so it must be for pro's and that if you don't know C++ you'll never get a job, I guess that's the reasoning behind it. I think it's natural to wonder, since people typically seek some form of return on investment and that applies to learning languages as well (evidenced by the "what if I end up never using it" reply above), but in this case, since programming concepts are mainly language-agnostic, I think it's really not that important. A good programmer who knows, say C#, but nothing about C++ can pick it up in a few days and become proficient in a few months.

I think knowing more than one language is far more important than becoming a guru in a single one, because even though the core of your game might be written in C++, the rest will likely be using other languages and perhaps even scripting languages, like C#, Lua, Python, and so on. But as we all know, when you have a hammer, everything looks like a nail. Programming is also about using the right tool for the job, and by sticking with a single language you are severely hampering your ability to do that.

So the bottom line is, yes, learn C++. Why not? It can only benefit you and frankly doesn't take that long. Becoming productive in C++ isn't a 20-year ordeal like some people would have you believe, unless you really want to know *everything* about the language and that isn't necessary to make games (not that I'm saying it's a bad thing to do so)

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”
alnite
alnite

The thing i'm aware of is spending my time on learning language which i may not use like ever.

You will use the knowledge you learned in C++ in other things. Don't assume that learning C++ only applies to C++. You will surprised how much of the little things can be applicable to other languages. Identifying performance issues, ambiguous syntax, memory allocations, are some of the FUN things that you learn in C++.

By fun, you mean spending weeks trying to find an obscured memory leak caused by an imposable to find pointer ?

That. And buffer overlows :D

ChaosEngine
ChaosEngine




A good programmer who knows, say C#, but nothing about C++ can pick it up in a few days and become proficient in a few months.

While I agree with the rest of your post, but I have to say this is just wrong (and demonstrably so. See if you can find Washus old C++ quiz). C++ is full of little quirks and gotchas that constantly surprise people who have been working with the language for years, never mind those who have just learned it. Scott Meyers has pretty much made a career out of it.

TBF, all languages have their idiosyncrasies, but C++ has way more than most.

A C++ programmer going to language x will almost certainly have an easier time than the other way round.

if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight
Dwarf King
Dwarf King

Yes you have to. [rant begins]Sadly many CS programs are Java schools now, had to learn some my self by self study...[rant ends]

"The only thing that interferes with my learning is my education" Albert Einstein "It is a miracle that curiosity survives formal education" Albert Einstein  
swiftcoder
swiftcoder

A good programmer who knows, say C#, but nothing about C++ can pick it up in a few days and become proficient in a few months.

In the other direction (C++ -> managed language), sure. Managed language -> C++? Not so much.

I have watched it takes years to convert a skilled Java programmer to even a moderately competent C++ programmer. The language has so many damn foibles and edge cases that if you don't cut your teeth on it early, it's an uphill battle.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
_the_phantom_
_the_phantom_


A good programmer who knows, say C#, but nothing about C++ can pick it up in a few days and become proficient in a few months.

In the other direction (C++ -> managed language), sure. Managed language -> C++? Not so much.



Even going the other way isn't quite as easy as people think; I'm mainly a C++ monkey but I do know C# and can write C# apps with little problem... the issues is I tend to write BAD C# apps which would make a full time C# developer cry. Granted, I'm getting better at writing more idiomatic C# as I write more of it but I'm still aware I'm doing bits poorly.
Katie
Katie

"Hey everyone, i was wondering if c++ is really a must in game industry."

Yes. It's in all the job adverts.

It doesn't matter if you, or I or anyone on this thread thinks it's a must or not. It's on the job adverts. If you don't have it, you'll find it hard to get a job. Unfair! Unfair!! Rant, rave etc. Doesn't matter. Learn it.

SimonForsman
SimonForsman

A good programmer who knows, say C#, but nothing about C++ can pick it up in a few days and become proficient in a few months.

In the other direction (C++ -> managed language), sure. Managed language -> C++? Not so much.

Even going the other way isn't quite as easy as people think; I'm mainly a C++ monkey but I do know C# and can write C# apps with little problem... the issues is I tend to write BAD C# apps which would make a full time C# developer cry. Granted, I'm getting better at writing more idiomatic C# as I write more of it but I'm still aware I'm doing bits poorly.

The big difference really is that managed languages won't blow up in your face as easily, it is easier to get by with Java or C# without actually knowing the language and its quirks as the most common result of doing things wrong is suboptimal performance, which is preferable to memory leaks, security holes, undefined behaviour and seemingly random crashes.

If we take Java for example, can one of the C++ programmers here write a code snippet in Java to create a string containing the numbers 1 to 10.000 separated by commas ?

[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Subalee
Subalee

Wow, now i feel really dumb because of believing that satire :/ Anyways thanks for clearing things up for me. I have to admit that I'm shocked how many replies I got. Really nice forum! thanks everyone :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.