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

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

I personally had jumped into C++, head on. And boy oh boy did I find those sharp edges. It's partially the reason why I took so long to learn programming even the simple things. Since it discouraged me so often, from me getting lost and also blowing off my own leg. Then I took a Java class and along with some of the basics I learned through that long time of C++, Java was a BREEZE. Then after that C# was also simple. Just syntax changes.

Though, in retrospect, for me at least, it would've been better for me to start off with Python, Java, or even C#.

Above all noted why/when C++ is used in the real world.

Advertisement

But I've looked for topics where members ask what to study first and you usually let is start with C#.

I'd say Python comes up even more often than C#, and for good reason.

Anyway, the consensus from academic circles (read: people who are tasked with teaching hundreds of students to program, year after year) is veering towards this: starting with a language that is overly complex, incoherent, low on expressive power or otherwise user-hostile means you are wasting your time. My gut feeling is that it's even more true if you are trying to learn on your own. Everywhere people are opting for Python, Scala, etc. when choosing languages for introductory programming courses.

I recall one particular experiment where a school carried out their two initial programming courses in two groups. The first group used Scheme for the first course. It is an excellent learning language that looks nothing like languages common in production use. The second group used Java. Both groups took the second course, whose subject was object-oriented programming, in Java. Even on such a limited timescale, the end result was that the students of the first group were better at programming in Java at the end of the second course. One can only imagine how much better they grasped programming in general. Also note that Java, while clunky and lacking expressivity, is much more forgiving than C++ is.

If you wish to learn C++ in the end stay away from Python...

The fact that python is fairly different from C++ is actually a very good reason to learn it, especially if you primarily intend to work with C family languages.

[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!

For your very first language... go with a non-compiled language. When you are learning programming basics, taking out the edit-compile-link-run cycle from the occassion is a huge benefit. It lets you focus on learning coding, as opposed to so many other things.

You can spend a few weeks in such a language, then learn just about any other language at a substantially increased pace.

I think choosing with what language you should start depends a lot on how you think. I for example always like to take things apart and study every little detail of it because i want to know how things REALLY work. That's the reason i started learning c++ very early (just after a bit of PHP which didn't help me a lot with c++). If i had gone even lower (assembler) that would've been too much. If you really wan't to learn something then mostly you can pull it off, even if it's frustrating at some points (which it definitely was, lol) but when you finally understand everything it's very satisfying. Another advantage is that if you understand c++ and the concepts of programming that come with it it's really easy to learn new languages, especially higher level languages. It might be hard in the beginning but later you can understand new things a lot easier.

If you don't really have the urge to know what's going on in a computer and just want to program i think it would be better to start with something high level so you can get right to the point and program something without having to worry about little details like memory management and stuff.

For your very first language... go with a non-compiled language. When you are learning programming basics, taking out the edit-compile-link-run cycle from the occassion is a huge benefit. It lets you focus on learning coding, as opposed to so many other things.

I don't really see where the problem is. Any modern compiler with a decent pc will compile a rather long program in a matter of 1-10 seconds and it's up and running. Of course if you have to configure the compiler and such it would be .. lets say a bit distracting but in a great number of compilers that i have used you just press f5 or click run and it does all the stuff for you and you just wait a few seconds.

"Errare humanum est, sed in errare perseverare diabolicum."

One of the main reasons why many companies use C++ is because when the language was in early publication versions it was actually quite useful and gained a lot of attention. Those massive numbers of students eventually got deep into the industry, so we are seeing the maturing of that C++ subculture. That same maturing of both the language and the students into careers happened to Java and is going to happen to C# (already is to a large extent).

The C++ and supporting libraries, like several major languages, are very powerful and will be used for years to come.

Keep in mind that every language has strong points and other weaker aspects which may be better satisfied in another language, which is why we actually see several other languages commonly used alongside C++ in the game development industry. For example, C++ is very favored for multi-threading and managed memory coding of areas of the game which are fairly constant, such as handling object loading, terrain issues like cloud to mountain clip hint to be more specific. In areas of the game which stop and start as the player makes decisions ingame, then an auto-memory management language implementation is often best, such as using Lua for scripting events by "triggers" as the main character does the role play thru the game scene. Another way of looking at it is when smooth implementation and render to screen is critical, then C++ shines bright with things like weather and terrain, but it may be much faster game development to use another language such as Lua, Python, Java, or C# for areas of the game where smooth rendering of the object on screen or other gameplay feature can afford to have a slight delay, such as a group of zombies suddenly rounding the corners of buildings when the character reaches a certain location. (Don't misunderstand, because all of these languages may be coded for very fast performance, but many people find Lua, Python, Java, or C# much faster to develop when used for not-performance-critical areas where these languages are typically quicker in development from start to beta.)

Clinton

Personal life and your private thoughts always effect your career. Research is the intellectual backbone of game development and the first order. Version Control is crucial for full management of applications and software. The better the workflow pipeline, then the greater the potential output for a quality game. Completing projects is the last but finest order.

by Clinton, 3Ddreamer

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)

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

I don't really see where the problem is. Any modern compiler with a decent pc will compile a rather long program in a matter of 1-10 seconds and it's up and running. Of course if you have to configure the compiler and such it would be .. lets say a bit distracting but in a great number of compilers that i have used you just press f5 or click run and it does all the stuff for you and you just wait a few seconds.


Compile time is not really the issue. Removing a layer of complexity is. If the person is learning in a REPL environment, changes just happen, there is no running of code. Variables are persisted until the environment is closed, code execution is always at the current point, etc. this is a great way to introduce a person to programming and has unintended benefits, like making debugging intuitive later on.
Legacy code, and lots of it.

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?

In ~20 years, sure we will probably call things like SDL legacy and sure people will still be slating C++ against their new language of choice and yet C++ will still be going strong, SDL will still work and everyone would have long forgotten .NET, C# and XNA.

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.

Legacy code, and lots of it.

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?

In ~20 years, sure we will probably call things like SDL legacy and sure people will still be slating C++ against their new language of choice and yet C++ will still be going strong, SDL will still work and everyone would have long forgotten .NET, C# and XNA.

Washu was talking about the game development industry, predominantly the professional portion of it. There is almost no "legacy code" for VB6, Java, or .NET because it is almost never used for shipping professional games. Additionally, C++ is much older than any of those technologies.

You have a highly amusing view of the future.

Legacy code, and lots of it.

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?

In ~20 years, sure we will probably call things like SDL legacy and sure people will still be slating C++ against their new language of choice and yet C++ will still be going strong, SDL will still work and everyone would have long forgotten .NET, C# and XNA.

Washu was talking about the game development industry, predominantly the professional portion of it. There is almost no "legacy code" for VB6, Java, or .NET because it is almost never used for shipping professional games. Additionally, C++ is much older than any of those technologies.

You have a highly amusing view of the future.

As someone who was doing this 20 years ago, I have a pretty good guess what another 20 years will do. I agree fully with your last comment.

Otherwise I would still be using the Fastgraf library, using the Glide API and talking about how C++ is too slow for real game programmers.

Legacy code is not linked to the language it was created from, but instead to the problem domain it was intended to solve. Once a problem is solved ( ie, OpenGL/DX replacing Glide ) or goes away ( ie. moving from direct memory access to virtualized environments ), the code written to work in those problem domains becomes legacy. Or of course, code can become legacy because it was replaced with a superior version.

This topic is closed to new replies.

Advertisement