topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 1:44 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Why C++ Is Not “Back”  (Read 7433 times)

Jibz

  • Developer
  • Joined in 2005
  • ***
  • Posts: 1,187
    • View Profile
    • Donate to Member
Why C++ Is Not “Back”
« on: December 02, 2012, 03:45 AM »
http://simpleprogram...1/why-c-is-not-back/

C++11 just came out recently and it seems like there is this big resurgence in interest in C++ development.

Now don’t get me wrong.  C++11 is fantastic!  I am in just about 100% agreement with all of the changes that have been made.  C++ has definitely become much easier to use and it has even become more powerful.

There is one thing it didn’t become though—and this is the most important—more simple.

...

My point of this post is not to bash C++ or bash people using C++ or teaching C++, but rather to blunt the message that seems to be being preached by an over eager C++ community.

Everyone is not going to become a C++ developer and they shouldn’t need to be.  While C++ may have the ability to make your program more efficient (in certain scenarios,) it is extremely unlikely to make you more efficient at creating your program (except in some extreme cases.)

So, I am glad C++ got a much needed overhaul, but I don’t think it is going to make a comeback any time soon, and that is a good thing.

I think this post has some very good points, and it reflects some of my thoughts about C++ lately. The recent changes are (largely) good, and C++ can be very elegant and terribly efficient, it is just really really hard to write good C++ code, and unless you need that extra edge on performance, there are many languages that will make your life a lot easier, especially if you are learning to program.

vlastimil

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 308
    • View Profile
    • Donate to Member
Re: Why C++ Is Not “Back”
« Reply #1 on: December 02, 2012, 04:46 AM »
Well, I may be biased, but I have a different perspective.

I think C++ is perceived as hard and C# as easy mainly because the tools and libraries used during development. C# has much much better support than plain old C++ in Visual Studio when designing user interface. Also, there is one (tens of megabytes big) core library for C#, but nothing like that for C++. Many C++ developers fear STL and even if they don't, it is only basic algorithms and you may run into binary compatibility if you use it in module interfaces. There is no "one" GUI framework (and MFC sucks).

When actually writing code, C++ does pretty well. In C++11+STL, you don't have to use new/delete at all. You get safety, efficiency and predictability (compared to garbage collection). But how much time is actually spent writing code? When working in C# on a simple tool, I would say that not much. Most of the code is generated and managed for you by the IDE and you only need to fill in a few gaps. That is something no tool currently does for C++ and that is why is it perceived as difficult. If you had to type everything the C# IDE does for you manually, the picture would be different.

Of course, it is easy in C++ to start writing bad code, but is is now also easy to write good one.

Renegade

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 13,288
  • Tell me something you don't know...
    • View Profile
    • Renegade Minds
    • Donate to Member
Re: Why C++ Is Not “Back”
« Reply #2 on: December 02, 2012, 06:03 AM »
Also biased here. ;)

I think it all really depends on what you want to do and how you want to do it. I mainly use C# because it's fast, and I'm more interested in getting something done and working than in efficiency and elegant code. I commit horrible sins. Regularly.

If you had to type everything the C# IDE does for you manually, the picture would be different.

+1

My view is that the IDE should do most of the grunt work for you, and free you up to be creative. The language and IDE shouldn't get in the way - they should help you along. This is why I refuse to code any JavaScript in anything other than Aptana -- it does the work and lets me do the creation.
Slow Down Music - Where I commit thought crimes...

Freedom is the right to be wrong, not the right to do wrong. - John Diefenbaker

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,186
    • View Profile
    • Donate to Member
Re: Why C++ Is Not “Back”
« Reply #3 on: December 02, 2012, 10:28 AM »
^ Totally agreed renegade.  And I also see as an architect very much that the newer programmers that I mentor don't *get* some stuff, because they don't know what goes on under the covers.  And so they can't make good decisions devoid of this knowledge.

We process millions of rows of data a day.  Someone slowed it down considerably, and I had to figure it out and fix it.  The culprit?  Enum.HasFlag.  MS put it there, right?  And it's a lot easier than bitwise comparisons- so the person used it.  But this put everything in and make everything easy is removing the problem solving from new engineers- making them truly into 'code monkeys'.  Yes, I know, in most situations, the difference in something like this wouldn't be noticeable.  But see that I noted that this was in a loader that loaded millions upon millions of records from financial entities daily?  The developer just coming in wouldn't even know that- and indeed this one didn't.  You have to know how something is done before you use it, so that you can make good decisions about when to use it.

Oh, and if you're interested- from my research on using that construct:

Except in the simplest of cases, the Enum.HasFlag carries a heavy performance penalty in comparison to writing out the code manually. Consider the following code:

Code: C# [Select]
  1. [Flags]
  2. public enum TestFlags
  3. {
  4.     One = 1,
  5.     Two = 2,
  6.     Three = 4,
  7.     Four = 8,
  8.     Five = 16,
  9.     Six = 32,
  10.     Seven = 64,
  11.     Eight = 128,
  12.     Nine = 256,
  13.     Ten = 512
  14. }
  15.  
  16.  
  17. class Program
  18. {
  19.     static void Main(string[] args)
  20.     {
  21.         TestFlags f = TestFlags.Five; /* or any other enum */
  22.         bool result = false;
  23.  
  24.         Stopwatch s = Stopwatch.StartNew();
  25.         for (int i = 0; i < 10000000; i++)
  26.         {
  27.             result |= f.HasFlag(TestFlags.Three);
  28.         }
  29.         s.Stop();
  30.         Console.WriteLine(s.ElapsedMilliseconds); // *4793 ms*
  31.  
  32.         s.Restart();
  33.         for (int i = 0; i < 10000000; i++)
  34.         {
  35.             result |= (f & TestFlags.Three) != 0;
  36.         }
  37.         s.Stop();
  38.         Console.WriteLine(s.ElapsedMilliseconds); // *27 ms*        
  39.  
  40.         Console.ReadLine();
  41.     }
  42. }

Over 10 million iterations, the HasFlags extension method takes a whopping 4793 ms, compared to the 27 ms for the standard bitwise implementation.

My view is that the IDE should do most of the grunt work for you, and free you up to be creative. The language and IDE shouldn't get in the way - they should help you along. This is why I refuse to code any JavaScript in anything other than Aptana -- it does the work and lets me do the creation.

Try Jetbrains Webstorm (or phpstorm).  I have, and haven't gone back.  A lot lighter that Aptana, and just as good.

Jibz

  • Developer
  • Joined in 2005
  • ***
  • Posts: 1,187
    • View Profile
    • Donate to Member
Re: Why C++ Is Not “Back”
« Reply #4 on: December 02, 2012, 01:50 PM »
I totally agree with the idea that knowing what happens behind the scenes gives you far more potential for writing good code -- though sometimes it can get in the way of quickly writing code that is good enough :-[. I think perhaps C is a better starting point for getting this knowledge though, since it is so much smaller as a language.

I think you are perhaps falling into the trap of defending C++, when the article isn't really attacking C++ (unless you view is that C++ should be used by everybody for everything). The author even repeatedly says he likes C++, and is just trying to point out that the recent interest does not mean that everybody should start using C++.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Why C++ Is Not “Back”
« Reply #5 on: December 02, 2012, 02:05 PM »
For me, the major problem with the new C++0x is that it's hard for me to see the audience for it.  It seems to me to be almost a last gasp that is going to turn into more of a poison pill..

C++ is my native language -- i've been coding in c++ for 25+ years, and I still love it.

But I just don't see the new stuff being added as satisfying anyone.

If you really want to dig into the more modern programming language ideas.. you are not going to want all of the legacy backward-compatibility messiness that C++ is committed to supporting.  The backward compatibility is one of the real strengths of C++ but it makes the language much less clean.

And on the other side of the coin, if you are coding in C++ because of the backward compatibility stability and large code bases, and are attracted to the lean and mean C++ principles, then all of these new features in C++0x are probably not only things you weren't wanting, but may cause you some concern that you're now going to have more incompatibility issues with old compilers, etc.

It seems to me that the new C++0x may really just hasten the extinction of C++.  I'm just hopefull it will help inspire the next breed of programming languages.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Why C++ Is Not “Back”
« Reply #6 on: December 02, 2012, 03:29 PM »
Perhaps a better way to say what i was trying to say is that, C++ is now trying to do two things that are very fundamentally at odds with each other:

It is trying to continue the C++ tradition of being strictly backwards compatible, for which it pays a very heavy price in terms of simplicity and consistency, while at the same time trying to absorb the more modern advances in programming language design.

Trying to do both of these things feels to me like you are courting disaster.

And you have to ask yourself -- who is clamoring for this?  The people who want to use modern programming language features don't want to be tied to ugly backwards compatibility compromises.  And the people for whom backwards compatibility is of top importance, I can't imagine they would welcome all of these new features.

There is a big market for modern programming language design -- C++0x is never going to be at home here because of all the cruft baggage it has to carry from its past.  And there is a smaller market for legacy C/C++ code -- this market is not going to be thrilled with these new features.

I just don't see an audience for C++0x.

Now I still think there *IS* a market for a new modern programming language that embraces the control over resources and the emphasis on performance that C++ has always focused on. That's something that I've been waiting a long time for.  But it's not going to be C++0x, it's going to be a new language that doesn't have to carry the baggage of backward compatibility that C++0x is burdened with.
« Last Edit: December 02, 2012, 03:34 PM by mouser »

Jibz

  • Developer
  • Joined in 2005
  • ***
  • Posts: 1,187
    • View Profile
    • Donate to Member
Re: Why C++ Is Not “Back”
« Reply #7 on: December 02, 2012, 03:43 PM »
Languages like D, Go, and Rust are often mentioned in the context of systems programming languages.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Why C++ Is Not “Back”
« Reply #8 on: December 02, 2012, 03:51 PM »
I gave D a good long look a while back.. it's definitely got the feel of an evolved C++, but didn't quite do it for me, and I have concerns about its longevity.

Never heard of Rust, going to give it a look.

I'd love to be involved in designing a new modern language that could capture the spirit of C++..

mwb1100

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,645
    • View Profile
    • Donate to Member
Re: Why C++ Is Not “Back”
« Reply #9 on: December 02, 2012, 06:13 PM »
The biggest problem with C++ is that it lacks a large, high level standard (or standard enough) library for things like network communication, file and directory operations (beyond reading and writing files).    In C++ you have to decide if you want to roll your own or choose from one one of several competing alternatives and get it integrated into your build system.  Boost is the closest thing to this, but even Boost is far from universally used.

Then if you pull something down from the internet that looks to be useful, you have to make sure it'll work with your chosen library/libraries, decide to port it to those if necessary, or pull in yet another dependency (and hope there are no conflicts).

All of this exists for other languages to some extent, but it's far worse for C++.  Herb Sutter has indicated that a focus for the next stages of C++ standardization will be to try to extend the library to address this:

I’ve been beating the drum this year (see the last section of the talk) that the biggest problem facing C++ today is the lack of a large set of de jure and de facto standard libraries.

There's also an indication that the C++ standardization process will try to move somewhat faster than the historically glacial pace it's taken in the past:

ISO C++ standardization is accelerating. Major companies are dedicating more people and resources to C++ standardization than they have in years. Over the next 24 months, we plan to ship three Technical Specifications and a new C++ International Standard.

Both of these goals are probably more difficult with C++ than other languages because C++ standardization is pretty truly a committee driven process - there is no single stakeholder that can dictate things as there is for most other languages. But it appears that many players in the C++ standardization process are trying to move it along (http://www.isocpp.org). Unfortunately, people who work on GCC don't seem to be represented very strongly at isocpp.org. Possibly because there's a significant cost - Gold at $10,000 per year, Silver at $5,000 per year, or Bronze at $1,000 per year.