Advertisement

How much life is left in C++ ?

Started by June 01, 2010 07:47 AM
72 comments, last by SiCrane 14 years, 5 months ago
I'm noticing that, on this site in particular people are being advised to learn C# before C++. We all know the differences between the two but if new people keep picking up C# then isn't there going to be a time when C# surpasses C++? My thinking is that if things carry on this way there will be a repeat of the assembly programmers scenario - very few of them still exist. We all know the performance benefits of assembly but we still use C++ - could this happen with C# and C++?

Just a curiosity of mine - im interested to hear what other peoples views are on this.

Plenty.

It ain't going to be going anywhere for many many years. The jump in usability between ASM and something like C++ is a lot greater than that between C++ and a .NET language (if any jump at all!). Not to mention there's a vast amount of code in C++ which to convert to .NET would be a mammoth task. When somebody like MS chooses to write the Windows OS with the .NET framework, then the question becomes a little more valid.
Advertisement
Some very valid points there - I'm noticing Java really taking a stand with software projects outside of gaming.
Quote: We all know the performance benefits of assembly but we still use C++
No, this isn't true any more. Maybe on a Wii, or a SPU, but not in general.
When there's 50 stages in the CPUs pipeline it's actually pretty damn hard to write optimal assembly -- your C++ compiler can probably do a better job in the general case. In the times when it can't, you can usually use intrinsic functions (i.e. assembly instructions that look like C functions) from C++ to bridge the gap.

Badly written C++ is worse than assembly, yes, but the opposite is also true. There's nothing stopping you from writing C++ that performs as good or better than hand-written assembly, except bad compilers (I'm looking at you, Wii...)

Also, if fetching a cache line takes as long as 800 arithmetic operations (that's a real example), then it doesn't matter how amazingly optimised your code is if your data hasn't been designed properly -- something I would argue is easier to do from C/C++ than from assembly (C++ also gives you lots of tools to completely screw this up, as mentioned below).
Quote: if new people keep picking up C# then isn't there going to be a time when C# surpasses C++
In console games, we don't use C++ because it's popular with the staff. We use it because it gives you enough low-level control over the hardware while still being somewhat productive.

It's also designed around the notion that you "only pay for what you use" -- so yeah you can go putting 3 vtables into your classes and iterating a linked list while using double dispatch and string-based RTTI... but you aren't forced to.

A good reason for beginners to use C# is that they'll use this "low-level control" to write extremely buggy code with really bad performance. C++ simply isn't a good learning ground for people new to programing.

[Edited by - Hodgman on June 1, 2010 8:31:59 AM]
I didn't think about modern day processors but you're right.

Are there fears that maybe the skillset will shift? I mean more people learning C# means less people learning C++. What happens if C++ programmers become so rare it forces studios to move to C# (or other languages) because only the elite studios can afford to pay the rates for rare C++ programmers.

Sorry, I know there's a lot of "what if's" - im just curious
Then the market will have to adapt.

But learning C# isn't an 'all or nothing' position; in fact if you are claiming to be a programmer and only know one language then I'd consider you a pretty poor programmer by all accounts.

Starting with C# does no stop you from learning C++, or any other language, later. What it might do is breed some better programmers as they will be focused on learning to code and problem solve rather than worrying about the fiddly aspects of the language.

It might also cut down the number of C++ programmers but I consider this a good thing as it means those of us who remain might well get paid closer to what we are worth and it'll mean less people out there spitting out rubbish C++ code in the first place.

Frankly the biggest problem has already happened; the OO-ification of programmers. People coming out of university who view the world only in objects. Don't get me wrong, objects are fine and I've nothing against OO but its not a tool to fix every problem and can lead to substandard solutions.

Unfortunately this seems to be something only experiance and/or personal intrest can fix.

edit: That said, I'd rather have the drooling masses writing decent OO code rather than trying to write high performance code and stuffing that up even harder because they don't understand what they are doing at that level.
Advertisement
Quote: Original post by LionMX
I'm noticing that, on this site in particular people are being advised to learn C# before C++. We all know the differences between the two but if new people keep picking up C# then isn't there going to be a time when C# surpasses C++? My thinking is that if things carry on this way there will be a repeat of the assembly programmers scenario - very few of them still exist. We all know the performance benefits of assembly but we still use C++ - could this happen with C# and C++?

Just a curiosity of mine - im interested to hear what other peoples views are on this.


C# and JAVA requires a virtual machine to be installed on the end user's computer, some people don't like this especially when selling software. With the large amount of rather good frameworks in C++ it is easy to make up for throwing out a higher level language. Not to mention it is also quite possible to embed a higher level language into your project.

I think the main difference between Assembly and C++ is that C++ can and will evolve as time goes on.

Lastly, every time I switch from programming in C# or Actionscript 3.0 to C++ I gain a lot of knowledge about software design. I had to learn design patterns when I started out in C++ because it wasn't doing everything that the higher level languages did for me. This had also allowed me a lot of freedom in my code and it forced me to care more about its overall design.

My advice would be to switch to C++ when you want to be a better programmer.
Quote: C# and JAVA requires a virtual machine to be installed on the end user's computer, some people don't like this especially when selling software.

Most people who use this as an argument don't know much about the practical realities of C++ deployment either (it also requires a runtime library to be deployed on the host machines). There are valid arguments here with respective to runtime size for some applications, and proliferation (owing almost exclusively to C++'s age), but that's about it.

Quote:
I think the main difference between Assembly and C++ is that C++ can and will evolve as time goes on.

Assembly is just mnemonics for the instruction set of the chip, so assembly evolves just as much as C++ -- arguably, in fact, faster, since there have been far more new chips developed in the years since C++98 was ratified than there have been revisions to the C++ language. Granted most such chips use very similar instruction sets, but not all of them.
Quote: Original post by phantom
Then the market will have to adapt.

But learning C# isn't an 'all or nothing' position; in fact if you are claiming to be a programmer and only know one language then I'd consider you a pretty poor programmer by all accounts.


I agree, my first language was C then I learnt C++ during university and now I use Java in my job. Unfortunately I dont work in the games industry so maybe the way people think is different but I found the transition from C -> C++ -> Java rather painless. I just wonder how "newbies" will respond to learning the other way - I bet the percentage for people who give up because it's difficult is high. I know it makes me a bad person but I found going from c to assembly difficult so I often did as little as possible.
I wouldn't give up on the venerable old dog just yet. C++ is still very widely used, particularly in game development and operating systems/low level stuff.

Quote:
C# and JAVA requires a virtual machine to be installed on the end user's computer, some people don't like this especially when selling software.


I disagree. Everybody and their dog has the .Net framework and the Java runtimes installed these days. Sometimes it is installed automatically, sometimes the install won't budge unless you have it. It's far from being avoided, that's what I'll say.

Quote:
Lastly, every time I switch from programming in C# or Actionscript 3.0 to C++ I gain a lot of knowledge about software design. I had to learn design patterns when I started out in C++ because it wasn't doing everything that the higher level languages did for me. This had also allowed me a lot of freedom in my code and it forced me to care more about its overall design.


Thing is, you would generally use design patterns in higher level languages too. I think what you're getting at, here, is that C++ isn't intrinsically object oriented by default and is mostly procedural, and I would agree that it grants you a certain level of freedom by not tying you to the OO paradigm ergo one doesn't have to use objects if one doesn't want to.

However, this freedom isn't necessarily a good thing. What exactly do you mean by "... the higher languages did for me ..."? I personally don't think there's anything about overall design that you can learn from one language to another; the core principles are language agnostic and can be applied across the board.

Quote: My advice would be to switch to C++ when you want to be a better programmer.


I would respectfully disagree. Using one language over another does not, by default or inference, make you a "better" or "worse" programmer. I've seen some beautiful Java and some absolutely abominable C++, was the C++ programmer a better one simply because he was using a language that was closer to the metal? I've also seen some excellent (although difficult to achieve) C++ and some C# that made me want to hurl.

C++ lends itself to all manner of hideous abuses and misuses, and features a lot of dirty concepts which can really ruin your day. Because of this, a lot of the language is misused or misunderstood by all but the absolute cream of programmers and those are very, very few in the grand scheme of things.

This topic is closed to new replies.

Advertisement