Please create an account to participate in the Slashdot moderation system


Forgot your password?

Bjarne Stroustrup Reflects On 25 Years of C++ 553

eldavojohn writes "Today roughly marks C++'s first release 25 years ago when about six years of Bjarne Stroustrop's life came to fruition in the now pervasive replacement language for C. It achieved ISO standardization in 1998 and its creator regularly receives accolades. Wired's short interview contains some nice anecdotes including 'If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it' and 'I'll just note that I consider the idea of one language, one programming tool, as the one and only best tool for everyone and for every problem infantile. If someone claims to have the perfect language he is either a fool or a salesman or both.' There's some surprising revelations in here, too, as his portable computer runs Windows."
This discussion has been archived. No new comments can be posted.

Bjarne Stroustrup Reflects On 25 Years of C++

Comments Filter:
  • the best. (Score:4, Informative)

    by bhcompy ( 1877290 ) on Thursday October 14, 2010 @04:41PM (#33900198)
    My first language and I wish my only. I don't know if it is because it was my first, but it's the only one that I feel like can accomplish everything I need in a very logical and clean fashion. Java comes close because it feels close, but the extra layer of syntax pisses me off. Anyways, I remember the project in high school that I was working on when it clicked in my mind as a language I can read rather than a bunch of mumbojumbo that I had to try to interpret. Thank you, recursive merge sort project.
  • Re:C++. lol. (Score:5, Informative)

    by grub ( 11606 ) <> on Thursday October 14, 2010 @04:44PM (#33900240) Homepage Journal

    I don't know why you were modded as a troll. FTA itself:

    Stroustrup: I'll just note that I consider the idea of one language, one programming tool, as the one and only best tool for everyone and for every problem infantile. If someone claims to have the perfect language he is either a fool or a salesman or both.
  • Doom (Score:5, Informative)

    by Purity Of Essence ( 1007601 ) on Thursday October 14, 2010 @05:03PM (#33900514)

    So, for me, the main satisfaction comes from interesting and challenging applications that just might not have been done without C++, or possibly been delayed for many years for lack of a language suitable for demanding real-world applications. ... Videogames like Doom

    Doom was written in C, not C++.

  • Re:Reflect? (Score:5, Informative)

    by ari_j ( 90255 ) on Thursday October 14, 2010 @05:07PM (#33900554)
    Ultimately, the only good try/catch 22 joke is the one about not making one.
  • Re:Written in C++? (Score:1, Informative)

    by Anonymous Coward on Thursday October 14, 2010 @05:07PM (#33900560)

    So was Doom II, Quake, Quake II, and Quake 3 Arena. All straight C.

    Dunno about Doom 3/Quake IV, they haven't released source code for those yet.

  • Re:the best. (Score:5, Informative)

    by The Moof ( 859402 ) on Thursday October 14, 2010 @05:16PM (#33900678)

    std::string somefunction(){}

    The fact that such a thing can compile is a glaring error.

    Here's something interesting: Visual Studio wouldn't compile it for me (error C4716, complains about no return value, as you had expected), but it compiled on my FreeBSD box without any complaints. Perhaps this is more of a compiler problem than a C++ problem.

  • Re:the best. (Score:3, Informative)

    by betterunixthanunix ( 980855 ) on Thursday October 14, 2010 @05:22PM (#33900742)
    Actually, if you look at the standard, it is not defined. The standard says what a return statement does, and it was what a function declaration should mean, but it says nothing about functions that have a non-void return type being required to have a return statement in the function body. The fact that Visual C++ won't compile that code means that (1) Visual C++ implements a language that is not exactly C++ and (2) Visual C++ corrects an error in the C++ standard. On the other hand, g++ does not try to correct errors in the standard; in fact, on at least one occasion, they have relied on omissions to justify changes to their implementation of the STL (specifically, they changed the implicit include structure, which is not defined in the standard, and which caused a lot of code to break; the right way to do things in C++ is to explicitly include all headers and never rely on implicit includes, but there are certain common implicit include structures that people have come to rely on, like fstream implicitly including iostream).
  • Re:the best. (Score:5, Informative)

    by HonIsCool ( 720634 ) on Thursday October 14, 2010 @05:57PM (#33901192)

    What you are saying is not correct. The C++ standard says:

    "6.6.3 The return statement
    A return statement without an expression can be used only in functions that do not return a value, that is, a function with the return type void, a constructor (12.1), or a destructor (12.4).
    Flowing off the end of a function is equivalent to a return with no value; this results in undefined behavior in a value-returning function."

    It is perfectly legal for a compiler to issue a warning for this or even an error. I consider a compiler refusing to compile it a superior compiler.

  • Re:the best. (Score:4, Informative)

    by GreatBunzinni ( 642500 ) on Thursday October 14, 2010 @06:46PM (#33901834)

    C++ was my first language too, and until I started teaching it to other people, it was my favorite. Then I saw all the things that make no sense in C++, which never tripped me up because I happened to have been using the language for so long. I also noticed that a lot of idioms and design patterns that I used to think were really cool hacks were just ways to avoid serious design flaws in the language itself.

    What really killed C++ for me was when a student created a situation like this:

    std::string somefunction(){}

    The fact that such a thing can compile is a glaring error.

    If you had invested enough time to learn the language well enough to get to a position that you are competent enough to teach others how to use it then you would know that that is indeed a glaring error. For example, if you take the time to check out ISO IEC-14882 (i.e., the international standard which defines the C++ programming language) you will eventually stumble on section 6.6.3 - the return statement. In that section you can read the following definition:

    Flowing off the end of a function is equivalent to a return with no value; this results in undefined behavior in a value-returning function.

    If you also aren't familiar with the concept of "undefined behavior", then you can read up regarding that on section 1.3.12 - undefined behavior, where you can find the following quote:

    behavior, such as might arise upon use of an erroneous program construct or erroneous data, for which this International Standard imposes no requirements. Undefined behavior may also be expected when this International Standard omits the description of any explicit definition of behavior. [Note: permissible undefined behavior ranges from ignoring the situation completely with unpredictable results, to behaving during translation or program execution in a documented manner characteristic of the environment (with or with-
    out the issuance of a diagnostic message), to terminating a translation or execution (with the issuance of a diagnostic message).

    So you see, what you tried to define as "not making sense in C++" is nothing more than ignorance of the language associated with the use of a compiler which fails to work well in this particular scenario. The standards may be a bit permissive in not declaring this to be illegal but the only parties dropping the ball are the ones in charge of specific compiler projects and/or ignorant users who fail to understand both this basic aspect and how to properly configure their compiler of choice.

  • Re:Objective C (Score:2, Informative)

    by Anonymous Coward on Thursday October 14, 2010 @07:19PM (#33902214)

    Cosine(Radians=3.14159) and Cosine(Degrees=180.0)

    Nothing prevents from having that exact same syntax in C++, along with many different possible others (whatever is a valid C++ expression).
    C++0x also allows the nicer Cosine(3.14159_Radians) through user-defined literals.

    You are making the grand parents point for him. As he said, You are forcing the polymorphism via typedefs. Your Radians and Degrees are no longer simply floats. What you really meant to do is use a label not a type-- but since there is no syntax for that in C++ you have to use a crescent wrench as a hammer. As the parent pointed out you can do that but it's not simple and does not enforce self documenting code.

  • Re:Freedom (Score:3, Informative)

    by Rakshasa Taisab ( 244699 ) on Thursday October 14, 2010 @08:28PM (#33902996) Homepage

    Except C++ is not slower than C... It's actually equally fast, and can give a lot of performance optimizations with a fraction of the code needed to do the same on C.

    You're just a troll who doesn't actually know C nor C++.

  • Re:Objective C (Score:3, Informative)

    by pizzach ( 1011925 ) <> on Thursday October 14, 2010 @09:19PM (#33903418) Homepage

    You get all these Java-like advantages but run a C-like speed. Right. Because, by the divine power of Saint Jobs, Objective-C is magically able to do late binding and introspection for free. Back in the real world, the speed difference between Objective-C and Java is pretty negligible.

    The reason people say this is because you can use straight C when the extra speed is paramount. Can you run inline C code in java without needing the interpreter? Using straight C code inline in Obj-C is a bit like using Assembly inline in C. It's there when you need it.

  • by pslam ( 97660 ) on Thursday October 14, 2010 @09:35PM (#33903556) Homepage Journal

    Except C++ is not slower than C... It's actually equally fast, and can give a lot of performance optimizations with a fraction of the code needed to do the same on C.

    It's even better than that. There's extra type checking and tighter rules on aliasing in C++ (unless you turn them off), so it can actually generate faster code. If you trivially convert a C program to the slightly less relaxed rules of C++, you should expect at least the same performance (if not, file a bug with your compiler provider), and often better.

    I agree with the sentiment that anyone who thinks C++ is slower then C understands neither. It perfectly demonstrates their lack of understanding.

  • Re:Doom (Score:1, Informative)

    by Anonymous Coward on Thursday October 14, 2010 @11:28PM (#33904344)

    & id tech 4 & 5 are written in C++. The last C game they did was Quake3...

  • by 21mhz ( 443080 ) on Friday October 15, 2010 @02:52AM (#33905212) Journal

    Note that he was shutting down an annoying newbie who suggested something like reworking the git codebase to use "nice abstractions" to solve no real problem. C++ advocacy on the net seems to be dominated by such newbies, or then they are the gurus who know obscure C++ quirks inside out and have written a book on that.

  • Re:Olde Saying (Score:1, Informative)

    by Anonymous Coward on Friday October 15, 2010 @04:23AM (#33905600)

    Reputed Academics have been less shy:

    "C++ is an insult to the human brain" (Niklaus Wirth)

    "I invented the term Object-Oriented, and I can tell you I did not have C++ in mind" (Alan Kay)

    "There are only two things wrong with C++: The initial concept and the implementation" (Bertrand Meyer)

    "C++: an octopus made by nailing extra legs onto a dog" (Eric S. Raymond)

    "Whenever the C++ language designers had two competing ideas as to how they should solve some problem, they said, 'OK, we'll do them both'. So the language is too baroque for my taste" (Donald E Knuth)


    Compare the BOOST C++ library to htt:// ANSI C scripts (footprint, reliability, performances, ease of use...)

  • Re:Olde Saying (Score:2, Informative)

    by e70838 ( 976799 ) on Friday October 15, 2010 @05:25AM (#33905822)
    In fact, Linus has tried to move the kernel to C++ in 1992. At that time, g++ was a piece of crap.
    The lessons learned from this experience (outside the fact that g++ was unstable) is that C++ has some strong limitations when used in a kernel and that he would never use again C++.
    Good C++ compilers have appeared only recently (before 2000, Comeau C++ was the single almost standard compliant compiler). Comprehension on what is good coding style in C++ is more recent. We keep many garbage from the previous era: bad libraries, bad coding style guides, ...
    For people that have discovered C++ recently, Linus opinion may look exaggerated, but do not accuse him of not understanding C++. You will look very misinformed.
  • by Anonymous Coward on Friday October 15, 2010 @10:34AM (#33907894)

    That was a simple example for economy of words. Let's take a more complex example. Suppose I have an area function that takes inputs like height (H=5) and width (W=6) and length (L=7). In objectC you might write the following where W,L, and H are just floats to get the area of the side of the object:
    [object area width:W height:H]
    simple and you could do that in C++ by typedef W is type width, and H is try Length.
    but now you want the area of the top and bottom:
    [object area width:L height:W ]
    But you can't do that in C++ without casting because L and W are not floats but rather are type defs that don't match their positions.
    But that's not an example of polymophism just using labels instead of type defs which is what you really wanted in the first place, since the values were logically floats and you don't need to proliferate the type defs and make it a typically C++ mess. On the other hand if you really did require type safety then you could give them types.

    THe other thing is that there are a proliferation of ways you might write the call in c++. IN most of these you would just have a list of arguments separated by commas:
    Notice there is no enforcement of self documentation here. Can you recall which order the arguments are supposed to be in? L then W or W then L? In objectiveC the labels are enforced automatically.

    People who write in C++ try to make up for the lack of labels by name mangling the method name like this:
    but there's no consistency in how that is done, and it does not enforce that the arguments are actually in the order required.

    None of this has been about polymoprhism. I was just backing up to show you that trying to use typdefs to do the job of labels is why C++ code is so damn hard to write, debug and read, and has no consistency from person to person. Notice that ObjectiveC is doing this without any bloat: THere is only way way to write the method not a proliferation. We did not have to create some library to hand in maps to fake labels as we would in C++. it's all very natural. The fact that you then get polymorphism directly emphasizes how natural it was: methods with different labels are different methods. No typecasting required. The signatures could be identical.

  • by goombah99 ( 560566 ) on Friday October 15, 2010 @10:41AM (#33907988)

    Mod parent up. Nice explanation.

How come financial advisors never seem to be as wealthy as they claim they'll make you?