Why companies still use C++ and what should I learn then

Started by
45 comments, last by kop0113 10 years, 8 months ago

Additionally, C++ is much older than any of those technologies.

Thats why I was very careful to specify versions of all the technologies I listed to be around the same age but for some reason you have assumed that by me saying pre-tr1 I must have meant the version of C++ straight after it was named from C with classes ;)
C++ from that age doesnt really give us much of that precious reusable legacy code anyway. It would probably be easier to port from java than from how C++ used to be.
I helped out on porting the newly open-sourced CDE to run on FreeBSD and the C (and C++) they used was c r u s t y! Though I am glad they stuck with it rather than just make a new language because I quite like C++ how it is today.

You have a highly amusing view of the future.

My view of the future is certainly not amusing since it involves technology and innovation crumbling under the heavy hammer of DRM and app stores. There is no future for developers... ONLY STORES!!

http://tinyurl.com/shewonyay - Thanks so much for those who voted on my GF's Competition Cosplay Entry for Cosplayzine. She won! I owe you all beers :)

Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.
Advertisement

Many companies DON'T use C++ at all. In some industries the use of C++ is extremely rare or even completely denied simply because its not a very tolerant and safe language. In the game development world though, things are a bit different.

There are a few reasons why things are different in game development, and the biggest reasons have ABSOLUTELY NOTHING to do with performance. People to claim C++'s "performance" is the reason its used in game development couldn't be more wrong. The two biggest reasons C++ is used are:

  • Legacy code, and lots of it.
  • The platforms they're targeting (such as PS3/XBox/PS4/Xboner) ONLY support C and C++ targets (for AAA games).

Many AAA games are written, these days, targeting consoles first, and then ported over to the PC. There are big reasons for that, namely the number of units shipped is usually significantly higher for consoles than for the PC. When you're looking at shipping millions of units on a console versus hundreds of thousands on the PC it quickly becomes obvious which one is a better market choice. However, with the exception of XNA (and not long for that either), none of the current generation of consoles supports anything except for C and C++. Some games have been written in Scheme (GOAL actually), however those used a compiler that produced PS2 machine code that was written in house by the developers.

It is also important to understand that legacy code is a very big thing, you have libraries that manage resources, libraries that manage memory, various forms of standard libraries (containers, algorithms, etc) that have all been written over the years using C and C++. Thus it is important, from a business perspective, to squeeze as much value as you can from those artifacts. Thus the legacy aspect comes into play. If you look at something like EA Sports... they've been hammering at the same code base for nigh unto a decade now. That's a huge amount of functionality and code that has been produced which would need to be tossed and rewritten should they move to another software platform (such as .Net), assuming one even existed for their target consoles.

As for what languages you should learn first? Your goal as a newbie programmer is to learn PROGRAMMING. Not optimization, not a programming language, not "low level" nonsense that people like to claim is the benefit of learning C++ first. No, your goal is to learn to program. Software development. The art and method of solving problems through strategic application of algorithms, data structures, and logic. This skill is independent of ALL languages, but it is EASIEST to pick up when you start with a language that is EASY TO LEARN. C++ is NOT THAT LANGUAGE. C#, Java, Python, Lua... all of these are great starting points that can help you to get started and rapidly develop the appropriate thought processes, which you can then apply to learning a significantly more complex beast, like C++.

For those recommending C++ as a first language, here's a simple little quiz. Take it if you dare. Try not to cheat. I.e. answer off the top of your head, not with your compiler or with a textbook.

  • Given the following three lines of code, answer these questions
    • Is the second line well defined behavior?
    • If the second line is well defined, where does the pointer point to?
    • What are some of the legal operations that can be performed on the third pointer?
  • 
    int* p = new int[10];
    int* j = p + 11;
    int* k = p + 10;
  • What output should the following lines of code produce?
    
    int a = 10;
    std::cout<<a<<a++<<--a;
    
  • Assuming the function called in the following block of code has no default parameters, and that no operators are overloaded, how many parameters does it take? Which objects are passed to it?

    
    f((a, b, c), d, e, ((g, h), i));

Lastly, here's a list of links to similar threads on this issue:

This one enjoys fairly significant popularity. (Note that only threads containing significant discussion are included.)

1) Professional Games Made In C#?
2) Java for game development?
3) Java----C/C++
4) c++ or c#
5) Question about Java Vs. C# Vs. C++
6) Java Games?
7) Java is fast?
8) Secondary Language:VB or Java?
9) What makes C++ so powerful?
10) C# games and cheating...
11) Is C# good enough for system utility programming
12) MC++ vs. C#
13) Which language is best for a 3d Games Engine?
14) C# vs C++ as a choice for development
15) Is Java the Future?
16) why C# and not Java?
17) What do you think of the D language?
18) my c++ d c# benchmark!
19) The Definitive Guide to Language Selection
20) Sharp Java
21) C++ or C#?
22) C++ or C#?
23) Java disadvantages
24) C++ or C#?
25) Visual C++.net vs Visual C#.net
26) C# - huh?
27) which language should i learn?
28) C or C++ or C#
29) learn C or C++ ??
30) Is C still useful in gamedev?
31) Why C# XNA When Everyone Wants C/C++
32) JIT compiled code vs native machine code
33) C++ or C?

This particular list is my top ten, because of the sheer frequency with which they occur. 12 days, 10 threads.
1) c++ or c# (5/1/06)
2) Java for game development? (5/2/06)
3) Java Games? (5/3/06)
4) Java----C/C++ (5/3/06)
5) MC++ vs. C# (5/4/06)
6) What makes C++ so powerful? (5/9/06)
7) C# games and cheating... (5/9/06)
8) Is C# good enough for system utility programming (5/9/06)
9) Which language is best for a 3d Games Engine? (5/11/06)
10) C# vs C++ as a choice for development (5/12/06)

I realy enjoy what you are saying!
To me it seems like people are only focusing C++ just because industry like Blizzard, Riot, Bethesda, EA and others are using it.
Cause alot of us just want to stay Indie and make marvelous games that way, no need for C++.

I also believe that C++ is still used by big companies because it would cost and take tremendous of time switching to another language.
Why should they when they can get the same result using C++ as with C#...
Maybe things will change, but atm its no reason for the industry to waste time/money changing language.

Dont tell me that C# wouldent do the same trick making for example League Of Legends...
Bloodline Champion is an AAA game made with C#/XNA.

//Thomas Wiborg

I think for me it is more the fact that C# is capable but so is Objective-C, Java, Python, Haskell, VB, AS3, HaXe etc.. etc...

But the industry had to choose one and that is C++. I would have been just as happy if it was Java and I would then use Java but I simply wont suggest limiting yourself to niche languages (within the gamedev industry) needlessly.

The indie gamedev industry is a strange one in that many indie devs are effectively consumers of "game making" products (including languages) so if they have been sold on C# which is highly probable because Microsoft has invested millions in doing so in the past, then who am I to get in the way of their enjoyment.

Anyway, this is turning into a pointless language war so I am out (at least until the next one ;).

http://tinyurl.com/shewonyay - Thanks so much for those who voted on my GF's Competition Cosplay Entry for Cosplayzine. She won! I owe you all beers :)

Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.

I started out with C++ many years ago. For the last 10 years I've been doing C# as most companies except in a few niches(such as game dev and those working on legacy systems)appear to be shifting away. C++ devs I know who are looking for work struggle now(relatively speaking) and have to travel about a lot, whereas I've never been busier and can stay local.

I wont get into the argument about why game companies use C++. I will say that if I wanted to get into game development at a software house that used C++ and didn't use C#, I would just go and learn C++.

C++ and C# share a lot of similarities, but there are lots of differences too...and these can be confusing, especially if you're new to both. One small example is multiple inheritance, which is not allowed in C#. These kind of differences ultimately affect how you write the code and will be confusing for a beginner when you switch.

C# is a far more productive language, and I have to say I'm continually impressed by its performance. That said, the only reason I'd learn C# and C++ is if a likely future employer used both or if I want to make some software where the performance edge C++ might give you didn't outweigh the large productivity benefits given by C#.

In short, it depends on your particular needs, but if you're sure they (and you) will only need C++, just learn that to start with, in my opinion.

As a C# dev, C++ is still very useful to know, though. C# hides a lot of stuff, so having the basic understand of many of the concepts that C# wraps is very useful.

Programming is a task. The language is a tool you use to accomplish that task.

Just like any task, there are many ways and many tools you could use to accomplish that task both correctly and in a timely manner.

For example - Should you learn to use a hammer or a nail gun first? It really depends on what the job calls for but you are probably encouraged to continue to learn about any tools that can get the desired result.

In our company we generally hire people who have demonstrated the ability to learn multiple disciplines even if the one we are looking for isn't their strongest one (so long as they are proficient in it). Learning something is never a waste of time. You know what you can do and what is comfortable for you. Some people can pick up complex languages with relative ease, others need to wade in. The thread has given many opinions from people who work in your targeted industry (or claim to at least). The choice remains yours in the end however and your success will ultimately depend on how much you are willing to change and adapt to the employment environment you are seeking out.

It is not the strongest of the species that survives, nor the most intelligent that survives. It is the one that is the most adaptable to change.

~ Charles Darwin
Evillive2

C++ is a complex language that not only makes it easy to shoot yourself in the foot, but it ensures that you'll blow off your whole leg when you do so.

If you want to learn C++, it will be much easier to do so after you've mastered a similar language, so that you can just focus on it's quirks/pitfalls, rather than all the basics as well!

Yes C++ is a complex language, but there is no requirement to use it all. In fact there are many people that argue against using many of the features (multiple inheritance, etc).

But, you can effectively start out with C, with more flexible variable creation and better comments. Also, find a toolkit (SDL, SFML, ClanLib, etc.) because loading bitmaps and sounds, handling a GUI interface, and setting video modes are challenging.

Start your program with everything you need to get a simple concept working in main and eventually start pulling pieces out into classes. I still do this when I'm starting a new program.

Check out Super Play, the SNES inspired Game Engine: http://www.superplay.info

I think Javascript (yes you read it well!) is the future for game programming since web browsers are becoming the new OS.

So, nowadays, I would not recommend starting with C++ to a young guy wanting to become a game developper.

I'd recommend against learning a high level garbage collected* language first. Bad habits die hard. Certainly no console game dev would want to hire someone with a complete ignorance of memory management. At a certain PS3 dev I worked at a few years ago, I remember the programming test was something like implementing a queue. It was a gameplay programming position, so at the time I thought it was odd. However, having worked in the industry for around a decade now, I understand their reasoning. There are a lot of programmers coming out of a CS degree having learned something like Java, and having picked up some really bad habits.

The C++ "blowing your leg off" references are funny, but I always think it's silly when people give examples like "what does this mean? (*(&((**(&x)(++a)))))". Of course you're going to blow off your leg if you go around spraying an uzi in every direction like a complete spaz.

The OP is interested in companies that indeed use C++, so whether you can blow your leg off with it is kind of irrelevant. Eventually it has to be learned. Just because you can do really hairy things in it doesn't mean that you can't learn in such a way that you start with the gentle concepts.

I think part of the reason people stumble when first learning C++ is that there are REALLY BAD resources for C++ in the internet, and also some really bad books out there. As an example, this is an article I wrote (13 years ago according to the time stamp) right here on gamedev - http://www.gamedev.net/page/share.php/_/technical/general-programming/modular-programming-a-classless-approach-part-i-r1066

It makes me cringe reading it. I had NO IDEA what I was talking about. The internet is flooded with bad C++ resources like this, particularly if you hang around game dev sites.

Since someone just made the extreme suggestion of Javascript, I'll go the other direction and suggest picking up this book -

http://www.amazon.com/Assembly-Language-Step-Step-Programming/dp/0470497025

The first version was one of the first programming books I ever read, and it completely took the fear of low-level away.

* speaking of garbage collection, a PS3 game I worked on nearly shipped with a periodic frame dip. Turned out it was Lua's garbage collector. Took a guy a bit smarter than me to get it to play nice.

"Why is there so much legacy code for C(98) and C++(pre tr1)? Why not VB6, Java 1.2, .NET 1.1 or other popular languages or platforms of past years?"

There IS a lot of legacy code in things like VB. There's plenty of work to be had if you know VB6 and are willing to re-write junky buggy corp apps into newer languages.

There IS a lot of legacy code in things like VB. There's plenty of work to be had if you know VB6 and are willing to re-write junky buggy corp apps into newer languages.

Yes you are exactly right but unfortunately VB6 code is not in a "form" where it can be used directly. if only they wrote it in C or C++ originally...

I predict in the next 20 years we are going to have loads of legacy .NET code that will need to be rewritten to either the latest trendy language or to C / C++ and be done with it ;)

I think Javascript (yes you read it well!) is the future for game programming since web browsers are becoming the new OS.


And as with OSes, you need systems languages which is why tools like Emscripten (C++) and to a certain extent Microsoft's TypeScript have been created to work on large scale client-side web applications which becomes very tricky with something like Javascript.
I also find Javascript is far harder than C++ when working in large teams so I am very grateful for Emscripten ;)

http://tinyurl.com/shewonyay - Thanks so much for those who voted on my GF's Competition Cosplay Entry for Cosplayzine. She won! I owe you all beers :)

Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.

This topic is closed to new replies.

Advertisement