back to article An unthinking programmer's guide to the new C++

So what’s all this about a new C++ standard, Verity? Why you asking me? I know nussing. I’m down to write ‘Porcine influenza — a programmer’s perspective’ this month. Don’t fib. Oh very well. The enthusiasts imprisoned in the ISO C++ bunker are reputedly on the point of lighting a white smoke bonfire to indicate they have a …

COMMENTS

This topic is closed for new posts.

Page:

  1. nicholas22
    Unhappy

    No shit sherlock

    Without any productivity enhancements, c++ will just keep losing its developer base.

  2. Matt Bucknall
    Coat

    Not one to be pedantic, but...

    Don't you mean delayed until 7DA, or indeed until 7DF?

  3. Anonymous Coward
    Anonymous Coward

    Long wait...

    "Actually the C-plus-plusers point out it could be delayed until 200A, or indeed until 200F".

    Since 200A is equivalent to 8202 in decimal, that means we could be in for a 6193 year wait.

    If 3D Realms hadn't just gone belly up, I'm sure there'd be a joke in there about the new C++ being used to write Duke Nukem Forever.

  4. Anonymous Coward
    Joke

    I think

    #define RIDICULOUS int i = {};

  5. Noogie Brown

    urgggh

    let c++ die already. it really is a monstrosity.

  6. Anonymous Coward
    Anonymous Coward

    hehe great spoof article

    imagine if someone were really to try and put those things into C++

  7. Anonymous Coward
    Anonymous Coward

    Square brackets

    "...complete with a wonderful square bracket syntax for deciding which bits of local state will arise from the undead when the thing is called..."

    Interesting. The C# compiler just decides on its own, which occasionally leads to curious bugs with anonymous methods if you aren't wide awake.

  8. A J Stiles
    Happy

    Out-of-order loops

    Been able to do this in Perl since forever:

    #!/usr/bin/perl -w

    use strict;

    foreach (1,2,5,6,4,7..10) {

    print "$_\n";

    };

    exit 0;

    Nice to see another language catching up.

  9. Adrian Challinor
    Unhappy

    concepts

    I can't get the concept of a concept - may be my axioms are wrong.

  10. Pirate Dave Silver badge
    Pirate

    If I wanted to do that, I would code in Pascal

    You say that like it's a bad thing...

  11. Anton Ivanov
    Linux

    Re: Out-of-order loops

    Yeah,

    After reading this tripe and comparing it to Perl I really want to see the justification C++ people put into calling Perl unreadable.

  12. danny_0x98

    Erlang?

    Then there's some chance of grokking the new syntax. If you had chosen APL as the follow-up comfort language, then the hazard and "Abandon all hope" signs for this iteration of C++ would be boldly and definitively posted.

  13. Ken Hagan Gold badge
    Happy

    Hehe, great spoof comment

    "hehe great spoof article

    By Anonymous Coward Posted Thursday 7th May 2009 12:24 GMT

    imagine if someone were really to try and put those things into C++"

    Imagine if someone really didn't realise that they have done.

  14. Tony Hoyle

    It may be a joke piece but..

    I can actually see the point of &&, if I'm reading the joke right.. returning a complex object is a bit of a pain currently - you either have to copy or use pointers to some stored object. I presume it's intended as some kind of language analogy to a smart pointer, without having to write your own (everyone who's used C++ for a while probably has a smartpointer class somewhere).

    The rest of the stuff is howlingly bad.. auto encourages lazy programming and would be a bug magnet (you can't even argue it for templates.. those should be typedefed). I can't even parse the curly brackets joke..

    If anything, a new version of C++ should simplify it.. there's too much duplication where they decided to slightly change something that was already in C just to make it 'different'.

  15. Rock Lobster
    Happy

    @ Ken

    imagine if someone couldn't tell an ordinary comment apart from a joke comment

  16. IHateWearingATie
    Boffin

    I used to code in C and C++...

    ... and I didn't understand a thing in the article or the comments. I must truly have passed to the Pointy Haired side.

    Pointers...I think I remember them...

  17. Anonymous Coward
    Coat

    Mmmmm, yup ...

    ... this article sums up rather nicely why I loathe and detest C++ with the burning passion of a million, red-hot suns.

    Kind of vindicates my continued use of Perl and Java or, in some cases, Plain Old C.

    It's the one with K&R first edition in the pocket.

  18. Brian Miller

    Sounds like C-- instead of C++

    A while back I was working with a fellow who regarded himself as a total C++ guru. He would put try-catch around functions that didn't throw, and things like that. Now I see that C++ is doing its best to behave like a dynamically interpreted language. If you want to write in Perl, why not just do it?

    Oh, and C++ still has to be fully compatible with K&R.

  19. amanfromMars Silver badge

    Paranoids Corner ....SchizophrenIQs Retreat ...... Sanity's Redoubt

    Verily I say, King Egg Fooey for Chip Stewards ...... and AI NEUKlearer Lead .... with the Full PerlyGatesPython Monty in Stealthy Cloud Cover, Verity?

    Think of IT as an ESPecial Phormation of Special Post Modern Relationships and Light Years ahead of Hieroglyphics and Lost Covenant Arks.

    Step into the Parlour, says the Spider to the Fly ..... "'Tis the prettiest little parlour

    That ever you did spy."? :-) ...... http://ingeb.org/songs/thespide.html

    Life is AIdDynamic Game, Full of Future Plans for Universal Players/Movers and Shakers.

  20. Jerome

    @ Rock Lobster

    Imagine the entire comments section buried in such a mire of postmodern meta-irony that no-one can tell what's going on, or indeed even recall what the original article was about.

  21. Anonymous Coward
    Thumb Down

    No Thanks

    I'll stick to C.

    I don't want inheritance or templates.

    All I want are my lovely pointers and the ability to use them.

    Everything else is for sissys.

  22. easyk

    I like C++

    Am I wierd? After using boost for a couple years and eliminating most of my OS dependencies between QNX, Linux and Windows I really began to appreciate the power C++ gives to library developers. Most of the complex constructs in C++ are only used where needed and then hidden away in a library or class so you can have neat and easy to understand code while still having powerful full control code under the hood. Besides Perl performs poorly for device drivers.

  23. E

    I read a quote from

    ... K or R a few years ago, where it was said "Now that C++ has got away from us..."

    He was IIRC talking about template metaprogramming vs 'just solve the programming problem at hand.'

    I dunno about this stuff. Tempates are great if sometimes obscure. The STL is great, Boost is mostly great, but it's kinda like the sermon on the mount: I don't claim to understand all of it.

    Some of the other stuff looks like angels dancing on the head of a pin. Trying to be all things to all people generally results in a big mess. KISS applies here.

    int i = 0; // OK

    int i = {}; // WTF? What obscure subtlety is this syntax addressing?

    auto fn(int foo) { ... }; // Most C++ programmers *like* C++ strong typing. Why break it?

    The right hand reference && thing (wrong name?) does make some sense though.

    Editors: let's have a K or R or K'n'R icon!

  24. Colin Barfoot
    Thumb Down

    gawdelpus

    So rather than removing all the half-arsed parts they thought they'd add some more, and not just silly academic additions, no, they'll be "Improving Standard C++ for the Physics Community".

    I notice that members of the old crowd are still there: Francis Glassborow (remember him Verity?), Herb Sutter, P.J. Plauger. Seems like a cosy get together for old time's sake. One for road.

  25. Frumious Bandersnatch
    Thumb Up

    ha you almost had me there

    Until the bit about lambda functions! Now if only they'd implement first-order closures ...

  26. Boris the Cockroach Silver badge
    Joke

    Yikes its alive

    I've looked into both C and C++ (and the m$ version too) and came to the conclusion that the designers of both C and C++ just wanted a language that used all those unused symbols on a keyboard...

    Boris

    mmm Java

  27. Peter Geoghegan
    Thumb Down

    Questioning the motives of C++ haters

    Concepts, or concept checking, explicate the implicit interface of templates. They are a way of ameliorating the problem of templates producing terrible error messages when used incorrectly. Prominent C++ pundit Scott Meyers, well known in the C++ community as the author of the "Effective C++" series, has questioned the necessity of concept checking in the new standard.

    The whole point of supporting initialiser lists (the { } syntax) is to allow classes, particularly containers such as std::vector to be initalised like arrays. i.e.:

    std::vector<int> container = { 5, 6, 7, 8};

    This previously wasn't possible.

    References aren't pointless. They are safer than pointers, in that they cannot be null, must be initialised, and their value cannot be changed once initialised - They become an "alternative name" for the value, as oppose to some distinct construct that points to the value. This facilitates operator overloading, and simplifies code. If it wasn't for references, you'd have to de-reference the pointer returned by the operator:

    my_class a, b;

    ...

    my_class c = *(a + b); // returns a pointer that is de-referenced - defeats the purpose of operator overloading

    As against:

    my_class c = a + b; // exploits user's intuition of what + ought to mean

    C++ certainly has more than its fair share of warts, but can we please see an article written by someone that understands the rationale behind the introduction of C++0x's new features?

    I have plenty of criticism I could make of C++ in general, and C++0x in particular, but I feel most of C++'s defects can be attributed to historical reasons, or the fact that major sub parts don't gel together flawlessly. It seems to me that often the shrillness of the criticism you hear of it posted anonymously on the internet is in direct inverse proportion to the poster's actual knowledge of the subject - typically, they make sweeping remarks like "C++ is shit", or "C++ is to C as lung cancer is to lung", whatever that means. Why is it shit? If it is shit, how do you account for the fact that many major projects have successfully been completed in C++, among them GoogleFS, Photoshop, Firefox and openoffice.org - are the organisations that created those project just stupid? What would you write, say, photoshop in if you were starting from scratch? I suspect that these people's needs ( I suspect that they're web application developers and Java/C# developers that produce middle of the road business apps) are not best addressed by C++ in any case, but perhaps if they tried a modern C++ framework like Qt or WxWidgets they'd find that many of the oft-repeated put-downs are overstated, outdated, or just false (example: C++ is the only language that combines higher level abstractions with manual memory management, which is bad. Ever hear of RAII, or for that matter Ada?). Some of these same criticisms can be made of C (most prominently, things about the inherent dangers of native code), but people don't criticise C because Unix is C and Unix is cool and I'm a hacker. The difference with C++ is that you don't have to use C's low level constructs like char pointers for strings, or printf statements - there's always a much better, safer alternative.

    A common, and valid, criticism of C++ is that it poorly encapsulates compilation units, necessitating recompiling client code when a class's definition is changed. That's the price you pay for the speed of having true local variables on the stack - the size of the class must be known in advance of compilation. The greater point illustrated by this example is that, essentially, C++ addresses the needs of a large (though largely reticent) group of people with a particular set of requirements that want the particular set of trade-offs that are least bad to them. Could there be, in principle, a language that better addresses *their* needs or preferences? Definitely. Is there one? For most of them, no. The number of people using C++ is not currently in decline (it was a few years ago), it just isn't growing as fast as the user base of other languages (source: Bjarne Stroustrup's website).

  28. Martin Silver badge

    @I read a quote from

    So there are now three different syntaxs to set a variable

    int i = 0; // but you still can't do this in the ctor

    i(0), // need to do it this way in the initialisation list

    int i = {}; // useful if int is redefined I suppose

  29. Anonymous Coward
    Boffin

    Hmmm

    Even to the initiated these features look like a bit of a hard sell. However, anyone put off by the enhancements isn't in the market for C++ in the first place, so that is probably as is should be. I don't see C++ losing it's 'expert only' status anytime soon (which is laughable if you can remember when there wasn't really much of an alternative).

    Some things are just complicated and other things are needlessly complicate (COM programming in C anyone?), but if you want to get the most from your machine you have to go beyond the average.

    What will be interesting will be to see what new compiled language eventually comes along to properly challenge C++ (Digital Mars D seems like the obvious one a the moment, but that has its own issues). That isn't likely to happen anytime soon I would say.

    If the new C++ features have you reeling in horror, then gues what - it obviously isn't for you. Just like device driver or OS kernel programming isn't for everyone.

  30. Robert Synnott

    @Brian Miller

    "Oh, and C++ still has to be fully compatible with K&R." - C++ has _never_ been fully compatible with K&R. Never ever.

  31. Anonymous Coward
    Anonymous Coward

    @E

    Fair comments. Yes, int i = {} is pretty bizzare I agree and I sympathise with 'angels dancing on the head of a pin' comment. I think it's undeniable that there are elements of this as C++ gets more sophisticated!

    However, I think the auto keyword will be fine if it is implemented sensibly. The whole point is that you still have strong typing, but you no longer have to type an essay to define a complex type (and yes, I do religiously use typedef, but that is hardly the point).

    At least the comments haven't degenerated into a total flame-fest yet!

  32. Ralph

    Replies miss the point

    As I read it, the article is intended to be humorous rather than a serious critique of C++. It's funny even for a C++ developer if you can momentarily detach yourself from understanding why these changes were made and what they achieve. But can we be spared the harsh replies? C++ is very good for specific purposes, as every other language is good in the right context. For those who understand and appreciate the language, these replies sound like email neophytes scoffing at the @ symbol in an address as if it were obvious to all how stupid it is.

  33. Anonymous Coward
    Anonymous Coward

    @Peter Geoghegan

    Yeah, bring on the rants! Excellent!

    As much as I agree, the problem is it's pointless trying to convert the 'it's too hard' crowd. They've already closed their minds to the whole conversation. The trouble is C++ take concepts from many other languages and fans of those other languages resent it.

    Observe all the hate from C programmers and functional programmers alike.

    As Bjarne himself stated, inside C++ is a smaller, cleaner language struggling to get out. With the new standard that struggle can only be harder I guess, but it certainly doesn't diminish the good work done in creating it.

    As you obviously realise from your other comments, C++ will continue to flourish on its own merits - but this isn't 1993 and never will be (yes, I realise you also realise this!)

    Regards

  34. BlueGreen

    @Peter Geoghegan

    a decade+ ago I spent a week trying to get a tiny test prog (one or two hefty lines of STL) running using the early STL with metrowerks C++.

    I lost. Broken compiler, broken STL. It put me off for life.

    I can handle C++ and welcomed some of it but the tangled, obtuse, spiny and obstreperous mass of the language eats too deeply into my limited cognitive reservoir, which I prefer to keep for tackling the quite-sufficient complexities of app development.

    The cost of using it is too high for me so, no ta if I can help it.

  35. Werner McGoole
    Thumb Down

    When you're in a hole

    Stop digging!

  36. Anonymous Coward
    Anonymous Coward

    @Brian Miller

    "Oh, and C++ still has to be fully compatible with K&R."

    Rubbish. C++ has never ever been K&R compatible (whatever you mean by "compatible").

    Even C does not need to adhere too closely to the original K&R spec. Lots of weird so-called "illegal" code compiles just fine and dandy. Depends on what you're trying to do. That's kinda the point, y'see?

  37. Anonymous Coward
    Anonymous Coward

    C++ is the orchestra

    it is designed to keep developers in jobs for as long as they like or for how long the money lasts.

    All these features are valid for certain types of problems, and for problems people have yet to really define.

    C++ is normally not the language to choose for any particular thing if you are responsible for the budget, but if you had to only use one environment for everything then C++ would be it.

  38. Mr Larrington
    Paris Hilton

    @Ralph

    It's funny even if you know sweet FA about C And All Its Spawn, which to me is about as comprehensible as Ancient Greek.

    Now, where di I leave my FORTRAN compiler?

  39. Richie

    CORAL66

    "And you can make for loops in a style I last saw in CORAL 66, where one provides the list of values the loop variable takes."

    MATLAB and R both do this. You pass in an array of whatever you like, and the language iterates over each element.

    MATLAB style:

    for i = [1 3 69 -7]

    % something

    end

    R style:

    for(i in c(1 3 69 -7))

    {

    # something

    }

  40. Anonymous Coward
    Happy

    ...and my Java 2p worth...

    for ( int i : new int[] { 1, 2, 5, 7 } ) {

    // nothing new here...

    }

  41. Bruce

    This is all well and good...

    ... but what does Kevlin think?

  42. Kevlin Henney

    What does Kevlin think?

    On a really good day, a great many things. On a not-so-good day, very little.

    But what do I think about C++0x? On the whole, the wrong thing at the wrong time.

    Kevlin

  43. JP Strauss
    Gates Horns

    haha

    HTML kicks C++'s ass.

  44. Steve Evans

    At this rate...

    ...by 2010 every C++ project is going to have to be supplied with it's own Rosetta stone!

    /me rapidly returns to the nice structured and strictly typed world of Delphi where basic operators are still words.

    Ahhh... That's better... *sigh*

  45. Anonymous Coward
    Thumb Down

    SAPPEUR

    Check http://www.sappeur.eu. That is real innovation on top of C++:

    -Safe as Java

    -Trace Garbage, don't collect

    -All pointers are Smart Pointers

    -multithreading is made explicit in the Type System

    -Array access is always checked

    -Heap and Stack are safe

    -References can (and should) be used

    Save Energy and conserve Money - use SAPPEUR !

  46. E
    Thumb Up

    @Anonymous Coward

    "...the auto keyword will be fine if it is implemented sensibly. The whole point is that you still have strong typing, but you no longer have to type an essay to define a complex type..."

    I conclude I need to spend a bit more time understanding the auto keyword. It seemed to me it was sort of a 'variant', like in VB. Your comment contradicts this. Thanks.

  47. E
    Happy

    @Colin Barfoot

    The thing about C++ (and to a good degree C also) is that it is a very open ended language. So you can do all this wild stuff with it that Stroustrup maybe never dreamed of. The people you mention are IMHO people of good faith. In scientific computing FORTRAN has lost some ground to C++ - so adding complex numbers and such is a good idea.

    What really convinced me C++ was worth learning and using was it's combination of flexibility and expressiveness and compactness (compared to most other languages at the time). That's what hooked me about C too.

    But, hey, the ability of a language to express increasingly subtle things gives us arm-chair language designers something to talk about, eh? 90% or 95% of C++ programmers and C++ programs will not use the more esoteric new features. But where they are useful, nothing is wrong with having them.

    My $0.02.

  48. E

    @Anton Ivanov

    Unreadable: there's the potential problem. It does seem to me that the proposed changes will introduce greater scope for unreadability. Haha, so the compsci profs teaching C++ courses will have to come up with new programming rules to go alongside "Do not use goto".

  49. E

    Last comment

    Someone pointed out above that the article was probably more a humour piece than a critique of the language. I agree.

    Now, if you want to read something funny about a programming language, go find a copy of the Intercal programmer's guide. Suspend criticism and just read. You'll probably laugh your *ss off!

  50. Anonymous Coward
    Unhappy

    A sad day

    I read the piece and despite not having touched a line of code in about 18 years I still laughed and got the jokes. I'm even more geek than I imagined.

    Mine is the one with "'m really not THAT much of a geek" printed on the back.

Page:

This topic is closed for new posts.