Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
Programming

Bjarne Stroustrup Reflects On 25 Years of C++ 553

Posted by timothy
from the stroustrup-plus-plus dept.
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:
  • Re:the best. (Score:5, Interesting)

    by ledow (319597) on Thursday October 14, 2010 @03:54PM (#33900370) Homepage

    I grew up with C and various other languages (I actually learned Z80 assembler after BASIC but before anything else) and I was forced to do Java for university despite the fact that I never attended a single "Programming in Java" lecture for two years and just downloaded the coursework and submitted it online the same day.

    I can't stand C++, it's all but unreadable to me. I'm not saying that C is always readable but C++ makes it much easier to create a mess and jumping into any large C++ project is more an exercise in reading than doing (sometimes that can be a good thing, sometimes that just gets in the way of what should just be a simple fix). And in the end it's just a clever macro / preprocessor trick over C99 to turn various "objects" into sets of function pointers that get called at creation / destruction. I honestly find C++'s syntax quite hideous, and I always thought that Java did a slightly better job at it. The trouble with Java is, unfortunately, far too much verbosity for some very simple things.

    I wouldn't necessarily recommend C to a beginner either but if you're intent on starting down the C++ line, you do actually have to learn 99.9% of C before you ever really understand anything "C++" in a given program. Thus it's a nice *extension* to a language but I don't like it being classed as a language in itself. It is "C with classes", after all.

    It very much depends where you start, I suppose, but I'm loathe to recommend anyone to start with either C or C++ until they know they want to program and will enjoy doing it.

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

    by betterunixthanunix (980855) on Thursday October 14, 2010 @03:57PM (#33900408)
    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. A function that declares a return type should have a return statement in it, and that should be beyond question. In C, failing to actually return will cause you to have corrupt data; in C++, it can cause a crash, when a temporary object that was never created is destroyed (and happens to have a virtual destructor, which is common).

    It is true, there is no on right language, but on the flip side, there certainly are languages that should be avoided if possible, and I would say that C++ is one of them. I understand that there is a lot of legacy code and that using C++ is often unavoidable, and I have found myself in that situation, but if I were starting a new project with a fresh codebase, C++ would be pretty far down the list of languages that I would consider.

  • Freedom (Score:5, Interesting)

    by FlawedLogic (1062848) on Thursday October 14, 2010 @03:57PM (#33900410)
    I've been writing C++ for 20 of those years and produced an awful lot of performance critical systems code in that time. To this day I find it the most liberating language, whatever is in your mind, you can express it, without the language compromising your intent. I can't see myself moving on until D becomes mainstream, and that may not be before I retire in ten years. I check out all the pretenders as they come and go, nothing else comes close.
  • by shutdown -p now (807394) on Thursday October 14, 2010 @04:01PM (#33900496) Journal

    C++ - the language which everyone loves to hate. Every time there is a story posted about it on /. (or any other technical forum), you see all kinds of posts ranting about how crappy it is, how Objective-C (or whatever is the fad of the day) is so much better etc.

    And yet - it is still the language in which most desktop software and games are written to this day, and this doesn't show the signs of changing. Not only that, but some of the biggest and most prominent FOSS projects - Firefox, OpenOffice, KDE - are written in it.

    Ever wondered why?

  • by 91degrees (207121) on Thursday October 14, 2010 @04:15PM (#33900662) Journal
    I think I'd actually like the language if it didn't try to do so much.

    Adding classes to C was great. Operator overloads are really useful, virtual functions mean you can frequently avoid C's rather cryptic function pointer syntax. There are so many clever tricks you can do with scoping that makes C++ extremely useful.

    After that things start to get a bit nasty. Template programming seems like such a nice idea, but it's so cryptic, and totally unreadable - and why use the triangular brackets!? . The syntax to differentiate pre and post increment seems completely arbitrary, and the headaches caused by multiple inheritance and default parameters make me wonder if they're really worth the trouble. The try/catch construct is also useful but it feels so unwieldy.
  • Re:the best. (Score:0, Interesting)

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

    C is an excellent language when it's used for the purpose it was designed for.

    C++ was not designed for any one specific purpose, and so it's never a good language. Occasionally it's the least bad of all the options available.

  • Re:C++. lol. (Score:2, Interesting)

    by Dystopian Rebel (714995) * on Thursday October 14, 2010 @04:26PM (#33900802) Journal

    The parent is NOT a troll. As others have noted, BS says this himself.

    I find one of the most unfortunate things about C++ is that for years a large number of self-important people considered C++ to be the only language that *good programmers* know.

    I have sat for interviews that were in sum nothing but quizzes about the arcane features and misfeatures of C++. The interviewers thought that they were showing me that I didn't deserve to work with "geniuses".

    What they were really showing me is that I didn't want to work with arrogant primates who had lost their way in the Software Engineering Forest.

  • by Dystopian Rebel (714995) * on Thursday October 14, 2010 @04:39PM (#33900954) Journal

    TFS: "There's some surprising revelations in here, too, as his portable computer runs Windows"

    Very well, I am a long-time supporter of FOSS too, but I'll feed your troll: How is BS's use of M-Windows a surprise?

    Is it because M-Windows has bad C++ development tools?

    Is it because M-Windows is not the dominate OS?

    Is it because C++ should only be used in FOSS?

    Is it because BS should share your opinions or be damned?

  • by rbarreira (836272) on Thursday October 14, 2010 @04:51PM (#33901124) Homepage

    Could you explain concretely what you like about working with C?

    I like working with C because it gives me almost all the performance of Assembly language and almost all (or for many applications, all) the ease-of-use of higher-level languages. It's also good to know that whatever new machines or architectures pop up tomorrow, there is bound to be a good C compiler for it, which is more than you can say about most other languages.

    Just glad I don't need to read their code!

    I don't see how well-written C code is so much harder to read than well-written code in Python, Java, or whatever...

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

    by ultranova (717540) on Thursday October 14, 2010 @04:54PM (#33901148)

    While it's great to know other programming languages, learning a completely different language for the sole purpose of getting used to programming in general instead of just learning the language you want to learn seems like a waste of time.

    If you're new to programming, start with line-number Basic. When you start inventing weird workarounds for the weaknesses of that language - namely, the lack of stack - graduate to C and the world of Block Programming. When that starts seeming small to you, graduate to C++/Java.

    The thing is, each and every programming paradigm has been invented to solve problems. You can't really understand it if you don't understand the problem(s) it was invented to solve, and those problems are really only apparent once you push the language to its limits and try make up your own ways to escape them.

    And hey, who knows, maybe you'll invent something better.

  • Re:Objective C (Score:5, Interesting)

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

    I think the thing that puts a lot of people off ObjectiveC when they come across it the first time is unfamiliar syntax for calling a method. Ironically this is one of it's greatest strengths! In objectiveC function polymophism is not determined a 'signature' created by the argument "types" (which is an idiotic way to do it since it's ambiguous), but rather by the argument labels. That is, the objectiveC method labels every argument with a variable name, not it's type. For example consider the cosine() function. ObjectiveC lets you effectively says Cosine(Radians=3.14159) and Cosine(Degrees=180.0) and have those be polymorphic even though both arguments are floats. In C++ if you want to do that you'd have to create a different typedef for every argument. yuck.

        Moreover, ObjectiveC does not actually determine which method gets called at compile time. it can do it at load time with late binding (like Java) or it can do it at runtime! this is because the object that get's the message can introspect the calling args and decide how to respond to it. You get all these Java-like advantages but run a C-like speed. Nifty.

    This is not to say that ObjectiveC is untyped like python keyword args, but rather that you have the benefit of typing and labeling due to it's more versatile syntax. It's just looks funny the first time you see it.

    At this point someone always says you can do that in C++ to and then produces some archane C++ way of doing that. Yes, well you can do that in BrainFuck too since it's turing complete as well. What matters is how simple you can make that. The beauty of ObjectiveC is that it is a very very thin layer on C that gets you all the things you really wanted in an object oriented language without the crap that makes it hard to use and debug.

  • the c++ mentality (Score:2, Interesting)

    by larry bagina (561269) on Thursday October 14, 2010 @05:30PM (#33901660) Journal

    Brad Cox liked C, but it was missing OOP. So he created Objective C, a pure superset of C that embraced the C-ness but added a smalltalk inspired runtime and OO.

    Bjarne Stroustrup wanted to create a new OO (or whatever) language, but he knew that creating an entirely new language was a dead end. He hated C, but it was popular, so he embraced and extended.

  • by Anonymous Coward on Thursday October 14, 2010 @05:54PM (#33901912)
    After 25 years, the core concepts of C++ are still misunderstood. This is not surprising since people jumped into C++ from C and saw C++ only as a syntactic sugar over C.
    The key concept of C++ is stack unwinding with orderly destruction of scoped objects. In C++, the data best reside on the stack - the heap is for shared data or really large data, and should always be tracked by some object on the stack. No other commercial language has this concept of predictable and orderly resource management.
    Once this concept is fully grasped, one can produce very robust and clean C++ code.
  • Re:Objective C (Score:5, Interesting)

    by Haeleth (414428) on Thursday October 14, 2010 @07:27PM (#33902982) Journal

    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.

  • Re:Objective C (Score:1, Interesting)

    by Anonymous Coward on Thursday October 14, 2010 @08:23PM (#33903452)

    > ObjectiveC lets you effectively says Cosine(Radians=3.14159) and Cosine(Degrees=180.0) and have those be polymorphic

    That's not polymorphic in the least. You simply have a method composed of multiple parts. When you can omit the label and have the proper implementation picked by the criteria of the argument alone, that's polymorphism..

    Objective C has polymorphism through other means, such as protocols. Selectors alone don't cut it.

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

    by larry bagina (561269) on Thursday October 14, 2010 @08:28PM (#33903496) Journal
    that would be [someObject drawSquareX: 100 y: 120 width: 30 height: 40] (not actually much of a square) or [someObject drawRectangle: myRect]
  • pick your poison (Score:3, Interesting)

    by yyxx (1812612) on Friday October 15, 2010 @12:35AM (#33904904)

    Objective-C is a caricature of Smalltalk, combining all the disadvantages of C with only few of the advantages of Smalltalk. It also lacks pretty much all the advantages of Java: Objective-C is not type-safe, it does not provide runtime safety, it does not provide sandboxing, and it does not allow you to safely load extension modules.

    C++ started out as a simple set of fixes to problems in C, and for the first few years, it was a pretty good tool. That's why it won over Objective-C, which came out around the same time. Eventually, C++ bloated beyond recognition, while Objective-C stagnated from disuse, and that's the state we're still in. There are still a few valid use cases for C++, but I see none for Objective-C.

    What should you use then? As far as languages that you can realistically use, I think the best ones around are C#, Go, Python, and Ruby. There is nothing (zero) new ideas in those languages compared to what's been available for decades and their implementations are mediocre and bloated at best. The evolution of programming languages has been a big, fat disappointment.

  • Re:pick your poison (Score:3, Interesting)

    by Rockoon (1252108) on Friday October 15, 2010 @06:08AM (#33906258)
    There has still been a bit of refinement in the standard Structured+OO paradigm, with for example Generics (first seen in Ada in 1983, but not to hit mainstream languages until C#/Java, and as templates in C++)

    Many programmers wouldnt want to go without some form of Generics today for any project of a significant size. All that research, when its proven useful, eventually makes its way into something more popular than the languages that pioneered them. The alternatives to generics are either re-inventing-the-wheel, inefficient-runtime-dynamics, or the complete-loss-of-type-safety. Thank you Jean Ichbiah (inventor of Ada!)

Sentient plasmoids are a gas.

Working...