Slashdot Mirror


Stroustrup on the Future of C++

/ASCII writes "Bjarne Stroustrup, the father of C++, has written an essay [PDF] on the features of the upcoming C++0x standard. In his essay, he argues that new features should whenever possible go into the standard library and not into the language, but that the language needs to shave of a few rough corners to make it easier to use for novices."

102 of 661 comments (clear)

  1. wait a moment... by Anonymous Coward · · Score: 5, Funny
    [...] to make it easier to use for novices.
    Doesn't this qualify as blasphemy?
    1. Re:wait a moment... by insert+cool+name · · Score: 5, Funny

      Doesn't this qualify as blasphemy?

      Not when it's God talking.

      --
      Never trust anyone with an id greater than 889388
    2. Re:wait a moment... by Mark+of+THE+CITY · · Score: 2, Funny

      Parent reminded me of the apocryphal objection to COBOL: "But Grace, darling, that will allow anyone to program" where the comparison is to assembly language.

      --
      The clearance system sounds logical. It is not. It is completely arbitrary. -- John Bolton
    3. Re:wait a moment... by Kurt+Granroth · · Score: 4, Insightful
      Not when it's God talking

      Speaking of which, did anybody else notice the author description in that article?

      "Bjarne Stroustrup is the College of Engineering Professor in Computer Science at Texas A&M University"

      What!? Isn't that like saying the George Bush is a businessman from Texas? It's technically true, but completely misses the point on what matters.

      This makes even less sense when you try to find the target audience. If the person reading the article already knows who Bjarne is (by which I mean every single C++ programmer), then I could see them omitting the entire "creator of C++" description because, well, they already know... but then why have a description at all?

      If the person doesn't already know who this "Bjarne" is and they are reading the article, don't you think they'd want to know that he created the thing and therefore might have some relevant opinions on that matter?

      Very odd...

    4. Re:wait a moment... by Anonymous Coward · · Score: 4, Funny

      "What!? Isn't that like saying the George Bush is a businessman from Texas? It's technically true, but completely misses the point on what matters."

      I don't know... don't most people prefer to emphasize their accomplishments and hide their failures?

  2. Dynamics in programming languages by jurt1235 · · Score: 5, Insightful

    It is interesting to see how an abstract language like a programming language evolves through time. I would think that in a language like C++ the more userfriendlyness should be in the libraries and not in the language, so I agree with the author on this point. Putting it in the libraries makes it better backwards compatible, and distributable.

    --

    My wife's sketchblog Blob[p]: Gastrono-me
    1. Re:Dynamics in programming languages by orthogonal · · Score: 5, Informative

      It is interesting to see how an abstract language like a programming language evolves through time

      If you find that interesting, you're going to love Stroustrup's The Design and Evolution of C++.

      It's an almost novelistic discussion of how he made C in to C++, the various trade-offs required, and how he decided what changes to make or not make. For example, why the dot operator (".") can't be overloaded, but the parentheses can be, and why (contra Goslings Java) operator overloading is a good thing (short answer: it makes syntax match semantics).

      If you ever want, or need, to develop a large-scale, flexible and general system of anything (and what's more general than C++, a programming language used by millions to write both Object Oriented and just "better C" code?), D&E is a wealth of experience, carefully and fully explained.

      And, like a novel, it's for the most part a fun read. Grab a copy, and you'll not only understand C++ better, you'll understand why C++ is what it is, and how it got there from C.

  3. a 'few' rough edges by leomekenkamp · · Score: 4, Insightful

    Shaving off a 'few' rough edges to make it more easy for newbies... It's that what Sun tried to do? (hint: java)

    --
    Wenn ist das Nunstueck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput.
    1. Re:a 'few' rough edges by lbmouse · · Score: 2, Funny

      ... or MS tried to do? (hint: C#)

    2. Re:a 'few' rough edges by /ASCII · · Score: 5, Informative
      If you would read the actual article, you would see that the edges Stroustroup talks about are little warts like :

      • whitespace sensitvity in templates, i.e. vector> is a syntax error, since >> is a single token.
      • Type declarating iterator variables can be a huge pain when using STL since the names are so long, i.e. the type 'vector >::const_iterator' is a bit of a mouthfull. Such variables can be guessed from the return type, so you could use a type 'auto' for this.


      Java does not remove a few warts from C++, it forces you to use a Garbage collector, OO design, type introspection, etc, etc. Those are pretty fundamental changes.
      --
      Try out fish, the friendly interactive shell.
    3. Re:a 'few' rough edges by leomekenkamp · · Score: 4, Insightful

      Yes, I know these are fundamental changes, that's why I put the word 'few' in between quotes.

      Point of fact stays however: c++ has an enormous learning curve. Complexity in the language is imho comparable to Latin: you can almost recognise the author by lookin at the code. That complexity is far, far less in java.

      Especially the gc makes life a lot easier for even seasoned programmers.

      And by the way: you can be almost as un-OO in java as you can be in c++. Introspection in java is mostly used in 'frameworks', like for instance the serialization API; normally you almost never use it.

      --
      Wenn ist das Nunstueck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput.
    4. Re:a 'few' rough edges by Da+Fokka · · Score: 4, Interesting

      ... or MS tried to do? (hint: C#)

      So tell me, what really is wrong with C#?

    5. Re:a 'few' rough edges by orthogonal · · Score: 4, Insightful

      Shaving off a 'few' rough edges to make it more easy for newbies... It's that what Sun tried to do? (hint: java)

      Java's ok, but a few mistakes were made. Among the worst: over-reliance on the instanceof operator, and the need for something called a MethodNotSupported exception.

      Now think about what MethodNotSupported means in the context of Barbara Liskov's Substitution Principle:

      We've got a language that supports inheritance. Inheritance makes sense only insofar as Liskov's Principle is followed. Put simply, if class D inherits from class B, any "promises" that B made -- it's interface, both syntactically, in terms of public member names, and semantically, that the member functions really do do some particular thing -- any of those promises must also be kept by D, because we are saying, as Liskov tells us, that D is-a B.

      If I hand you an instance of D, and you plug it in place of am instance of B, anything that the B instance does, the D instance must at least do. Otherwise, how can you safely and with confidence substitute a the D in where the B used to be?

      But along comes Java, and the MethodNotSupported exception -- a method used by some of Java's core library, including, dismayingly enough, commonly used container classes. It's used so that a derived class can suddenly and at run-time throw it, telling you, "Whoops! Ha ha! Trickled you, I can't in fact really do what B promises! I claim I'm a B, but really, I'm not!"

      Now imagine you had a component stereo, and you replaced your tuner with a "better" tuner with all the same jacks as the original. You'd plug it in and expect it to do the same work as the original tuner, just with better reception or fidelity or whatever. Now what if you plugged in the new tuner to the old connections, and suddenly its display read: "Sure, I have a two-plug RCA input, but it's not actually connected to anything, so you can plug in an RCA jack but no sound will come out". That's what having a method that throws MethodNotSupport is like: the jack -- or member function name -- is there, but the implementation is not.

      D inherits ("extends") B, it says so right there on the label, but no sound comes out. With Liskov undermined, you don't really have an object oriented language at all. You don't really have true inheritance. What you have is a sham, a sham that can break down on you at run-time because an object is lying to you.

      And the upshot is that you don't see enough real object oriented programming by client Java coders. If the core library can get it that wrong, why should clients of that library bother to adhere to a standard?

      So you get lots of java code that does RTTI using instanceof and if( p instanceof Foo ) ... else if( p instanceof Bar ) ladders rather than calling p.virtualFunction(). Because coders won't take seriously OO that the language and its core libraries don't take seriously.

    6. Re:a 'few' rough edges by /ASCII · · Score: 2, Informative
      Two important points here:
      • There are lots of GCs for C++. They are not part of the language, they are implemented as libraries. Hopefully, a future version of the C++ standard will have a GC in the standard library. But never as a part of the language.
      • The point about introspection in Java is that it _always_ costs you in performance and memory/disc use. Even if you're not using it.
      --
      Try out fish, the friendly interactive shell.
    7. Re:a 'few' rough edges by Deadbolt · · Score: 4, Interesting

      So the language is responsible for the perversions that retarded coders put it through?

      If you use instanceof more than once every, say, 10000 lines of code, I will fight you. That's no lie. It's a sop, and we, the loyal Java programmers of the world, know it's a sop. People who don't know what they're doing can turn it into a crutch. But those of us who DO know what we're doing know that using instanceof should be an automatic hint to rethink the design.

      As for MethodNotSupportedException -- yes, it's kind of a hack. But the thing is, perfect designs don't translate to reality very well, and Java, for all its good points, isn't perfect. That exception lets you know when you're breaking an API contract -- though a List may have add() methods, if you want that List to be immutable, is it preferable to throw an exception from a mutator or remove the mutator from the subclass completely? Or should we just take add() out of the List interface? Point is, it's a hack, but it's a lot better than the alternatives. And what it DOES do very well is say, "Look, genius, you're saying two different things about this object. Figure out what you mean and then say it."

      I could read stupid C++/D/C/Ruby/whatever code and then blame the language too, you know.

      --
      "Honey, it's not working out; I think we should make our relationship open-source."
    8. Re:a 'few' rough edges by orthogonal · · Score: 3, Insightful

      "That exception lets you know when you're breaking an API contract -- though a List may have add() methods, if you want that List to be immutable, is it preferable to throw an exception from a mutator or remove the mutator from the subclass completely? Or should we just take add() out of the List interface?"

      If those are the motivations, we should have an ImmutableList class without an add function, and derive the List with an add function from it (in C++, probably by private inheritance, that is, inheritance of implementation). Only the List class with the (working) add should publically inherit from the interface with an add function.

      Problem solved.

      "I could read stupid C++/D/C/Ruby/whatever code and then blame the language too, you know."

      Sure, sure. Don't be touchy. I code Java too, in fact I'm Sun Certified.

      What I'm saying is, you tell me you'd "fight" unnecessary uses of instanceof, and I believe you. I'm just trying to make your fight easier. The point is, if your core libraries don't take liberties, your fellow client coders will be less likely to -- or at least less likely to use the bad example ("but the core library does it, why can't I?") when a good java programmer, like you, points out the problem.

    9. Re:a 'few' rough edges by 0xABADC0DA · · Score: 2, Informative

      Java does not remove a few warts from C++, it forces you to use a Garbage collector, OO design, type introspection, etc, etc. Those are pretty fundamental changes.

      What, like it can't do both? The problem with C++ is that is was built with focus purely on technology and seemingly without any effort to human factors at all. I mean come on, "::" to separate class from method name, pure virtual destructors, separate interface and implementation files, can't nest templates because >> is a token, references *and* pointers, no garbage collector (even optional)? If there had been any thought into human factors whoever came up with these would be burned at the stake.

      Java does enforce using a GC, and encourages OO design, and makes C into a safe language (no pointer math and no invalid casts), but that is not why it has been so successful.

      The #1 thing it does is make the code do what is says... you can look at Java code and see exactly what is going on with no ambiguity at all. You might not know what some method does, but you know when it's called; with operator overloading it is impossible to know what a C++ code is doing (ie, cin >> s, shift right or method call?).

      The #2 thing Java does is have a large, consistent library. People can glance at pretty much any Java code and know a lot about the methods being called do since they are to the standard library.

      The #3 thing it does is to remove all of the syntax crap of C++. The syntax in C is somewhat functional and makes some sense (except function pointers). It's clearly something people can stand, and Java adds nothing to this and even removes the -> vs . ambiguity.

      Those are the reasons why Java is so successful, not because it forces OO, GC, safety, etc on the programmer. In fact in a lot of areas those are the things slowing its growth.

    10. Re:a 'few' rough edges by SerpentMage · · Score: 2, Insightful

      Yes it forces you to do all of the things that make you productive.

      Now getting back to C++, you are not forced to do anything except write code like the following:

      T & list::iterator::operator* () const
      {
      return current->data;
      }

      Yeah I suppose this is obvious, and simple! (NOT)

      I completely gave up on C++ about six months ago. Before that I was half in and half out. Having read BS's article I have to say I am glad I gave up on C++.

      I have talked to multiple people who regularly develop using Python, C#, Java, etc and they hate the fact you have so many little details in C++. If you look at my little C++ example look how many details a coder is supposed to take care of. It is insane!

      Oddly enough, people still like C. I suppose it is a simple and effective language to get low level coding done.

      --

      "You can't make a race horse of a pig"
      "No," said Samuel, "but you can make very fast pig"
    11. Re:a 'few' rough edges by Dewb · · Score: 2, Informative

      If those are the motivations, we should have an ImmutableList class without an add function, and derive the List with an add function from it (in C++, probably by private inheritance, that is, inheritance of implementation). Only the List class with the (working) add should publically inherit from the interface with an add function.

      Just in case anyone's curious, this is the way the NS* container classes in Objective C work. NSArray is immutable, but the derived class NSMutableArray has add/remove methods, etc.

      I personally prefer supporting both in one interface using 'const' in C++, but this approach does make a bit of sense (once you get over the "Why doesn't NSArray have any mutator methods?! reaction.)

    12. Re:a 'few' rough edges by Chris+Burke · · Score: 2, Interesting

      The template closing thing is an obvious, minor change.

      I'm not so sure about 'auto'. Just from the article, which admittedly is not supposed to be a list of features going into the new standard, I can't help but see problems. e.g.:

      auto my_thing = [complex stl expression];

      [some other complex expression](my_thing);

      and getting some horrible STL error on the second expression because the type of the first expression wasn't what you expected and now you have to figure out what it actually was and how to force it to be what you thought it was going to be. In other words, it's the same nasty STL template debugging you have to do today, only with another level of hidden indirection in the type of a variable, which is at least something I don't really have to worry about today.

      On the other hand, I do really like the idea of "concepts" where you specify what "concept" a template expects and the type you give can be verified to be the correct concept. As it stands right now, you don't know that a given type won't work in a given template until the compiler compiles a template function that requires a method your class doesn't support which may not even happen until after you've been using the template and class combination for a while. This sounds a bit like Java interfaces, but without the requirement that your class derive from the interface. You just have to provide what the concept expects.

      This beats the hell out of the current situation where the "concept" a template requires is implied by its implementation. The implication that this might simplify template error messages would be icing on the cake.

      --

      The enemies of Democracy are
    13. Re:a 'few' rough edges by orthogonal · · Score: 3, Interesting

      "Okay, I'll buy that. However, nothing prevents you from creating your own ImmutableList wrapper around a List instance and not exposing any mutators."

      Sure. No argument from me on that. Nothing prevents me from creating my own class that doesn't throw NoSuchMethod.

      But the whole point of libraries, you'll agree, is to save the client programmer from having to roll his own, design his own, test his own, code his own -- and then make it interoperate with your code or his code.

      And it's his code (not yours, not mine) where the problem sneaks in. (It's always his code, not mine. ;) )

      Say I'm using Joe's Nifty Library O' Functions. Joe, being a good programmer, doesn't try to roll his own container code -- he knows that no one wants to read up on how his JoeArray or JoeInterator or JoeList are different from the standard, so Joe -- and he's right to do this -- uses standard Java core library classes.

      So far so good. But to be good, Joe has to use java.util.List. That's actually an interface, so Joe uses List as his public contract and java.util.ArrayList as the actual implementing class. He uses it as a public member of Joe's Own Nifty Widget with Lots O' Features.

      Now you use Joe's library in your code, and you routinely use Widget.getObserverList() like this: myWidget.getObserverList().add( myCallback ) and all is well.

      But at some point Joe adds Lenny's Luscious Library to his own code, because it adds all sorts of new functionality to Joe's stuff. But Lenny's library requires that Jow use Lenny's List class. It also implements the java.util.List interface, so Joe -- rather than copy stuff back and forth between lists, just replaces the ArrayList with a LennyList. Joe's code still works, and he releases Joe's Library 2.0.

      You upgrade to Joe 2.0, to take advantage of all the new functionality he's added -- in fact, your 2.0 release leverages and relies on lots of the new functionality in Joe's library, and there's no way you could roll your own version in time to meet your client's deadline. And the compiler never complains about your upgrade, because all the interfaces are right, no method calls are made to functions that don't exist.

      But at runtime, your code fails. Because Lenny's List has an add function, but never implements beyond throwing an exception. Incredibly enough, Lenny's List is a special proxy listinstanceof too often, they'll just say "see, I told you, object oriented code and using exceptions just ain't reliable."

      Of course, the problem is that in using NoSuchMethod, Java isn't actually being object oriented, but after the code throws, try explaining that to the converted C programmers doing java. (Again, not you, not anyone who has read this far -- but we all know and have worked with someone like this, no?)

      Now of course, these sort of problems won't arise on small projects. But they'll inevitably arise when your JSP library is calling your Java App server's code which is calling, via RMI, your Distributed Business Object which is calling, via JSQL either an Oracle database (for your domestic operations) or a Sybase database (for the European subsidiary).

    14. Re:a 'few' rough edges by dustmite · · Score: 2, Informative

      C# is not standard. Yes I know there is a standard specification, but it's not an "industry standard" in that it's not supported widely. E.g. can I simply compile my C# applications on OS X in Xcode, or on Linux, even if I have used cross-platform libraries like wxWidgets? As an ISV, choosing C# would mean a choice to deliberately limit the available platforms we could run our software on. This doesn't make sense at a time when libs like wxWidgets make it easy to develop decent cross-platform software - there is little advantage to deliberately unnecessarily limiting yourself like that. This makes C# useless for many applications regardless of whether or not it is a good language technically --- it just doesn't have critical mass.

      But why doesn't it? Because C# just doesn't offer enough value over and above existing languages to attract significant numbers of new developers - it tries to solve problems that mostly had already been solved already elsewhere, and frankly there was really no point in introducing yet another new language at a time when there were already hundreds of decent languages in widespread use for all sorts of purposes. To make people want to use something new it has to be more than just "good". It has to offer something that really makes people want to switch, especially as there are retraining costs involved in switching to a different language.

    15. Re:a 'few' rough edges by renehollan · · Score: 2, Insightful
      Boy, that sounds like a slooow way to replace a lookup table. Programmatically it may be more elegant, but certainly not equivalent speed-wise, which is the real purpose of a lookup table.

      You appear to miss the point. It may very well be slow, and probably is, but it is slow at compile time, and generates the fast table for you to use at run time.

      In practice, I've written some knarly templates, and have not found the compile speed to be all that bad.

      --
      You could've hired me.
  4. I'm curious ... by The+Mgt · · Score: 4, Funny

    .. as to the pronunciation of 'C++0x'. Any suggestions ?

    1. Re:I'm curious ... by strongmace · · Score: 5, Funny

      See Plus Plus Ox

      ...or you could just shorten it by taking out the plus plus and having C0x which is obviously pronounced cocks

      --
      "If we hit that bullseye, the rest of the dominos will fall like a house of cards. Checkmate." -Zapp Brannigan
    2. Re:I'm curious ... by sbb · · Score: 2, Funny

      C++ heXtreme!

    3. Re:I'm curious ... by Trailer+Park+Boy · · Score: 5, Informative

      That's 0x as in 05 as in 2005. So C++05 or C++06.

    4. Re:I'm curious ... by iabervon · · Score: 4, Funny

      But C0x is an entirely different language (the development version of the successor to C99). If you want to make it easier to say, arrange it as C0x++, which is obviously pronounced "spam".

  5. Is threading going to be abstraced out ? by Gopal.V · · Score: 3, Insightful

    Stuff that went into Boost should be in the standard library from now on... Also anyone who has had to use g++filt will agree with me that C++ STL error messages need to look less like the dog's breakfast :)

    1. Re:Is threading going to be abstraced out ? by jmccay · · Score: 2, Informative

      Actually, what I was looking for (and had escaped my mind) was one of the following:

      Library Extensions Technical Report 1

      or

      Library TR1

      I knew TR stood for technical report. I have seen both of these refered to when introducing TR1 in articles--primarily in C/C++ Users Journal.
      While I am mentioning it. You can download an older draft (January 2005) of TR1 here, and Scott Meyers has updated his page with information mapping items in TR1 to Effective C++ ( which is a must read for all C++ programmers).

      --
      At the next eco-hypocrisy-meeting, count the private jets used to get to the meeting. Should be interesting to see that
  6. Dogma by roman_mir · · Score: 2, Interesting

    but that the language needs to shave of a few rough corners to make it easier to use for novices. - that is probably true. Analogy:

    GLICK
    Exactly! And that's what we're looking to do -
    shake these people up a bit, get them motivated.
    That's the whole point of the campaign. Mass
    attendance is at an all-time low in this country.
    And it's not like we're losing them to the
    Protestants or Baptists - people aren't practicing
    at any denomination these days. If we can sell
    them some show - let 'em know the Catholic church
    has some panache, we can win them back - even get
    some new ones. Fill them pews, people - that's the
    key. And cross-promoting - like with the cereal
    tie-in grabs the little ones as well. Hook 'em
    while they're young.
    (sits at his desk, lights smoke)

    RUFUS
    Kind of like the tobacco industry?

    GLICK
    Oh - if only we had their numbers. But we are
    aiming for the same demographic, even though mine
    is the soul-saving biz. And if I have to play a
    bit of the devil to bring them closer to the Lord,
    then I'll wear the cloven hooves and carry the
    pitch fork.


    -
    Today the battle is between Java and C++ and Java wins. Not because it's faster, because it is more convenient.

    What C++ could use from Java? Why, an option to have garbage collection for starters. Just an option, not a requirement.

    1. Re:Dogma by Misroi · · Score: 2, Insightful

      C++ is just fine the way it is. If you want a language like java, go with c#.net

      and you can also code c++.net, which has the option to use the .net framework and the .net garbage collector.

      my personal opinion is c++ should stay exactly like it is. The more libraries the better. if you want some high level language, use c#.net. If you want a headache go with c++.net.

    2. Re:Dogma by orthogonal · · Score: 5, Funny

      "I sometimes find distributing an extra 30 MB [the .net run-time] a bit inconvenient."

      Please download my new folding bicycle! Its lightweight aluminum frame means it's easily portable and rugged too! when not biking, fold it up and carry it under your arm like a briefcase! The perfect form of personal transportation!*

      * Note: lightweight bicycle application is powered by a Soviet-era nuclear submarine, a separate download.

    3. Re:Dogma by Deviant+Q · · Score: 2, Insightful
      Today the battle is between Java and C++ and Java wins. Not because it's faster, because it is more convenient.

      Actually, I'd urge anyone who thinks this is the case to consider C#. Yes, I know it's Microsoft, and yes, I know there's .NET involved, but...

      I just love that language. It's a pleasure to code in; it fixes everything (IMO) that Java did wrong; it's very powerful and intuitive at the same time; the .NET framework class library is absolutely wonderful... I could go on and on. It's just awesome.

      The only thing that pissed me off about it was the lack of templates, which (just like in Java) gives you some crazy boxing/unboxing issues like int i = (int)myArrayList[0];, but with templates ("generics") in 2.0 that's all fixed. It's beautiful.

      --
      "May the days be aimless. Let the seasons drift. Do not advance the action according to a plan."
  7. A better wheel by Anonymous Coward · · Score: 5, Insightful

    Am I the only one who wonders why we need a successor to C or C++?

    I've sat through the past 10 years and watched things like Java and D and Objective C come, but meanwhile most serious OS level and game development continues to be in C or C++. Doesn't this demonstrate that new language are merely a distraction to developers who haven't fully exploited the current set?

    1. Re:A better wheel by Radres · · Score: 3, Interesting

      Because sometimes you want to write something quickly without having to worry about managing memory, pointers, etc. If you're writing an application where every clock cycle counts, then yes, use C or C++, but in most cases you can get away with a little bit more CPU usage with the benefit of code maintainability. I suppose if you really had a section of code where minimal CPU usage was important, you could write that in C++ and import it into Java as a native interface library.

    2. Re:A better wheel by onnel · · Score: 5, Insightful

      No, it's more a signifier that different problems need different solutions. If all you have is a hammer, everything may look like a nail, but if you know c++, perl, php, java and a few others, your toolbox will contain an appropriate solution for a broad range of problems. I write my games in c++, my websites in php and my text parsing utilities in php. Java and python also serve their niches. Anyone who believes that a single language is the best solution to all of the broad range of problems faced by programmers is sorely mistaken. Onnel

      --

    3. Re:A better wheel by roard · · Score: 4, Informative
      Objective-C was created in 1983 by Brad Cox, then used on NeXT, so it's not exactly something that came in the last ten year ;-)

      And actually drivers on the NeXT were written in Objective-C ;-)

      Anyway, it's all a problem of using the right tool for the right job. Objective-C is excellent (particularly with AppKit + InterfaceBuilder on OSX, or with GNUstep+Gorm) for creating graphical applications.

      If you need a very optimized code, you can do it in C, or C++... and still keep the rest of the app in Objective-C, as Objective-C is just a superset of C, and the Objective-C++ thingy let you mix C++ code an ObjC code in the same place...

      But as they say, early optimisation is the root of all evils :-) which is why most of the time you're much better off with a high-level dynamic language than with a low level or static language. My opinion.

    4. Re:A better wheel by Zerbs · · Score: 2, Interesting

      We don't need a successor to C or C++, Delphi's use of Object Pascal provides all the functionality, speed, and a slick IDE, without the awkward pains of C flavored languages and without the hastles of interpreted or pseudo-compiled languages like Java or C#.

      --
      "22 astronauts were born in Ohio. What is it about your state that makes people want to flee the Earth?" Stephen Colbert
  8. C++0x? by rerunn · · Score: 2, Funny


    Perfect opportunity to come up with a decent name but nope, geekiness prevails and the best he can do is: C++0x

    1. Re:C++0x? by /ASCII · · Score: 2, Informative

      Hmmm, the C standard are called C90 and C99. C++ follows this pattern as well with C++98, and the current C++0x, which on release will be renamed C++06 +- 1. Neat, consistent and predictable. Only6 you think it's geeky. Are you a marketer by any chance? ;-)

      --
      Try out fish, the friendly interactive shell.
  9. Names by DNS-and-BIND · · Score: 2, Informative
    Jeez, can they make these names any more obtuse? As if C++ wasn't confusing enough for people not in the know, C++0x? I mean, little in-jokes are fun, but put them in code comments, not in the title.

    And I hate PDFs...if it had spiffy charts or images or something, it would be great...but it's just text! Opened it, saved as HTML and it was 78k.

    --
    Shutting down free speech with violence isn't fighting fascism. It IS fascism!
  10. Yeah about that standard library... by hey · · Score: 4, Interesting

    ... its embarasing. Compare it to CPAN (perl) or Java. It can't do very much. I wish they could get some real functionality in there. Adding the Boost stuff is nice but. What some something like Java's SWT where you can write an entire GUI using the standard library. Now that would be an improvement for C++.

    I would be very easy to do. Just "steal" the API spec's from Java. That's what C# did. Just recode the entire Java API into some C++ .h header files. Call it the standard and let vendors code it out. Sweet!

    1. Re:Yeah about that standard library... by joshstaiger · · Score: 2, Informative

      SWT acomplishes this. It uses native widgets where possible, and does so in an intelligent fashion.

      Granted, this took much longer than it should have.

      It's regrettable that Sun's marketing hype over Swing et all has poisoned people's impression of Java desktop GUIs, but with SWT we finally have a good framework...honest.

      Try downloading Eclipse (written using SWT) to see for yourself.

    2. Re:Yeah about that standard library... by elflord · · Score: 2, Informative
      Compare it to CPAN (perl) or Java. It can't do very much.

      The aim of the standard library is not to "do as much as possible". The problem with canonizing a library in the standard, is that once it's there, you have a huge amount of code that depends on it, so you're stuck with it.

      As for CPAN, last I checked, nothing in CPAN (or indeed perl!) was part of any formal standard in the same sense as the C++ library. CPAN is a collection of contributed libraries for Perl. There are also an enormous number of third party libraries for C++.

      The bottom line is that putting a particular library in the standard gives it a sort of canonization/elevation that is probably not desirable as far as GUI libraries is concerned. I doubt it would be possible to get everyone to agree on a single true C++ GUI library, and neither should they.

    3. Re:Yeah about that standard library... by MobyDisk · · Score: 2, Insightful
      You are frustrated because you misunderstand the definition of a programming langauge. Programming languages don't provide APIs. Let me quote from the Wikipedia:
      A programming language...is a standardized communication technique for expressing instructions to a computer. It is a set of syntactic and semantic rules...to precisely specify what data a computer will act upon, how these data will be stored/transmitted, and precisely what actions to take under various circumstances.
      This definition does not include GUIs, graphics, or sound, or networking, or even file I/O. A language is used to describe allocating memory, and performing if/then/else logic, and describing data structures. Some examples of programming languages are: C, C++, Fortran, LISP, COBOL, TCL, Prolog, and shell scripts. Java is only a programming language if you remove the libraries.

      What you are looking for is often called a platform. The Java platform ships with the Java language + a series of libraries that give you graphics and sound and networking.

      If you treat C++ as a platform, you will be forever frustrated. If you are looking for a platform based on C++, I recommend C++ + POSIX + GTK. Most of the time I use C++ + Win32 as my platform. Try this, and you will be far less frustrated.

      Oh, and just to make it clearer: If you want, you can use C++ + AWT or C++ + Swing if you want. The Java APIs are fully callable from C/C++. I don't recommend it because it defeats the purpose of using an low-level language like C++ if you then include a big virtual machine, but if you like the Java APIs, you can do it.

  11. C++0x? D! by pdbaby · · Score: 4, Interesting

    Why do we need this? D is a beautiful, well-appointed systems programming language. It's got a gcc front-end. It's got garbage-collection if you want, custom memory management if you want. It's got embedded assembly if you want. And it's fast

    I thought we were staying with C++ because of all the code that's already written in it...

    --
    Global symbol "$deity" requires explicit package name at line 2. - If only $scripture started "use strict;"
    1. Re:C++0x? D! by WalterBright · · Score: 2, Informative

      Actually, it is free. GDC is the gnu version of the compiler, completely GPL.

    2. Re:C++0x? D! by jma05 · · Score: 2, Insightful

      There are a LOT of things better in D than C++. D is far better language (not library) enhancement over C++ than Java/C#. Take a look at language comparison at http://www.digitalmars.com/d/index.html I do not use D however. I don't do much of systems programming and I fancy IDEs but language wise, D is perhaps the best imperative, native compiling language out there at the moment.

  12. Too little too late? by leandrod · · Score: 2, Interesting

    I still remember the 'C++ Advisor' or something the like from Unix Magazine or a similar publication who wrote his last column giving up on the language because only a language lawyer could keep up on the accretions to it. I don't remember what the guy went for, but if one is into OO C derivatives you have C# with its integrated, extensible type system from the DBMS up to other languages. Or Java, if you don't want to be torpedoed by MS' 'IP'. C++ should have been fixed a long time ago, but then AT&T wouldn't have suffered from NIHS and we'd be all using ObjC and OpenStep.

    --
    Leandro Guimarães Faria Corcete DUTRA
    DA, DBA, SysAdmin, Data Modeller
    GNU Project, Debian GNU/Lin
  13. hiding implementation of templates? how? by KnightTristan · · Score: 2, Interesting

    I really wonder how they're gonna do that. I know some compilers have tried that in the past, with some export template thingy stuff. Templates where instantiated at link time. However, AFAIK, that never really worked.

    Tristan

  14. What we need is "Smoothed out" people... by brockbr · · Score: 5, Insightful

    Every time a cost of entry is reduced and the expected prerequisites are thrown aside, the result is a truly less capable *person*, not a more capable tool.

    Agreed - There are some things that need smoothing, but I for one am tired of dealing with people who lack a fundamental understanding of the *systems* as a whole. Examples of this are the folks coming out with CS degrees who aren't even capable of following a thought, let alone starting an actual career designing and developing software.

    For them, a tool like Java offers an entry level that is acceptable given there current capabilities - A tool geared towards THAT user (and a fine one at that).

    But C (and C++) can be leveraged by people who know the tool and *use* the tool for what it can do, even with it's high(er, intellectually) cost of entry.

  15. Expected release date by thammoud · · Score: 2, Insightful

    2020. Good luck getting all the stuff in. Long live open standards.

  16. Re:The future of C++... by th0mas.sixbit.org · · Score: 2, Funny

    ... posts the AC as he thinks to himself, "VB roolz".

    --
    twitter.com/gravitronic
  17. Features I want... by BAILOPAN · · Score: 5, Interesting

    I program in C++ from dawn to dusk, and a few things really irk me about it:

    1. Member function pointers. Implementation dependent and messy syntax that few people even know about. Their use is limited, and they don't support delegates like C#, making them ugly to work with.

    2. The "virtual =0" syntax instead of something nice like "abstract" or "interface" is just weird. How can you set a prototype equal to 0? What's wrong with nice words?

    3. Operator new and delete were designed by someone on crack. The only way to call a constructor is with placement new, whose syntax looks like: new (var) type(). Placement delete, however, doesn't call the destructor, which must be invoked manually. Furthermore, delete can't take parameters like new. What.

    4. There is a "typeid" operator but no "typeof" operator. GCC has an extension for this, but it's not standard C++ I think.

    I'm sure there are other language constructs that have annoyed me, and if you don't read my mind and fix them, Bjarne, I will kick you in the pants!

    --
    If you say "here goes my karma" I will bite you!!!
    1. Re:Features I want... by jonastullus · · Score: 3, Informative

      1. Member function pointers. Implementation dependent and messy syntax that few people even know about. Their use is limited, and they don't support delegates like C#, making them ugly to work with.

      exactly, and

      std::for_each(content.begin(), content.end(),
      std::bind1st(std::mem_fun(&PointVisitor::operator( )), v));

      is neither typable nor easy to read AT ALL! plus, it makes my head ache!

    2. Re:Features I want... by CrayzyJ · · Score: 4, Interesting

      > There is a "typeid" operator but no "typeof" operator.

      According to "Effective C++" - Meyers, if you need to know the type of a class, you designed your classes wrong. Take advantage of abstract classes and coercion for this.

      --
      Holy s-, it's Jesus!
    3. Re:Features I want... by Anonymous Coward · · Score: 3, Interesting

      I don't know you bro, but care to elaborate on delete not calling destructor. That's kind of new thing to me after 10 years as C++ coder.

      And the syntax of new and delete is awesome and I like it very much. I don't have time to chat and explain why I mean it is(and suits language well) but it is-trust me on this one. And that delete operator doesn't take arguments, man thats as easy to do the other way as - I mean plain easy.

      and yes there is a proposal for typeof

    4. Re:Features I want... by neil.pearce · · Score: 4, Interesting

      The "virtual =0" syntax instead of something nice like "abstract" or "interface" is just weird. How can you set a prototype equal to 0? What's wrong with nice words?

      The man himself, in "The Design and Evolution of C++" states...

      The curious =0 syntax was chosen over the obvious alternative of introducing a keyword "pure" or "abstract" because at the the I saw no chance of getting a new keyword accepted.
      Had I suggested "pure", Release 2.0 would have shipped without abstract classes. Given a choice between a nicer syntax and abstract classes, I chose abstract classes. Rather than risking delay and incurring the certain fights over "pure", I used the traditional C and C++ convention of using 0 to represent "not there". The =0 syntax fits with my view that a function body is the initializer for a function and also with the (simplistic, but usually adequate) view of the set of virtual functions being implemented as a vector of function pointers. In fact, =0 is not best implemented by putting a 0 in the vtbl. My implementation places a pointer to a function called __pure_virtual_called in the vtbl; this function can then be defined to give a reasonable run-time error.

    5. Re:Features I want... by Anonymous Coward · · Score: 5, Informative
      1. Member function pointers. Implementation dependent and messy syntax that few people even know about. Their use is limited, and they don't support delegates like C#, making them ugly to work with.

      False. Member function pointers are standardized and not implementation dependent. They do have a syntax that is unusual, however. It's unreasonable to expect C++ to support delegates "like C#" considering that C# was designed long after C++.

      2. The "virtual =0" syntax instead of something nice like "abstract" or "interface" is just weird. How can you set a prototype equal to 0? What's wrong with nice words?

      There is hesitation to introduce keywords, for fear of breaking backwards compatibility. If you program in C++ from dawn to dusk, the =0 notation should be perfectly normal to you, and not a problem in the slightest. They could have made it more descriptive, but it's certainly not a showstopper, and no C++ programmers I know even notice it anymore, as it is just a part of how things are done. Maybe it's a problem for newbies, but you're only a newbie for a short time.

      3. Operator new and delete were designed by someone on crack. The only way to call a constructor is with placement new, whose syntax looks like: new (var) type(). Placement delete, however, doesn't call the destructor, which must be invoked manually. Furthermore, delete can't take parameters like new. What. You cannot call constructors, PERIOD. Placement new is not invoking a constructor, it's evaluating a "new expression" using an allocator function that returns the address it is given, and a SIDE EFFECT of that is the invocation of the constructor. It's simply impossible to directly call a constructor in C++.

      As for "placement delete", I think you lack understanding. Users are not supposed to invoke placement delete, they are supposed to just invoke the destructor for objects created with placement new. Placement delete is only used to cleanup the memory when an exception causes the constructor to fail. And, as an obviously competant C++ programmer, you should know that if the constructor exits with an exception, the destructor is NOT invoked because the object wasn't constructed and therefore doesn't really exist. Operator new and delete are about MEMORY MANAGEMENT and not object lifetime issues. Constructor and destructors are about that. A "new expression" makes use of operator new and also invokes a constructor. You seem to have confused the "new expression" for operator new.

      4. There is a "typeid" operator but no "typeof" operator. GCC has an extension for this, but it's not standard C++ I think.

      You're correct, and you may find that we're trying to address this topic in C++0X. If you're interested, see http://www.open-std.org/jtc1/sc22/wg21/docs/papers /2004/n1737.pdf

    6. Re:Features I want... by XNormal · · Score: 4, Informative

      1. Member function pointers. Implementation dependent and messy syntax that few people even know about. Their use is limited, and they don't support delegates like C#, making them ugly to work with.

      For a full description of just how utterly brain damaged C++ member functions really are check thisarticle.

      Riddle: What's the size of a method pointer?

      1. 4 bytes
      2. 8 bytes
      3. 12 bytes
      4. 16 bytes
      5. 20 bytes
      6. all of the above

      The correct answer is 6. It can be any of these sizes depending on the circumstances. And just imagine that with all of this mess method pointers STILL don't support something as elementary as delegates (bound method pointers) in a dependable and portable way.

      --
      Stop worrying about the risks of nuclear power and start worrying about the risks of not using nuclear power.
    7. Re:Features I want... by joss · · Score: 2, Interesting

      Great, please give me an example of how would you use this return type ?

      Foo f1(3);
      Foo *f;
      f = new Foo(2);

      Maybe a little more thought needs to go into your language suggestions.

      --
      http://rareformnewmedia.com/
    8. Re:Features I want... by Spy+der+Mann · · Score: 3, Interesting

      exactly, and

      std::for_each(content.begin(), content.end(),
      std::bind1st(std::mem_fun(&PointVisitor::operator( )), v));


      This is one of the reasons i love PHP so much:

      foreach($array as $item)
      {
      }

      I never use any for_each crap in C++. I just make sure all my arrays begin at index 0. Sure, it's risky at times, but definitely much more elegant than the half-baked C++ iterators.

  18. Blasphemy? by smittyoneeach · · Score: 4, Funny

    In no way. If you read the B.S. writings (and I recommend he favor the world with a middle initial) he is always concerned with teachability of a feature, which is pretty understandable when you consider he's an academic.
    Now, what an academic is doing having a successful programming language with real-world applications is another question...

    --
    Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
  19. Re:C++... always the ugly step-kid by jurt1235 · · Score: 2, Funny

    History of java according to IBM:
    Java is based on Smalltalk!, not on C++

    Can not help it, they tell this at the IBM java courses.

    --

    My wife's sketchblog Blob[p]: Gastrono-me
  20. Re:standards are nice by drstock · · Score: 3, Funny

    "Standards are nice, everybody should have their own" That quote always cracks me up.

    --
    My other comment is funny
  21. Watch out you don't get f'ed by MarkusQ · · Score: 3, Funny

    the language needs to shave of a few rough corners

    Yo nee t b carefu whe cuttin corner; i yo cu to fa yo ca reall "f" yoursel ove goo!

    --MarkusQ

  22. If you're confused too... by Henry+V+.009 · · Score: 2, Informative

    I read the article and was confused by some of the code examples.

    The '=' have been replaced by '-' signs. (In Acrobat 7 on Windows anyway.) The code makes a heck of a lot more sense once you realize this.

    1. Re:If you're confused too... by zonx+lebaam · · Score: 2, Funny

      A glimpse at the true power of operator overloading!

  23. Shave OFF a few rough corners by lbmouse · · Score: 2, Funny

    ...change the name from C++ to Coo

  24. *yeah* initializing std::vectors by jonastullus · · Score: 2, Interesting

    if that were to happen i'd *so* be exhilerated!

    not having a way to initialize a std::vector with some values has always been one minor annoyance for me when using the stl containers!

    and about that "expert" thing: it is not by chance that c++ has become an expert-oriented language! there are SO many hidden traps and arcane details to get wrong that one can't just use c++ with intermediate skills and hope not to be punished! even the most simple mistakes can (and will) lead to segmentation faults and memory corruption!
    i am not even saying that c++ is an evil language, but it sure as hell isn't newbie-friendly!

    1. Re:*yeah* initializing std::vectors by Uksi · · Score: 2, Informative
      Aside from the std::vector(n, initialValue) constructor, which fills the vector with n copies of the initialValue, you can use the boost::assign library. From the doc: "The purpose of this library is to make it easy to fill containers with data..."
      • A comma-separated list:
        vector<int> v;
        v += 1,2,3,4,5,6,7,8,9;
      • A parenthesis-separated list:
        map<string,int> m;
        insert( m )( "Bar", 1 )( "Foo", 2 );
      • Repeats:
        vector<int> v;
        v += 1,2,3,repeat(10,4),5,6,7,8,9;
        // v = [1,2,3,4,4,4,4,4,4,4,4,4,4,5,6,7,8,9]
      ..etc
    2. Re:*yeah* initializing std::vectors by maxwell+demon · · Score: 2, Interesting

      I never liked the comma-separated list method. The problem is that it doesn't work like it seems to work. Anyone "unsuspecting" who sees

      v += 1, 2, 3, 4, 5, 6, 7, 8, 9

      immediatly thinks

      v += (1, 2, 3, 4, 5, 6, 7, 8, 9)

      i.e. the list of those numbers is added to v. But don't try to type the second line! It will compile quite fine. But it will not do what you want, but rather only append 9 to the vector. However the "intuitiveness" of the method completely relies on that wrong intuition. The true mechanism at work isn't quite intuitive.

      BTW, I consider using operator+= for this purpose a bad idea, too.

      --
      The Tao of math: The numbers you can count are not the real numbers.
  25. A second wave for C++ by Uksi · · Score: 4, Interesting

    I won't argue the relative merits of C++ to other languages. For many organizations, switching from C++ (regardless of whether it would make things easier) is often not an option, and not considered as an option. I will also not argue whether that is bad.

    The fact is, there's a huge C++ user and code base out there, and if they are going to stick with C++, there's exciting stuff coming.

    I feel that C++ is having its second coming, primarily due to developments like the boost library and the Modern C++ Design book.

    For example, I've been using a combination of boost::function and boost::bind to make powerful, flexible callbacks like nobody's business. Finally, there's a function "pointer" that can work with both freestanding functions, member functions and function objects, and finally there's an easy way to delay calling functions and use closures, respectively. (Also see boost::lambda).

    Sure, almost all of this has been possible one way or the other (the flexible callback has been typically implemented via function ptr and void ptr argument, C-style), but it's very refreshing to actually have the code say what you mean: "I want to delay calling this function", or "this callback doesn't give a crap whether the function you're giving it is a member function or not".

    Then there are smart pointers, which have easier-to-follow, clearer semantics, and can be used in STL containers and such. No more using easy-to-shoot-yourself-in-foot auto_ptr. It's been possible to write large chunks of code that have multiple "new" statements, but have no "delete" statements, all while maintaining exact control over the memory allocation.

    Of course there's more... Maybe it's stuff that LISP/Scheme programmers have been using for ages, but the key difference is I can now apply tools in production commercial C++ code, during my everyday work. I no longer sit and say: "oh, crap, I could really use a closure here." I just do it.

    A big problem is that the new features require greater understanding of the language and thus better training of the run-of-the-mill C++ developer. Many C++ developers I encounter do not have the sufficient understanding of these tools, and of the language. We should strive to educate our fellow developers, ... For Great Code!

  26. Re:Why new languages: Why? by elflord · · Score: 2, Interesting
    I don't understand why languages that take someone like me hours and minutes to learn fully have to be changed will-nilly every ten to twenty years.

    I agree with you -- but if you read the article, you'll notice that Bjarne's point of view (and for that matter, the prevailing view in the community) is also consistent with yours. Basically, changes in the language are to be as minimal as possible. The changes that he proposes will not make life harder or more confusing. The "new C++" is going to be much the same as the old C++, but with a larger standard library.

    The place where more substantial changes will occur (in fact have already occurred in TR1) is in the library. Libraries do change, that's a basic fact of life. The C++ standard library is still much simpler than other standard libraries.

  27. Re:C++... always the ugly step-kid by jonastullus · · Score: 3, Informative

    C was never a "nice" langauge, it was ugly, had massive problems around memory allocations, and the old unallocated pointer problems. It had unmangled names, so everything was in a global scope.

    Then you had langauges like Smalltalk and Eiffel, elegant languages, simplicity, languages which gave control and power.


    i won't dispute that many languages allow much better (data and functional) abstraction than C. but C - in its simplicity as a more readable and slightly more type-safe assembly - had its merits. in C there are no hidden mechanism and you are always right on the bare metal of the machine. so for what it was written for (operating systems, drivers and low-level software) C is actually a veritable and suitable language; far from more abstract languages in its power of abstraction and lacking any kind of real type-safety, BUT it had its applications!

    c++ on the other hand takes the principles of C (medium/weak typing, ability to program close to the machine, lack of functional abstraction) and enhanced it by adding hidden mechanisms and arcane problems with values/references/pointers such as object slicing, double freeing, etc.

    therefore c++ is neither the bare-metal-language that C was nor is it a real abstraction language like smalltalk, eiffel, lisp, haskell, ...! it is a PITA to learn C++, because every time you think you got it, something else creeps up on you and leads to one of those beloved "segmentation faults". c++'s merit is, that it allows a seemless transition from the bare-metal-programming of C to the more abstract realms of genericity (via templates *argh*) and OO. but the cost of this wide spectrum is the impossibility to comprehend c++ in its entirety or even understand enough of it in order not to be clubbed to death by wild pointers and memory corruption.

    on its own, the necessity to think about copy-constructors and assignment-operators for EVERY class one writes is annoying. but together with virtual function calls not working in con/destructors, expressions of form

    Class instance();

    being interpreted as function declarations and by-default-implicit constructors can bring the aspiring beginner close to the edge sometimes.

  28. Syntactic candy. by mcc · · Score: 5, Insightful
    This is mere unnecessary conveniences. What exactly are they giving us here? Well, if I'm reading this right, "C++0x"* will give us:
    • Some cases where you can type ; where previously {} was necessary, saving as many as two keystrokes.
    • The lexer ambiguity where a<b<c>> and a<b<c> > meant entirely different things is fixed, saving as many as one keystroke.
    • EVEN MORE "free" constructors which may or may not work quite the way you wanted them to in practice.
    • More "fancy cast" operators, which sounds nice until you remember that if there's ever a time you find yourself using the C++ "fancy cast" operators, then there is a damn good chance that it's because you're doing something unwise enough it really would be a better idea to refactor the code to make the "fancy cast" unnecessary.
    ...in the meantime the fundamental issues with C++ remain not only unresolved, but unaddressed. The template system is still not a generics system, but an ugly cut & paste macro system which can incidentally be used for generics, with some caveats. The class system is still fundamentally brittle and unfriendly to simple things such as upgrading a DLL or determining at runtime if two objects are of the same type. The syntax is still a forest of features whose features interact in ways so crazy and unpredictable it approaches Perl in its chaos; references are still gimped; the distinctions in behavior and use between static and dynamic objects remain awkward and newbie-unfriendly. The features that people obviously desire to have in the language as demonstrated by their tendency to hack them in with third-party libraries (like BOOST) are-- they tell us-- a good thing, and they tell us we should continue to hack them in with libraries (like BOOST). That's nice. You know, that would be a lot easier though if we had a macro system** capable of anything smarter than blind code cut and paste-- or at least a macro system** fundamentally designed to be used for anything at all other than generics.

    Meanwhile, it appears if I'm reading this right that the most important differences in C++0x will be changes to the standard library. Great. The STL was defined how many years ago, and it's only just in the last few years that compliant implementations have become commonplace? How many decades will it be before the "C++0x" library changes have become common in a cross-platform compatible way?

    C++ is an extremely useful language, and making an update to C++ which changes as little as possible so as to follow some kind of "if it aint broken don't fix it" principle is an idea which makes a whole lot of sense. However it seems likely to me from reading this that C++0x will offer so little significant difference from C++ as to make itself simply redundant.

    * ("C++0x". Were they specifically trying to come up with a name less convenient than "C#"? Ah well, I guess we can call it "COX" or "cocks" for short.)
    ** "Template system"
    1. Re:Syntactic candy. by NFLFan · · Score: 2, Insightful
      # Some cases where you can type ; where previously {} was necessary, saving as many as two keystrokes. # The lexer ambiguity where a> and a > meant entirely different things is fixed, saving as many as one keystroke.
      I don't think it is about saving one from typing but preventing errors. An expierenced C++-er knows to avoid >> with templates but does a beginner? The error messages can be less than great with templates- so avoiding one is all the better. The error message that g++ now seems to give is helpful but so annoying saying something like "you used >> where you wanted > > ... [c++ template garble]."
      EVEN MORE "free" constructors which may or may not work quite the way you wanted them to in practice.
      That sounds like a very ignorant argument. I used this constructor but it does not do what I want it to, is it wrong?
      More "fancy cast" operators, which sounds nice until you remember that if there's ever a time you find yourself using the C++ "fancy cast" operators, then there is a damn good chance that it's because you're doing something unwise enough it really would be a better idea to refactor the code to make the "fancy cast" unnecessary.
      I assume the current fancy C++ cast operators you are talking about are static_cast and dynamic_cast. With the lack of multi-methods and it being an error to downcast an object c-style I think the need for static_cast and dynamic_cast are clear. The only good clue to maybe needing to refactor an hierarchy is when it is unsafe to use static_cast in place of dynamic_cast (when you know the type), times when you have virtual base classes and other goofy instances.
  29. How about a module system? by putko · · Score: 3, Insightful

    More powerful languages like ML, CAML and some Schemes have a module system. This allows the programmer to control the meaning of identifiers (e.g. what function they mean). E.g. what gets imported (and with what name), what gets exported.

    Often there is a separate notation for the modules -- it says what files contain the things, what's exported/imported etc.

    That's very useful for encapsulation.

    C++'s namespaces are a crappy attempt to get the benefits of a module system -- that's likely where he got the idea from.

    Hygienic macros would be a good step too.

    --
    http://www.thebricktestament.com/the_law/when_to_s tone_your_children/dt21_18a.html
    1. Re:How about a module system? by Xepo · · Score: 2, Informative

      You can really accomplish this with namespaces as they are currently.

      The using keyword isn't only used in using namespace std;. You can also say things like: using std::vector;. You can also make aliases to namespaces: namespace sp=boost::spirit; Separate things correctly with namespaces, and know how to use using and you'll already have this functionality.

  30. Re:C++... always the ugly step-kid by NDSalerno · · Score: 3, Insightful

    Here here! In the realm of native application development I have programmed in C++, Delphi, and Eiffel. Each language has its pros and cons. C++ is no doubt the most popular and most successful of the three. However, I have been most productive and had the most fun with Eiffel and Delphi. Some might be quick to say I am not experienced enough with C++ or that I haven't learned the idioms. I have programmed in C++ for many years. I have read all the books written by Stroustrup, Scott Myers, Herb Sutter, Andrei Alexandrescu, etc. I regularly read the newsgroups and paid attention to Sutter's Guru of the Week articles. With all that under my belt I still make mistakes. Why? In Eiffel and Delphi a statement of code can do one or two things. In C++ a statement of code can do several things, some of which incur side effects of their own. If you don't understand these behaviors then you write buggy code. Or, in other words, C++ is complex.

    The hardcore crowd will tell you that ultimately you are better off going with C++ because of speed and power (implying that every other is a step above Visual BASIC). NONSENSE! Delphi is on par with C++. In certain situations C++ is more efficient than Delphi. In other situations Delphi is more efficient than C++. In the long run they are both the same. The only thing Delphi can't do is metaprogamming. Big deal. I can write my number crunching algorithm in C++ templates and wrap it in a library that Dephi can call. Problem solved. You know what C++ can't do elegantly? GUI development. It's tortuous. C++ Builder doesn't count because the language is modified and is not ANSI C++, which should really tell you that there is truth in the statement that C++ lacks some features. Qt has always been my favorite ANSI compliant GUI library. However, even Qt is a testament to the needed addition to C++. The meta-object compiler?? As if my compile times weren't long enough?

    I have debated on the C++ newsgroups about accepting Borland's C++ extensions to the language, namely properties, closures, and reflection (advanced RTTI). I admit that boost does have a way to implement closures as template classes. They work and are efficient. My only dislike is that the syntax is too cumbersome. But I'll let that go. However, it has been argued and proven that properties CAN NOT be implemented as a class library without overhead. They simply must be a feature of the language. Combine that with better RTTI support (reflection capabilities) and you will have some powerful new tools to make elegant designs. And no, I am not advocating using RTTI for general development. Obviously if you have to test your base class pointer to discover the actual child type then your design is flawed. But that does not mean RTTI is as evil as goto statements. Properties and reflection is superior in the domain of GUI frameworks. GTK++, MFC, Qt, etc., should be proof enough that GUI libraries are too cumbersome without properties and reflection.

    A lot of people ask for C++ to have some kind of GUI library but I do agree with Stroustrup's rationale for why that is not possible. There is no common denominator of design that would make sense for every platform and would appease everyone (whom has their own opinions on the design of a GUI framework, which are radically different). It is better for C++ to rely on third party libraries that deal with GUI development. That is fine for me. What I ask for is that we improve the language to allow better development for these third party GUI libraries.

    Outside of GUI development, properties can be useful. The hardcore group, however, always argues against syntactic sugar because it is somehow pointless. This may be true for computer scientists. It is not true for software engineers. I always welcome any kind of help in reducing bugs. Syntactic sugar can actually help. To say it briefly, Delphi and Eiffel read like English. C++ reads like machine language. Guess which group of developers is going to have a higher defect rate?

    Nicholas

  31. Re:Deja vu by (void*)cheerio · · Score: 2, Interesting

    First off, Java only recently got templates and generics.

    Secondly, C++ is a multi-paradigms language, you can OO or not OO, template or not template, h4x with the void pointers or not h4x with the void pointers. You and your problem choose, not someone else.

    It also has operator overloading and you can control your resourse management options, rather than rely on Java's garbage collection which fails when you want to manage resourses other than memory (e.g. DB connections)

    So Java and C# may have superseded C++ in many domains, but C++ is still king baby. Albeit a mean king.

  32. Re:Waiting for C++ 2007 lite ANSI standard by grahamlee · · Score: 2, Insightful

    I think the OP would have got on better with "mindshare" than market share...but that's just an aside. I agree that C++ and C#/Java/Objective-C object models cannot be considered supersets or subsets of each other, and think that a language which was "C++ but with C# inheritance" would not be a useful language. At least it wouldn't be a language offering anything significant that others already don't - it would be like Objective-C with static compile-time method lookups. I've never particularly got on with multiple inheritance (I'm an ObjC protocol/Java interface man) but it has its uses to a lot of people - I think it seems like a first go at aspects. Get rid of it and whatever you end up with may be of use to someone, but C++ it isn't. My particular issue with C++ is that which BS seems to be warning against - unlike him I already think there's far too much in the C++ language that should properly have gone into the standard library. For me, OO languages should be like Ruby or ObjC - give me a way to manipulate objects, then give me a bucketload of objects. On the other hand, it's possible to go too far in the opposite direction and end up with a designed-by-committee API like Java which bloats with every new release, because someone somewhere didn't like a particular package and decided it needed a complete reimplementation (but we can't deprecate the existing one for another release or so).

  33. Nothing is wrong with C# by Rogerborg · · Score: 2, Informative

    C# is what C++ always wanted to be. It was written by people who had learned from the mistakes of C++ and Java. It's not perfect, but it's better than either of the others for the majority of desktop and server applications. Anyone who tells you otherwise is a Microsoft hater, or isn't working in that problem realm.

    You might also want to have a look at the D programming language, which is a ruthlessly pragmatic alternative.

    --
    If you were blocking sigs, you wouldn't have to read this.
  34. Re:The future of C++... by Nasarius · · Score: 3, Insightful
    ... is extinction. Just stating a fact here.

    Obviously. The same goes for any language. But what do you propose to replace it? The vast majority of "modern" languages are not compiled to machine code. For the moment, C++ is a good balance between the efficiency of C and the user-friendliness of higher-level languages. It fills a niche (resource-gobbling 3D games, operating systems, compatibility with C/C++ libraries, etc) that no other language does.

    --
    LOAD "SIG",8,1
  35. Re:How about... by CptNerd · · Score: 3, Insightful
    ..we wait for people to actually understand amd implement the current C++ standard?
    Unfortunately, because the spec is so convoluted, you can implement some aspects in completely incompatible ways, and still be "implementing the standard."

    I've been in the profession for over 20 years, and I've seen the same thing happen to certain "standards". Something new and innovative will come along, and within a decade, features will be added that will make it unusable, and foster the demand for "something like X but easier/simpler/faster/cleaner". Most of the feature creep is driven by large corporate interests and the demands of their programming staffs to add features that they claim they can't develop without.

    Not many people remember X Window 10R4, but the entire Xlib documentation took up a half-inch thick stack of single-sided pages, and described a basic networked window system that was useful enough to develop distributed systems with. The protocol was easy to implement, straightforward, and clean. But that wasn't good enough for the wonks at Apollo, DEC, HP, Sun, AT&T, and the researchers at MIT. So, once everyone added their "must have" requirements to X Window (we have to have font servers or we can't write good systems!) you ended up with a monstrosity of an Xlib spec that took up a thousand or so pages of documentation, added thousands of new points of failure, and spawned an entire bookshelf from O'Reilly just to try to explain how to use X.

    I saw the same thing happen to C++. In the early days it was what it set out to be, a simple, easy to implement extension to C that let you do basic object oriented programming. Sure, it wasn't Smalltalk or Scheme, but it was good enough for 90% of the tasks that really needed simple lightweight objects. But, certain vested software interests demanded that the spec be extended to include things like templates and virtual this and that, all designed to save some corporate programming group some design time, at the expense of creating a spec that required Talmudic scholars to interpret.

    I've been on the outside of Java, watching it since it was first described, and I've seen the changes and additions to the language spec over the years. The same thing is happening to Java that I saw happen to X and C++, and I predict that in 10 years or so someone will come out with a language "that does what Java does without all the overhead". I knew Java was doomed to follow the C++/X path when they announced namespace support in the language. Sorry, Javaheads, but that was the tipping point, and you're all on that long slide into obfuscation and bloat that many derided C++ for.

    I know many who actually read this post won't believe it, will argue that "Java is different" somehow, but mark my words, Java will bloat into uselessness within 10 years, just like C++ did.

    --
    By the taping of my glasses, something geeky this way passes
  36. Two important additions by ardor · · Score: 2, Insightful

    1. signals & slots. These *must* be introduced. Event handling is a breeze with them.

    2. make it mandatory for allocations to be deallocated in the heap they were allocated, that is, for example if you allocate memory with new or malloc() in a DLL, and you deallocate it with delete or free(), then the deallocation must be done in the DLL. This could be done with some tables storing the heap for each allocation. This is *very* important if you work with several DLLs in your project, since if you deallocate something that was allocated in a different module, the system crashes because you try to deallocate in the wrong heap. Especially STL containers cause a lot of trouble with DLLs.
    Well, this can be solved by overloading the new & delete operators; also, choosing "multithreaded DLL" as CRT in VisualC is a solution, since then all "multithreded DLL"-Modules share the same heap. Nevertheless, this is something that should be dealt with in the language.

    --
    This sig does not contain any SCO code.
  37. Template madness by Anonymous+Brave+Guy · · Score: 2, Insightful
    Stuff that went into Boost should be in the standard library from now on...

    Oh God, please, no!

    C++ desperately needs some basic functionality in its standard library: concurrency, GUI, maybe things like sockets. (Alas, by the standards committee's own admission, some of these -- particularly the GUI one -- are unlikely to happen.)

    What C++ doesn't need is for its relatively simple but useful standard library to be overwhelmed by every template freak and his brother's pet ideas, which is very much the direction a lot of the "in crowd" and a lot of Boost contributors are tending towards at present.

    By all means, let library designers use whatever language features are useful in whatever ingenious ways they can, but please let the interface for anything that actually gets into the standard library be simple and effective, not infinitely customisable but massively over-complex. That means some parts of Boost would be excellent additions, but others certainly would not.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  38. What is C++'s popularity? by gregarican · · Score: 2, Interesting

    I know that's a relatively intangible question to quantify but I did find a survey that lists different programming languages used in the workplace. Seems as if C++ definitely isn't dying just yet. I found another seemingly google-based article on the popularity of various programming languages. Sure Java and C# are up there with PHP thrown in as well, but C++ still has lots of current uses. Seeing I am hooked on Ruby in my workplace I am one of the few according to all of these figures :-)

  39. Strostrup is in denial by Animats · · Score: 4, Insightful
    C++ is in deep trouble, and Strostrup is in denial about it.

    C++ is the only major language with extensive abstraction but without memory safety. All other major languages are either memory-safe or don't hide the underlying machinery. (Java, C#, VB, Perl, Python, etc. all have automatic memory management. Some use garbage collection; some use reference counts. C is unsafe, but hides nothing.) This fact is responsible for millions of program crashes every day. Most security holes in C++ code come from this problem. Java and C# were invented primarily to eliminate the safety problems of C++. The open source community has generally stayed with C, where at least you can see by examination what's going on. C++ is losing market share to Java.

    And Strostrup denies this is a problem.

    This has happened before. Last time, it was Wirth. Wirth designed Pascal, Modula, and Modula II, but refused to admit that each had serious problems. He fought external compilation in Pascal. He fought extensions to the language. He even fought compile-time arithmetic. In the end, he took Pascal from a major language to a historical footnote.

    Serious systems programming was once done in Pascal, but not in Wirth's version of it. The original Macintosh and Lisa software was written in nonstandard versions of Pascal. And much of the DOS era was built on Turbo Pascal. But proliferating nonstandard versions of Pascal caused another set of problems.

    C++ has been in decline for years. "Evans Data has found that the percentage of developers using C++ has steadily declined over the last six years--from 76 percent in the spring 1998 to 46 percent in fall 2004." Strostrup also denies that.

    The C++ committee has been taken over by template fanatics. Most of the committee's effort revolves around obscure template features that few will use, and which no responsible programming manager would allow on a mission-critical project. There's very little interest in language safety, and a vocal minority that insists language safety is undesirable or impossible.

    All is not well in the C++ world. Claming otherwise is irresponsible.

    1. Re:Strostrup is in denial by I+judge+you · · Score: 2, Insightful
      C++ is the only major language with extensive abstraction but without memory safety

      And for that, I thank C++.

      C++ has been in decline for years

      Who cares? It's not dying. It's more an effect of the mass over-hyping of C++ in the 90's. When the crowd moved onto Java, the C++ scene gained...

      vocal minority that insists language safety is undesirable

      The tradeoffs involved make it undesirable. It's a fundamental architectual choice of the langauge, with undeniable performance implications. If you want safety above performance, go use another language.

      I juge you: ass

  40. The problem with nice words... by devphil · · Score: 2, Insightful


    ...is that they're already in use.

    Remember that, when the language syntax was designed, the idea was that every conforming C program would also be a conforming "C With Classes" program. Identifiers like "abstract" and "interface" were already in use as user variables, types, functions, etc.

    I think you would be pretty pissed off if the next revision of your dawn-to-disk programming language suddenly made "foo" or "i" a reserved keyword. :-)

    Time has passed and the two languages no longer fit together like that. Hell, they barely resemble each other anymore. But even ignoring C, now there are valid C++ programs which use "abstract" and "interface" as identifiers, so the problem remains.

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
  41. Re:C++ Viability by joss · · Score: 2, Interesting

    > forgive me if I take exception to some programmer hack calling himself a Scientist.

    No, I won't forgive you, you pompous fuck. He didnt call himself a scientist, he said he had graduated with a degree in CS. That's what it's called and it has as much right to be called a science as rocket science, which is more obviously engineering than CS.

    --
    http://rareformnewmedia.com/
  42. Why standards are updated by dmeranda · · Score: 2, Interesting

    First, with ISO-quality standards, updates are made carefully and slowly to insure the least pain to all users relying on the standard. Backwards compatibility is usually the most important concern to the maintainers; there's no "willy nilly" changing going on. [Compare this to say Java, whose specs change much more quickly and perhaps more "willy" than C++]

    There are many reasons to update standards periodically:

    1. Most standards bodies (such as ISO) *require* that all standards be updated, or at least re-affirmed, on a periodic basis; usually once per decade. Otherwise they are considered abandonded and "revoked" from having its standard status. This helps weed out truely abandoned standards as well as insures that the standard is properly maintained and retains its usefulness.

    2. As with most language standards, there are always many many small technical imperfections, or more commonly ambiguities, that need to be addressed or clarified. Most of these will never affect the "common" programmer, except perhaps those on the fringe (such as with embedded systems and so forth).

    3. Practical experiences with a language often show shortcommings that, although may be technically minor, greatly detract from the language's usefulness in some cases. For instance when the C standard was last updated they made the numerical semantics much tighter (because they found out FORTRAN programmers could not adequately port programs to C without them). These changes would be hardly noticed by most programmers who don't do heavy and precise computation; but greatly welcomed by those who did.

    4. Sometimes novel techniques or components are invented which prove to be very general solutions to widely-encountered problems, and which fit the "style" of the language very closely. Once these experimental components are deemed very mature and stable, adding them into the language proper can benifit all language users. For C++, many of these new extensions come out of the Boost project. But only the most mature and the most general-purpose extensions should be considered for standardization.

    For a look at what's on the C++ issue lists, look at http://www.open-std.org/jtc1/sc22/wg21/

  43. "Design and Evolution" mis-titled by alispguru · · Score: 4, Interesting

    I prefer to think of that volume as "The Design Rationalization and Mutation of C++". An astounding amount of it is Stroustrup explaining why one feature or another would have been a good idea, but had to be shelved in favor of something simpler to implement, or requiring fewer keywords to change. It shows the extent to which C++'s design was political in addition to being technical (see Lambda the Ultimate Political Party for how this worked in the Lisp community).

    It's a good, informative read, though not always a fun one - I still gnash my teeth every time I read about how they settled on termination semantics for exceptions.

    --

    To a Lisp hacker, XML is S-expressions in drag.
    1. Re:"Design and Evolution" mis-titled by Gobelet · · Score: 2, Funny

      "The Design Rationalization and Mutation of C++"

      Actually he thought about it, but the title with the font they just bought wouldn't fit the cover.

    2. Re:"Design and Evolution" mis-titled by ckaminski · · Score: 2, Interesting

      No finally() clause, that gets me every time. I understand that C++ wants to foster stack-based object creation vs. heap allocation, but dammit, a finally clause would have eliminated SO much redundancy in my code over the years...

  44. Balance between ease of use and features by Mingco · · Score: 3, Insightful

    The perfect balance of ease of use and richness of features for C++ is defined thusly:

    If any novice is able to pick up Bjarne Stroustrups' The C++ Language and beat him within an inch of his life... but no more, then the book is perfectly balanced between ease of use and richness of features.

    As it currently stands, I believe that every second or third novice would easily be able to beat Bjarne to a messy, bloody pulp almost as ugly as the code his language engenders.

  45. Re:How is that 5? by Chris+Burke · · Score: 2, Informative

    No, he means it's whatever year it ends up actually being. 2005 was just an example, as was 06 which he also listed.

    --

    The enemies of Democracy are
  46. It's far too late by pammon · · Score: 4, Insightful
    "If you think C++ is not overly complicated, just what is a protected abstract virtual base pure virtual private destructor and when was the last time you needed one?" -Tom Cargill

    The largest problem with C++ is its complexity. It is not just too complicated, it is *unmanageably complicated.* Some of the symptoms are:

    • The STL has inexplicable omissions. For example, there's no portable way to seed the built-in PRNG in the random_shuffle algorithm, rendering it useless.
    • Guruhood isn't good enough. Consider the seemingly simple task of creating a stack that works correctly with exceptions. It's extraordinarily difficult even for a guru.
    • Language features interact in nonintuitive ways, producing a combinatorial explosion. For example, if you overload a function in a class, you don't have to use the scope resolution operator, and if you override a function, you don't have to use it either - but if you do both, you DO have to use the scope resolution operator or else you get a compile error!
    Insofar as the new C++ standard adds stuff, instead of simplifying, this will only get worse. Since it's unreasonable to expect a new standard to remove features, the problem is unfixable. The result will be that programmers carve out their separate comfort zones, compiler vendors will not implement all features, and the monolithic C++ language will fragment into a Venn diagram of sublanguages. More so than today.
  47. The article looks like a promotional prop... by iskander · · Score: 2, Insightful

    and Bjarne sounds as if he were rehearsing his pitch on the eve of a product launch. As if C++ needed to be re-launched! I wonder whether he does this because he fears people's reaction to the new standard. In any case, it seems he hopes to preempt a good deal of criticism by manipulating our view of the standard's gestation ahead of the release. We've seen this kind of thing before, haven't we?

    Technique Before the launch, persuade clients to believe that the product's development was/is governed by core values they already hold. Result After the launch, clients are less likely to look at the product critically and dispassionately because they are already satisfied that it respects their core values.

    But maybe that's what a language creator ends up having to do if he wants changes to be widely accepted and (more importantly) adopted so that the language does not become stale. Yes, "the end justifies the means" and all that jazz. That might account for the delay in the delivery of Perl 6 and the endless series of Exegeses and Apocalypses and Ecclesiastes and whatnot.

    What I don't fully understand, then, is why Bjarne spoils an otherwise excellent pamphlet by indulging in the pointless denunciation of enumerations as an "odd and isolated feature" born of or comparable to (it's not clear from the phrasing) a "random extension" that was included in the standard due to operational deficiencies in the standards process. Is this flamebait, tossed our way to draw attention to his article and to the standards process? Certainly, he isn't trying to discredit the process by acknowledging the inevitability of incorporating "random extensions" that would later become "odd and isolated" features, is he?

  48. Re:wxWidgets by Tim+Browse · · Score: 2, Informative

    I keep looking at wxWidgets every now and again, but I can never shake off the feeling that I will just be annoyed by it.

    This is quite possibly because I've been writing my own abstracted GUI library over the past few years - as both a learning exercise and to produce a useful library, so I admit that I'm biased.

    To take an example - for UI/GDI stuff, MFC is just a very thin wrapper over most Win32 objects/calls. It basically takes care of object destruction and has a few (crap) convenience functions, but that's it.

    One of my pet hates is that the standard listbox control works differently to the 'new' listview control (introduced in Win95). Again, in MFC, the APIs are different. Another pet hate is that to clear a listbox of all items, clear a listview of all items, or clear a combobox list of all items is like 3 different calls, ClearContents(), DeleteAll(), or whatever.

    In my own GUI library, you instantiate the same listbox class and attach it to the control in a dialog, and it automagically handles the rest. You use the same API to manage the two types of list control - this is as it should be, imho.

    When I checked wxWindows a while back, it failed to even manage this for unifying the API of two basically similar objects. They just copied the Win32 function names. This kind of thing doesn't inspire confidence that the higher level stuff isn't of a similar quality.

    Another pain about list controls in Windows is that for one of them (forget which - I have a library to do all this shit for me now), it's non-trivial to find which is the selected item in the list (or some similar operation that should be easy). By non-trivial, I mean it's more than one function call. Again, my library abstracts away stuff like that, but I checked wxWindows and it was still just copying the Win32 interface, even for something as obviously broken as that. I think there was even a note in the comments as to how dumb this was.

    I guess my point is: if the list control class in a GUI library isn't even nice to use, I don't want to know about the rest of it.