back to article The New C++: Lay down your guns, knives, and clubs

"The world is built on C++," Herb Sutter tells The Reg. Considering he's one of the language's chief stewards, we question his impartiality. But he does have a point. After more than 30 years – depending on whose numbers you swallow (these or these) – C++ remains one of computing's most popular programming languages, favored …

COMMENTS

This topic is closed for new posts.

Page:

  1. Nick Gisburne
    Facepalm

    I'd think again about that working name

    C++0x = C0x = Cocks. The future world will be built on Cocks, eh? If you include the 'P' sounds in ++ you've got some kind of stutterer's pox (cowpox or seapox). You're not even going to get away with its fully pronounced name - see plus plus 0x = see plus plus socks.

    As it's one step up from C++, I'd go for C3P, and then you might as well add the 0 on the end just for Star Wars lulz.

    1. LaeMing
      Go

      The name is ....

      "C++0x" - looks more like the output of Perl programmers playing 'golf' to me!

      1. LinkOfHyrule
        Gimp

        C++0x is illegal here!

        "C++0x" looks to me like the ASCII art representation of a depraved sex act involving barbed wire and as such is considered "extreme porn" under English law!

      2. Sureo
        Meh

        C++0x ?

        I would have thought something simpler and more obvious: C+++

        1. Ian Yates

          Surely

          ++C++

          1. annodomini2
            Coat

            Or...

            C+=2

          2. Frumious Bandersnatch

            ++C++

            This doesn't work syntactically. There aren't any rules for deciding on the relative precedence of ++C and C++. The fact that the language doesn't include such a rule is due to both (++C) and (C++) not being lvalues so they can't be pre/post-incremented and the question of relative precedence doesn't arise. The related C++++ doesn't work either, for the same reason. You could call it (C+=2,C-2) but it's hardly a very catchy name.

        2. John 62
          Trollface

          re: C+++?

          Not sure about a triple-plus operator.

          But I thought C++++ had already been done: C#

    2. Anonymous Coward
      Coat

      Naming...

      Ok, everybody wants to associate the name, but what about naming it D, E, F, whatever? C was created as a significant evolution of B...

      Yes, me and my poor coding skills are leaving...

      (whoever failed 3 times to write a "Hello World" inside a text box after reading C for dummies shouldn't be allowed near a compiler, like me.)

  2. Mikel

    We do need new tools for multicore

    I don't know if this new C++ is what we need, but there has been a need this past five years for a toolset that approaches the bare metal like C, but leverages the many core direction our processors are moving in.

    Whatever the end product is, it should be able to handle heterogenous cores, because that's the direction platforms are moving in. Multiple different CPU cores, GPUs, hardware media decoders, varying forms of ALU, RNG's and PhysX units included in the silicon. The core system is getting revved these days far faster than before and with a lot of oddball things that didn't used to be considered part of the platform. The software tools are lagging these days, as dealing with this riotous mix always involves custom coding.

    It's incredibly complex. I think we'll be groping about for an easy answer for a long time, and in the interim kernel coders are going to earn their money. More power to 'em. Whatever the answer is, it ain't Java, nor C#, nor COBOL.

    1. Anonymous Coward
      Anonymous Coward

      upvote

      because this post is:

      objective, critical, balanced and rational

      nicely done

    2. Anton Ivanov

      There used to be a tool

      I know I will get shot down for saying this, but the tools are there. They are called Ada, Erlang and Smalltalk.

      The problem is that the first is universally hated by everyone and the latter two have failed to gain enough ground outside Europe.

      1. Someone Else Silver badge
        Thumb Down

        Say What?

        Ada? The PL/1 of the 80's?!?

        You mean to say that someone threw in **even more** kitchen sink-ism to support such modern nuances as multicores into Ada, and we weren't informed?

        Shirley, you jest...

        1. Anonymous Coward
          Angel

          kitchen sink-ism

          Nice! and entirely fitting where Ada is concerned (was? it can only be hoped...). Designed by committee (commisariat) and it showed. Did have some basic concurrency as you say but could you massage the rendez-vous into a realistic multi-core implementation once you've hit the runtime system hard enough? Discuss*.

          Then they shovelled OO into it, but I'd got out by then - C++ it was so sexy! That committee - Grady Booch did alright out of the DoD, no? - stole my youth, the bastards. But now I'm happy, stroking my Python with some Lua and giving the bits some deep down C love...

          Did I tell you about the years spent writing Lisp? These days, I just need to find the time to cut some serious Erlang.

          *I think that's a "no", probbly.

    3. Nigel 11

      Google's GO language?

      Take a look at Golang. Looks like the right idea set for multicore, albeit immature.

  3. Peter 70

    D

    El Reg seems to have been running lots of stries about Go recently. D goes largely unmentioned, which is a shame (mind you, understandable, the team behind Go have been much more savvy about getting the word out about what is a slightly more targeted and thus easier to explain language).

    True. D invites ridicule with it's name, but version 2 does start to deliver: much like C++0X it's an attempt to adress the short comings of C++ (the difficulty of programming well) and, of course, concurrence, while retaining the performance and ultimate flexibility of a 'big' language as opposed to a Ruby etc.

    Andrei Alexandrescu's book on D is worth a read - if only for its propensity to discuss the motivation behind the design of a language (he's been a driving force behind the version 2 revision of the language).

    1. Tasogare

      D2

      I'm glad someone mentioned this. I've been experimenting with D recently and, while it seems fairly obscure, it's surprisingly good at what it claims to do. I keep waiting for it to bite me and it doesn't.

    2. h4rm0ny
      Thumb Up

      D

      I'm glad to see that other D supporters are out there. The moment I saw a headline about an improved C++ I wanted to grab my monitor and shout "It's here! It's called D!"

      D has addressed almost everything I could want it to address about C++. It's a great language that deserves to become mainstream. And I'll echo what you say about Andrei Alexandrescu's book on D. It's the most entertaining and interesting books on a programming language I've ever read. I've got it on Kindle and for a while, it went everywhere with me being just as interesting to read (moreso actually) than the novels I usually carry around for my leisure reading.

      If the world of programming really is a meritocracy, then D deserves to be out there and popular.

      1. Ru
        Coffee/keyboard

        "If the world of programming really is a meritocracy..."

        Ahahahaha.

        From the article, "PHP, Ruby, and JavaScript? Sure, some might claim that they are the future..."

        Read it and weep. There is very, very little that is meritocratic about software development and tools. It is all accessibility and popularity with the usual dose of not-invented-here, lets-reinvent-the-wheel from each generation of new devs. There is no thought of whether there are better tools and languages out there already.

        But don't take my world for it, I like Perl and Erlang.

        1. ian 22

          @Ru

          Very positive comment. For balance I'll add C++ is putrid, and I hate it.

  4. Michael 17
    Unhappy

    About *&#! time!

    Every time I have to listen to the annoying fanboys praise C++, I have to grit my teeth to avoid strangling them! I write low level lock-free concurrent algorithms for a living, Getting them right in C++ has always been much more of a pain in the ass than in Java, and the main reason is the lack of a clear memory model. I hope when they claim they're defining a C++ memory model that they're also including a proper suite of memory barriers and the like. I'm still bitter that the last C++ standards committee discussed the weakness of the volatile keyword, but then decided to punt the issue into the future.

    Now we'll just have to wait 5+ years for the C++ compilers to actually do the right thing when you have code that really depends on the memory model.

    1. Bartosz
      Alert

      Memory model

      @Michael 17: I think you'll be happy with the new C++ memory model. If all you need is Java's "volatile" and sequential consistency, the C++ equivalent is the strong form of "atomic". But (weak) atomics can give you much more control than Java over lock-free semantics. You can portably do things that could only be done using "unsafe" code in Java. You get tools to relax sequential consistency without running into undefined behavior. Obviously, you can shoot yourself in the foot doing that. But that's C++.

    2. Tchou
      Pint

      memory model?

      I'd'love to hear you speaking of Java memory model, and how you can control it.

      If you want clear model use C. How does a sky high abstracted language can help grasping the memory model?

      1. Michael 17

        Specified behavior is better than unspecified behavior

        A "sky high abstracted language" helps by actually having a defined memory model. C++ does not. Regardless of the underlying hardware provided memory model, the C++ compilers can do a variety of memory reorderings. The only control you have over that is with the volatile keyword, and the prior C++ standards committee deliberately bailed out of providing better memory semantics than volatile provides. Different C++ compilers end up using different mechanisms for saying you need a memory barrier, but there's no portable way to do that.

        So if you're content to write C++ code targeted at (modern) x86 CPUs compiled with gcc, you can do it. But if you'd like to write a portable library, you're screwed.

        A little searching will turn up plenty of web pages with long discussions of the issues here.

  5. Christian Berger

    One solution to get more speed

    Get rid of the copy constructor. Please! I know it sounds like a good idea on paper, but people just aren't going to use pointers when they have to put funny characters around them.

    The point is, it's the idiots who need help, not the experts. Nobody who knows what they are doing will ever complain for having to put some extra code into some exotic or dangerous program part. However requiring the idiot to learn C and Assembler, as well as all the implementation details of that platform, just to avoid the biggest pitfalls, isn't going to work.

    My point is: Unlike what many C++ programmers seem to believe, it is possible to have systems which are both easy to use/program and powerful and fast.

    1. Shakje

      I'm going to assume two things

      1) That you've been following 0x

      -and-

      2) It hasn't changed significantly since I last looked (which was a bit of time ago)

      So:

      1) Pointers, bleh, there's no reason whatsoever (that I can think of) not to be using a combination of references and smart pointers (shared_ptr is in the MS TR1 implementation now, if you don't want that you can get the whole shebang with Boost)

      2) 0x brings move semantics, i.e. instead of copying the data, you transfer ownership of it to another object, have a look at it if you haven't already

      3) It's perfectly possible to write platform-independent code without writing all the gubbins that go with it by using Boost and a bit of common sense. If you want to optimise it then go ahead, but only if you're advanced.

      The really unfortunate thing about C++ is that backwards-compatibility thing. Unfortunately, it's too late now to start making things obsolete or unavailable, and there's not much can be done about that. Too many teachers don't talk properly about pointers and references, or RAII, or the pitfalls of constructors and the way inheritance works, and so on, and not enough companies are willing to enforce decent standards to control their C++.

      I guess what I'm trying to say is that the language could do with a clean-out, but that will probably never happen. I'll have a look at D, Alexandrescu is one of my favourite C++ writers, Modern C++ Design is one of my most worn-out C++ books.

    2. Field Marshal Von Krakenfart
      Boffin

      Simples

      "Unlike what many C++ programmers seem to believe, it is possible to have systems which are both easy to use/program and powerful and fast."

      Yeah, it's called cobol, and on a mainframe

  6. jake Silver badge

    Whatever. When doing real work, I'll stick with K&R C and inline assembler ...

    I don't want the compiler to tell me what I can & can't do with the hardware.

    But then, I'm a hacker[1], not a sheep.

    [1] Old jargon meaning, not modern journalistic meaning ...

    1. Anonymous Coward
      Anonymous Coward

      the usual trite narrow-minded drivel

      "When doing real work, I'll stick with K&R C and inline assembler"

      Define real work. It may be that you are only confident with the tools you have already used. It may be that the "real work" you do is all about solving small problems that do not require any degree of abstraction.

      "I don't want the compiler to tell me what I can & can't do with the hardware". And if you want to program close to hardware, you are on the right track. Can you conceive of a problem space where you need to think bigger to solve a more complex problem? If not then you should stick with the mucking out.

      "not a sheep." Arrogant, narrow-minded and, here's an irony, unintelligent.

      1. jake Silver badge

        @AC20:46

        "Define real work."

        Coding close to the hardware, which should be obvious from the comment your replied to ... but for some reason you seem to think I'm not allowed to comment on that ... I mean, "stick the mucking out"? WTF?

        "Can you conceive of a problem space where you need to think bigger to solve a more complex problem?"

        Yes, I can. Are you equipped to understand my commentary?

        "Arrogant"

        I prefer "capable".

        "narrow-minded"

        I prefer "knowledgeable".

        "and, here's an irony"

        God is an iron ...

        "unintelligent."

        Says the AC, with no actual rebuttal to my post...

        1. foo_bar_baz
          Mushroom

          Nerd testosterone alert

          The AC probably had an issue with your implication that:

          - other than close-to-hardware programming is not "real work"

          - using a HLL makes you a sheep

          Both of which rubbed the AC the wrong way, who's obviously proud of his own "real work" that involves using a compiler. I don't think he disagreed with your choice of tools, so he wasn't trying to offer a rebuttal.

          Just calm down and get back to your workstations. The managers want that code yesterday.

          1. jake Silver badge

            @foo_bar_baz

            Most programming that isn't close to the hardware is frivolous. Think about it.

            It's not the HLL that makes you a sheep, it's the mind-set (see "app stores" and the like, and what they mean in the great scheme of things).

            I lost interest in managers over thirty years ago ... I'm my own boss :-)

  7. Paul Fremantle

    C++ Garbage Collection

    There is a good reason they still haven't added Garbage Collection to C++......... there would be nothing left. Boom Boom.

    1. sT0rNG b4R3 duRiD
      Joke

      None left?

      Ah, no... You'll be left with C :P

  8. Anonymous Coward
    Stop

    Mac OS X written in C++?

    More like C and Objective C. A very nice subset/superset pair of languages I might add, and more or less the antithesis of C++. (I like to think of C++ as the perfect language for writing an OS kernel using the OO paradigm. Except you don't need OO for kernels. You need it for applications. And applications are much better served by the dynamism of Objective C.)

    1. Steen Hive
      Go

      IOKit

      XNU is a hybrid microkernel The entire Mac OS X device-driver subsystem and accompanying user clients are written in C++, and very bloody good it is too.

  9. Mage Silver badge
    Mushroom

    Concurrency

    In 1987 I argued that it was a flaw not supporting Concurrency and that the language had learnt nothing about simple interfaces to building large systems from Modula-2. Modula-2 and Occam are older and both have concurrency support as part of the language.

    Since the 1970s we knew a new language would need Concurrency, Multi-cpu support etc.

    Also large C++ projects still too much depend on tools like Make. You should not need a separate file in a scripting language to build a large project.

    Strings and Buffer Over-runs. Most Security Vulnerabilities and bugs.

    Again by late 1970s it was known the default should be array bound checking. At outset of C++ in late 1980s the shortcomings of Strings in C was known and half baked string classes produced. It should have been a bit like VBSTR, not just null terminated but a size stored as well if dynamic, if Static the compiler knows the size. Then "count" to return the max number of array elements (string or otherwise) and "length" for size of array (or characters in string before null terminator).

    C++ was born deformed due to having to be as backward compatible as possible with C, which after all wasn't really developed as a HLL at all but as a portable macro assembler to port UNIX and UNIX applications. Any form of Template, macro or define has no place in a safe language with human readable programs.

    Obviously any native compiled language that's got a decent compiler is going to beat "p-code on Virtual Machines" (VB6, .Net, Java) or scripting languages. So no surprise C++ wins that competition.

    1. Anonymous Coward
      Anonymous Coward

      What C++ templates have to do with C backward compatibility?

      It is a star feature if you compare it with Java generics...

    2. Paul Shirley

      the build process

      "You should not need a separate file in a scripting language to build a large project."

      *Every* large C++ project I've ever worked on contained a large number of external resources that needed format conversion, precompiling, packing or other processing and the final output needed some sort of packaging or resource binding. Why on earth would tightly binding that to the C++ component make any sense at all?

      A tool like make is a pretty good solution to an opened ended problem like the build process, where there's no way of even knowing what tools a dev might need to run during the build.

      Decoupling the build *process* from any of the tools invoked while building is exactly the right solution. Scripted solutions like make are one of the more powerful options.

  10. Anteaus
    Coffee/keyboard

    {[Time] (to) {ditch {C syntax}}} ? ;

    C, C++, C#, Java, Javascript, PERL, php etc. are all fundamentally similar in using a punctuation-heavy syntax as opposed to an English-like syntax. Worse, the punctuation symbols most often used are those which most typists find hard to touch-type owing to their placement on the keyboard. (and let's face it they were placed where they are because they are rarely used in standard typing)

    Apart from leading to slow, finger-twisting typing this heavy reliance on punctuation makes it hard to spot errors. A missing } can lead-to all kinds of weird error messages, most of which bear no relation to line with the actual error.

    While English-like syntaxes involve more characters per statement, this is easily offset by the fact that they can be typed much faster, and debugged more reliably.

    The choice of C syntax came about in the early days of the PC, through the need for a language which would deliver satisfactory perfromance on the puny 8086 processors of the day, but which would offer easier coding than pure assembly language. The fact that we're still using this syntax in the days of phones with GHz processors and PCs with more power than an early mainframe is historical, and somewhat farcical. It's akin to insisting on using CGA graphics on a 24" LCD.

    If as the article says there's a need for a rethink of programming languages to properly handle concurrent processing, then this may also be the point to stop using the archaic C syntax.

    1. Anonymous Coward
      Anonymous Coward

      "choice of C syntax came about in the early days of the PC"

      What ??!!

    2. Destroy All Monsters Silver badge
      WTF?

      U complain about the syntax?

      This is 2011. There are IDEs and check-as-you-type syntax verifiers, you know.

      And speed-typing when coding is really a non-issue.

      "as opposed to an English-like syntax."

      Because SQL was a big success in clarity?

      1. Andrew Hodgkinson

        Well, not SQL perhaps...

        ...but Ruby is really rather nice.

    3. Christopher Key.
      Megaphone

      Syntax

      I take issue with almost all of the above!

      On ease of typing, I fail to see how typing "}" can possibly be slower than typing e.g. "End If", especially when including wasted time relocating the cursor to correct typos.

      On spotting errors, I fail to see how a missing "}" can be easier to spot than a missing "End If". The eye automatically matches bracket pairs, whereas matching "If", "End If" is far harder.

      On the comparison with English, note that English can be pretty punctuation heavy when conveying complex concepts, and all the better for it. Compare the following:

      > "When you wake up in the morning, Pooh," said Piglet at last, "what's the first thing you say to yourself?"

      "What's for breakfast?" said Pooh. "What do you say, Piglet?"

      "I say, I wonder what's going to happen exciting today?" said Piglet.

      Pooh nodded thoughtfully. "It's the same thing," he said.

      > Open Quote When you wake up in the morning Comma Pooh Comma Close Quote said Piglet at last Comma Open Quote what's the first thing you say to yourself Question Close Quote

      Open Quote What's for breakfast Question Close Quote said Pooh Stop Open Quote What do you say Comma Piglet Question Close Quote

      Open Quote I say Comma I wonder what's going to happen exciting today Question Close Quote said Piglet Stop

      Pooh nodded thoughtfully Stop Open Quote It's the same thing Comma Close Quote he said Stop

      1. foo_bar_baz
        Linux

        @Christopher key

        Perhaps the answer is not being verbose. I offer Python as a good example.

        As a Perl fan the indentation put me off, but I had to use it in my work. I've since ditched Perl. On the rare occasions when I have to write JavaScript the braces and parentheses look very cluttered.

        Tux because penguins and snakes go together well.

    4. Anonymous Coward
      Anonymous Coward

      Here come the S-expressions! All for it.

      And functional programming solved concurrency years ago. ;P

      1. Anonymous Coward
        Anonymous Coward

        Re: Here come the S-expressions! All for it.

        "And functional programming solved concurrency years ago. ;P"

        Shame they make everything else harder (thinks of Haskell and shudders).

    5. Anonymous Coward
      Boffin

      Re: {[Time] (to) {ditch {C syntax}}} ? ;

      (indeed (time-to (use (proper (and syntax language)))))

      'nuff said.

    6. Bartosz
      Coffee/keyboard

      C++ syntax

      @Anteaus: The use of punctuation might be annoying for beginners, but you can get used to it and then it actually saves you typing and makes programs less verbose (and that's important, because you don't want the mechanics of the language obscure the logic of your program). However there is one big handicap that C++ inherited from C and that is declaration syntax. Even Herb Sutter openly complains about it. But changing the syntax now would break so much existing code that it's not a realistic option.

    7. PotNoodle

      Re: syntax

      My only bugbear with C++ syntax is is really more to do with fonts - if in my stupidity I've put something in normal brackets instead of curly, the two look quite similar in some default typefaces (such as the one Code::Blocks uses by default), especially when rendered in 10-point. This can lead to a lot of confused squinting before I realise what's up. Easily solvable with a little customisation, though.

      I suspect the syntax could be simplified a bit if the committee felt it necessary. There's already a degree of context-sensitivity towards what each punctuation mark means - e.g. when I type a semicolon in the conditional block of a for loop, the compiler knows it doesn't mean "this is the end of the function". Personally I like using the current syntax - having plenty of different punctuation marks in play makes the code more readable once you understand what they mean. Plenty of other syntaxes (syntaces?) could use a little more variety in this area.

Page:

This topic is closed for new posts.

Other stories you might like