back to article What's all the C Plus Fuss? Bjarne Stroustrup warns of dangerous future plans for his C++

Earlier this year, Bjarne Stroustrup, creator of C++, managing director in the technology division of Morgan Stanley, and a visiting professor of computer science at Columbia University in the US, wrote a letter inviting those overseeing the evolution of the programming language to “Remember the Vasa!” Easy for a Dane to …

Page:

        1. Tom 7 Silver badge

          Re: There are several C++ map-reduce libraries

          I do like them myself.

          I do not like the fact Qt seems to take up several gig and when I have to upgrade so I can compile a 500 line graphics app I seem to have to download all possible libraries. I'm sure I've see a QT library for the Manchester Baby in there!

  1. CommanderGalaxian
    Unhappy

    Heaven help the newbies.

    From about 1989 through the 2004 - I spent most of my time programming in either C or C++ and loving them both. Then for the last decade and a bit I've been programming SCADA sytems (which tend to have their own Pascal or C like languages).

    On coming back to C++ in 2018 - all I can say is: WTF happened!?

    1. Fibbles

      Re: Heaven help the newbies.

      It got better?

      You don't have to use every new feature of the language and I can't think of any that actively make it worse.

  2. Anonymous Coward
    Anonymous Coward

    Code style

    For goodness sake!

    for (int i=0; i<MAX; i++) ++v[i]; // increment each element of the array v

    Should be:

    for (int i = 0; i < MAX; i++) ++v[i]; // increment each element of the array v

    People who don't use white space properly should be taken behind the bike sheds and shot!

    1. CommanderGalaxian

      Re: Code style

      Either style is equally legible. The problems come when people start mixing styles (usually because some arsehole thinks their style is better than everybody else's) - that's what gives the readability headaches.

      1. GrumpenKraut
        Trollface

        Re: Code style

        The real nasty here is using the postfix-form of the increment operator.

        Only half trolling --->

      2. JohnFen

        Re: Code style

        This. It doesn't matter what a company's (or individual's) official code style is, it's only important that they have one and that it is used consistently. This is true for all languages.

        1. Anonymous Coward
          Anonymous Coward

          Re: Code style

          Concur. That's part of the future support capability in whatever I do. It's highly likely, for one reason or another, some one else is going to try something with what I've crafted. Why should I make their life Hell? I also keep the complexity level low, not stupid but useful. APL (J now) is a favorite of mine but I'm used to using maths most everyone else doesn't know exists.

    2. Tom 7 Silver badge

      Re: Code style

      You dont understand, The purpose of Code Style is so that no-one can ever learn the full set of quirks in your company so you will always make a mistake here or there and then the really shit managers can go off on one for several weeks explaining to everyone in the department how its your fault you couldn't solve Fermat's last theorem in 20 lines of python as he'd demanded in the project plan.

  3. Hans 1
    Happy

    there is hardly any feature I wouldn’t do somewhat differently if I had to do it again.

    Anybody who has ever written code would say this, too!

  4. karlkarl Silver badge

    I was on the C++ spec discussion group the other day asking why std::shared_ptr<T> or std::vector<T>::iterator did not provide some additional checking whether memory gets destroyed whilst within the member function itself (i.e 'this' gets destroyed, via a smart pointer resetting or a vector clearing).

    Whilst I certainly I agreed that these features will add some overhead and should not be part of the spec, I would really like to see it enabled in some sort of debug mode rather than leave that task to compiler specific vendors (to mess up).

    Basically I fear that C++ is evolving the wrong way. It is becoming full of really cool advanced and fast features that I will likely never use, whereas it is still just as unsafe as it was since the invention of smart pointers in TR1 / C++0x.

    I think the problem is that these guys are so smart that they don't need this additional error checking. Unfortunately the rest of us really need them (as evidence with a lot of security related bugs that keep cropping up).

    1. Bronek Kozicki

      why std::shared_ptr<T> or std::vector<T>::iterator did not provide some additional checking whether memory gets destroyed whilst within the member function itself

      My response to this category of problems is: fix your design.

      1. Tom 7 Silver badge

        RE: why std::shared_ptr<T> or std::vector<T>::ite....

        So you've identified somewhere in the language where there could be a problem if you dont write your code properly and rather than adding some check in your coding procedure you are going to wait until someone updates the language?

  5. Missing Semicolon Silver badge

    C++ has been squeezed out

    If you want stuff to run quickly, or with few resources in a tiny micro, there's C.

    If you have a bigger box, heap, scheduling, whatnot, you use a proper manage language like Java/Rust/Scala.

    For code where the expression on a complex algorithm is the main problem, not the cyle-level efficiency, you go higher level Python/R/Go

    C++ can't really be used unless you have a heap. If you do have a heap, with plenty of free space, yoiu need memory management, ruling C++ out.

    1. karlkarl Silver badge

      Re: C++ has been squeezed out

      C++ uses the same memory management system as Rust. RAII.

      In many cases, big heavy things like Java and .NET are simply not a solution to C++ and aren't they all written in C++ anyway? ;). I don't think C++ will ever be squeezed out and I predict its lifespan will actually extend well beyond most of those mentioned languages.

      Ultimately, C is king and in theory the only language we really need (it attaches our logic to the machinery) and C++ is meant to be C with additional safety and facilities. I have tried to create a safe ANSI C library (https://github.com/osen/plank) largely using MACROs. It still isn't quite up to the safety of C++.

  6. Anonymous Coward
    Coffee/keyboard

    I've alwats been concerned that C++ just isn't complicated enough...

    ...so I'm glad to see this fundamental flaw is being properly addressed.

  7. Lee D Silver badge

    I have to say, just that simple for-loop is a prime example of why I don't like C++.

    I can memorise the entire standard library of C, and every command in it, and every operator, and every syntax. Nobody can then run up a piece of code which can't be deciphered (sure, I may have to play pre-processor games, but everything will come down to obvious code).

    When there are a dozen ways to iterate over a simple group of objects, and half-a-dozen different groups of objects, and obscure syntactic sugar the people use because it saves them a fraction of a second, it quickly becomes a pain to understand. Which means it's a pain to verify. Which means it's a pain to secure. Which is not what you want in something like C/C++.

    The "hidden effects" of such code, where things are iterated upon, objects are instantiated, etc. behind your back is a real pain to me. It's like every simple line becoming a dozen "subroutines", overrode and silently inserted, and no obvious way to tell that's what's happening from a quick glance.

    I'm sure with a good IDE, these things become mere colourations, and you can expand object creation etc. but it means too much is going on under the hood without my say-so.

    That's the problem I have with C++... someone can give you the worst spaghetti code and it could easily be malicious, obtuse, or just terrible. With C, you have a chance to spot it, you can pre-process and then see each step, and you have the entire library in your head. If you want to use fancy objects, you have well-defined headers and you can easily isolate the problem.

    When I read my first book on C++, I was so excited to try using it. We all know that "reading about it" and "doing it" are two very different things, but I'd never seen such a gap when learning a programming language. Everything about C++ suggests it should be wonderful, but the pitfalls and readability plummet the second you try to use it, and the other code you inherit is usually nothing more than show-off gibberish trying to use every template, library function and short-cut syntax possible.

    I dearly want C-with-objects back again. C++ never was that, despite claiming so at one point.

    1. GrumpenKraut
      Angel

      > I have to say, just that simple for-loop is a prime example of why I don't like C++.

      Funny, I really like that idiom.

      But let me offer you some help with hating C++: Let A be a std:valarray (of, say, type int). Then you can replace all elements strictly greater than 5 by 77 as follows:

      A[ A > 5 ] = 77;

      No, I am not kidding.

    2. Fibbles

      "Language I know is easier to understand than language I do not know."

      The range based for loop is far from opaque to anybody who actually knows the language. It simply iterates the each element 'foo' in container 'bar'. It does it by using a feature of the language that has been in the standard for 20 years, namely 'iterators'. Every algorithm in the Standard Library uses iterators, they're not a difficult concept and are fundamental to understanding the Standard Library.

      Your complaint seems to be that you don't understand the inner workings of the Standard Library and therefore can't 'secure' your code which is ridiculous because you shouldn't care about the implementation any more than you should care about the implementation of your compiler. At a certain point you have to trust that something does what it says on the tin.

    3. karlkarl Silver badge

      I agree that C has some advantage over C++ in that it is simpler. This is quite evident by the K&R book being about 1/4 the size of Stroustrup's C++ Language book ;)

      However the complexity in some cases is worth it. For example with "safe" iterators it can be set up so that if the data you are iterating through changes (i.e some berk has cleared the container hidden down the call stack), you can know about it (with an assertion).

      That said. Some developers I feel over-consume C++ features (especially templates). For example, I present to everyone the GLM challenge. Who can find where the glm::mat4 glm::rotate() function is actually implemented in 1 minute?:

      https://github.com/g-truc/glm/tree/master/glm

      I'll give you a clue... If you are using an IDE with intellisense. Turn it off. It will probably crash ;)

      Contrast this with linmath (ANSI C): https://github.com/datenwolf/linmath.h

      GLM is safer but gosh is it more complex. I would hate to extend that thing.

      1. Fibbles

        /glm/gtc/matrix_transform.inl

        glm - because it's in the OpenGL Math Library

        gtc - because it's Template Core rather than Template eXperimental (gtx)

        matrix_transform - because it's a free function for transforming a matrix object

        .inl - design choice of the library, could just as easily go in the hpp file

        This seems more a criticism of the GLM library and their header layouts rather than a valid criticism of templates. It's also unfair comparing its size to linmath since GLM is specifically designed to inter-operate with OpenGL and mimics GLSL as closely as possible within the limits of the language.

      2. Anonymous Coward
        Facepalm

        Who can find the glm::rotate() function?

        > For example, I present to everyone the GLM challenge. Who can find where the glm::mat4 glm::rotate() function is actually implemented in 1 minute?:

        Interesting .. I've also wondered why, for such a high level language, you need to help C++ keep track of its variables using the Namespace feature. For another example, it's perfectly obvious that :: is the scope resolution operator and does different things depending on the context. It would be like creating a human language that the key words could be overloaded with ever changing meaning <sarcasm>

        Human brains don't work like this, C++ a high level computer language written for computers :]

        1. Richard 12 Silver badge

          Re: Who can find the glm::rotate() function?

          Namespaces are because it's not possible to give every class, function and constant a unique, memorable name.

          It is common - nay certain - that a mid to large sized project will have multiple things that with the same name.

          But if you have Eigen::matrix4x4 and GLM::matrix4x4, you can actually say which one you mean.

          Nothing more.

          And of course, you can just tell the compiler "in this source file I use GLM", to avoid typing the letters.

  8. tony2heads

    closer to the Mary Rose

    The Tudor warship performed well for decade until the upgrade.

  9. regreader2011

    I guess we now live in an age where computer languages are treated akin to consumer electronics items -- one must ship a new version every couple of years, else people switch to a different brand? Or is it just a self-serving effort to keep the C++ education business humming?

    1. ThomH

      I think it's more like the explosion in new languages, resulting from the post-internet easier grouping of interested people, has led to a much faster turnover in new ideas and the established languages like to crib what they can.

  10. HmmmYes

    Problem is, each language version really should be considered a different lanaguage.

    Maintaining any long (>10 year) lifed C++ is a massive PITA.

    Ibe seen programmers start off MFC C++ style - C++90 + the stupid MS addons.

    Then some has read the Design Pattern book, so you get 'patterns' in the code base from 95is-00ish.

    Then they discover the STD. All the new stuff then becomes templated.

    All a massive fuckup.

    You need to have strongly applied coding rules, not just syntax but on the language and libraries used.

    The module needs needs to be frozen to that C++ version.

    End of the day, I spend more time testing.checking stuff than I do writing new stuff. Any language that makes testing easier gets my vote.

  11. arctic_haze

    What's wrong with good old ANSI C?

    ANSI C is good enough for the scale of project I do. If I really needed to start a big multithreaded project I would think of something created for that purpose, but most probably that would not be C++.

  12. vincent himpe

    why not simply have a 'foreach' ?

    foreach (x in v) x++;

    why all those cryptic modifiers ? language syntax should be easy to read. Not look something written by a drunk hamfisted keyboard pounder typing expletives in symbolic form... $#@&%^!!!

    1. Fibbles

      It's not far off that really. C++ is a statically typed language so you need to provide a type in your code or explicitly tell the compiler to deduce it from the value passed.

      for ( auto& x : v )

      If you look at the above range based for you can see that the colon is equivalent to 'in'. The only non obvious bit to somebody who uses another language is the 'auto&'. The 'auto' just tells the compiler to deduce the type since it knows what 'v' contains and therefore knows the type of 'x'. The '&' tells the compiler that it should not make a copy of the element from the container but just use a reference back to the original object.

      1. Lee D Silver badge

        I'm with the foreach guy.

        The second you start using a different syntax for the same command (for), and distinguish using obscure symbols, and even HAVE things like "auto" type modifiers (which just makes me think of VB "Variants"... shudder...), then you've strayed far enough from the original command to warrant a new keyword.

        That line is impenetrable to my programming mind. Can you honestly imagine seeing something like that inside, say, the Linux kernel? Or the LibreSSL library?

        C++ just wants to overload absolutely everything, including its own commands, and that quickly turns into a royal mess.

        And I can't imagine that the generated code is any better than just using the "obvious" foreach and a type/object that allows iteration, and an obvious array/collection of objects.

        For instance, if that loop modifies x, and it's just a reference back to the object inside the collection, that could quickly turn into disaster and it might well be hard to spot.

        Honestly, a programming language is like a joke, if you have to explain it, it's not working. Sure, C is hardly as readable as BASIC, but C++ is an order of magnitude more obscure than either, especially when people play with these pretty "tricks".

        1. Fibbles

          The second you start using a different syntax for the same command (for), and distinguish using obscure symbols, and even HAVE things like "auto" type modifiers (which just makes me think of VB "Variants"... shudder...), then you've strayed far enough from the original command to warrant a new keyword.

          That line is impenetrable to my programming mind.

          What makes it impenetrable? I really can't see how 'foreach x in y' is significantly more readable than 'for x in y'.

          The auto keyword is not specific to for loops, you can use it pretty much anywhere you'd like the type deduced. It's useful because you shouldn't be redeclaring the same information over and over. If I change variable foo from int to unsigned int I don't want to have to then go through each line of code to change the type there as well.

          Can you honestly imagine seeing something like that inside, say, the Linux kernel? Or the LibreSSL library?

          No because they're both written in C, not C++.

          For instance, if that loop modifies x, and it's just a reference back to the object inside the collection, that could quickly turn into disaster and it might well be hard to spot.

          References have been a core part of the language since the year dot. Do you have the same complaint about pointers? A reference serves the same purpose as a dereferenced pointer.

          Honestly, a programming language is like a joke, if you have to explain it,

          You can't honestly expect to be able to use a language without learning the syntax. Even something like Python (which is marketed as close to natural language,) requires you to learn the syntax.

          1. onefang

            "You can't honestly expect to be able to use a language without learning the syntax."

            Half the time I can.

          2. Waseem Alkurdi

            (which just makes me think of VB "Variants"... shudder...)

            Talking of the devil! For those who haven't endured the mental pain of understanding it:

            Want a data type that stores strings and integers, yet can't use string functions nor integer functions, nor can be useful for anything? Yes sir: Variant.

            Worse still is that not defining a data type for a variable "implicit declaration" gives you a fucking Variant.

      2. parperback parper

        Although you're better off avoiding the auto if you're using a non-templated function.

        That way your IDE will know what type it is, and you'll get a nice compiler error message if someone changes the type of v without telling you.

    2. Lee D Silver badge

      Expletives in symbol form are called "grawlixes".

      Just a bit of trivia for you.

    3. Anonymous Coward
      IT Angle

      why not simply have a 'foreach' ?

      > why not simply have a 'foreach' ?

      Because computer programming is an esoteric art form not to the shared with the hoi polloi :]

      1. Someone Else Silver badge

        Re: why not simply have a 'foreach' ?

        Prolly because that symbol was taken by the likes of boost and Qt and ...

    4. Anonymous Coward
      Anonymous Coward

      why not simply have a 'foreach'....

      "why not simply have a 'foreach' ?

      foreach (x in v) x++;"

      Because that would require reserving another keyword, unnecessarily breaking lots of existing code , when 'for' is already reserved and easy to understand, the only new bit of syntax is the reuse of the ':' the rest is all normal C++

      You could just as easily write

      std::vector<int> v

      for(int i : v) ....

      Backwards compatibility.... for when your language is not just a fashionable toy

  13. handleoclast
    Coat

    Bring back the good old days

    Those wonderful days when Niklaus Wirth had a strong say in the design of a new language, and of new features to an existing language.

    That way it is absolutely guaranteed to be unusable crap. So almost nobody but bondage and discipline fetishists will use it, and the rest of us can safely ignore it.

  14. Ian Joyner Bronze badge

    I Agree with Bjarne Stroustrup!!

    I remember reading something a long time ago by Bjarne on the Vasa. I really recommend a trip to see it if you are in Stockholm – quite a sight.

    I have been agreeing with Bjarne on this point for over 20 years, and C++ has been a top-heavy artefact for at least that time.

    http://ianjoyner.name/C++.html

    I'll admit to missing the most critical point (for 2018) that security is the elephant in the room for both C and C++ (and CPU/system architectures). Like most, I concentrated on correctness and verification, as well as other factors such as maintainability. Security is intricately tied to correctness, but rather than guarding a programmer against their own mistakes, it is guarding a system against the malicious intents of others. C and C++ can be too early undermined, and buffer overflows have proven to be the curse of modern computing, but blessing to the hackers.

    But security is indeed the issue that should see C and C++ relegated to the past of the wild-west days of computing.

    It is time for a rethink – or at least to learn the lessons from the past for good software development, even back to the 1960s, that C and C++ have wilfully ignored and spurned as 'restricting programmer freedom'. That attitude was naive, then stupid, now it should be criminal.

  15. Grant Fromage
    Coat

    Too many years ago from byte magazine

    The man himself " to err is human, to really fsk up you need C++"

    I have the mag somewhere 85?.

  16. Maelstorm Bronze badge

    Uhggg Another C++ standard?

    You know, we don't really need any new features to the language. In fact, there's a few features that probably should be removed. So yes, I agree with Bjarne Stroustrup. Right tool for the job really. I view C++ as the object oriented version of C, and I use C...a lot in my coding since I code close to the bare metal. C and assembler for my work.

    C: Low level system stuff such as kernels, device drivers, libraries, etc...

    C++: Higher level application stuff (especially on GUI platforms) or when using objects make sense...like the Abstract Syntax Tree that's generated from a parser and is fed into the code generator for a compiler. OOP makes sense here since the nodes are all the same, the data they contain is what differentiates what type of node it is.

    Here's a little thing that Linus said about C++. Enjoy.

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

  17. Waseem Alkurdi

    Regarding the "C Plus" in the headline

    <rant>

    It REALLY GETS ON MY TITS when engineering students at our university (who have to take C++ as mandatory) call it "C plus" as shorthand/acronym/whateverthefuck.

    REALLY ANNOYING.

    </rant>

    I do understand that this is to rhyme with "fuss", but it awakes my PTSD whenever I hear it.

  18. shaunhw

    stroustrup sounds like a C ansii string function!

    The man is right. Leave C++ alone, it doesn't need anything else adding for the sake of it.

    If they want an extended version with new features give it new name.

    1. onefang

      "If they want an extended version with new features give it new name."

      Hmm, C+=2, ++C, D (Oops, taken already), CPLusPLus (from BCPL, the grand daddy of C++), CRAP++, I could go on...

      Though given my above declaration for hating all languages beginning with P, continuing the BCPL -> B -> C tradition and calling it P will just get right up my nose.

  19. amanfromMars 1 Silver badge

    No need to reinvent the wheel ... but there are always leading improvements to be made for markets*

    There are no major decisions I regret, though there is hardly any feature I wouldn’t do somewhat differently if I had to do it again. .... Bjarne Stroustrup

    Exercise that easy option and invent a much more formidable scripting tool leading machines towards goals delivering invincibility with increased markets share of derived product.

    Anything else surely has one polishing a turd rather than displaying a diamond in the raw?

    * For example ..... Not quite reinventing the wheel, but ...

  20. Anonymous Coward
    Anonymous Coward

    B is right

    Although, one can wonder why is he late?

  21. CodeBlaster

    C++ vs C

    Coming from an assembly language background (6502 and 68000) back in the day, I decided that it was time to learn how to code in C/C++. This was back in the early 90s - I was a games programmer and the move from the Amiga to the PC meant that I had to learn how to code in this "new" high level language. Having bought a number of C++ books, it was an uphill struggle and I decided to just learn C, giving myself the option to learn C++ if I needed it in the future. I taught myself C in 2 weeks using an excellent disk/book set called "Master C". To prove to myself that I had learnt it, I wrote a crappy PC version of Galaga with assembly language for the graphics and everything else in C. No problem, it took me 3 days. I've never needed C++! I was involved in one other (PC) game back in the 90s and then got out the industry but I've written numerous complex apps in C and never felt the need for C++. In my opinion it is too much for a beginner or maybe I just wasn't intelligent enough to pick it up easily. I long for the heady days of assembly language coding - software seemed to work better back then...

    1. Missing Semicolon Silver badge
      Unhappy

      Re: C++ vs C

      There are two things wrong with C++

      1) Spooky hidden code. Due to the horrors that are overloaded operators

      c=a+b;

      Is completely incomprehensible. If a and b are instances, the actual code is presumably in the overloaded operator+ for the class of a. Then, it must create a temporary a on the stack, before using the copy constructor to make c. So, if there are side effects in the constructors, all sorts of shizzle goes on. Plus it can eat up loads of stack.

      And, the whole mess was just to make sure that strings are not special objects, but you can still write

      foo=bar+"more";

      The world already has Perl as a write-only language. It doesn't need another one.

      2) The utterly crap reference book. Everyone worships Stroustrup, but the book is utterly useless for learning to write real-life code. It always shows stuff as definitions, ans rarely describes how to separate declaration and definition - the way you always work. The descriptions of the various features are a hymn to how clever they are, not a careful description of the use, abuse, and side effects.

Page:

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Other stories you might like