Bjarne Stroustrup Reflects On 25 Years of C++
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."
C++ is to C as Lung Cancer is to Lung.
Truer words have never been spoken.
No, no. You're thinking of C#!
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.
And if anyone thinks C++ is the perfect language they're an idiot.
Only 25 years? When I was in college, we learned C. No "plus plus", no "objective", no "sharp"... just "C".
Aye, as a matter of fact, I am feeling than a wee bit like Scotty in the TNG episode "Relics".
http://alternatives.rzero.com/
I know he said it in jest, but the devices wouldn't have had any C++ in them at all. Only binaries, generated by assemblers, which took output from the C++ compiler. :) A couple layers of abstraction away is all...
Better known as 318230.
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.
Yay, happy birthday, my favorite language :)
Sometimes, it is more important to have the right problem than the best solution.
This is certainly true in more ways than he intended. C++ is as awful as it is useful: Extremely. I will remember this quote next time I have to make an implementation recommendation: "C++ is the right problem for this job." Fucking terrible syntax, loaded with gotchas, requires inordinate amount of expertise to avoid subtle errors--and utterly indispensable when a high-performance general purpose programming language is needed.
C++ FQA (frequently questioned answers)
(Defective C++ is a summary)
'There are only two things wrong with C++: The initial concept and the implementation' - and other quotes
Why C++ sucks
And, previsibly: http://cplusplussucks.com/
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?
Doom was written in C, not C++.
+0 Meh
trollface.jpg
I'm sure "SlashdotMedia" will improve on all the wonders that Dice Holdings blessed us all with
Alan Kay said "Actually I made up the term "object-oriented", and I can tell you I did not have C++ in mind."
C++ seems like an awful stopgap solution that got out of control.
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.
I can't stand C++, it's all but unreadable to me.
That's because just about every C++ coder wants to be the guru (and maybe find the error that gets the $2 check from Bjarne - I actually saw one and the guy who got it framed it!) so, what do they do? Ever frick'in chance they get, they have to use some esoteric feature of the language in their development regardless if it's appropriate - I've done it too. For example, how many of you fellow C++ guys made a template class even though the class would only deal with one data type for ever and ever and ever? Or overloaded an operator just for the sake of overloading it - operator overloading back in my day was the most over used and abused feature in C++.
When I got over the guru thing, I always tried to keep my code well documented and used features sparingly.
For the record, templates can be awesome such as when using the STL - that saved so much grunt work!
RIP America
July 4, 1776 - September 11, 2001
Does Bjarne Stroustrop think of women as objects?
"Trademarks are the heraldry of the new feudalism."
I do believe that anyone that claims to actually like working with C or C++ is either
1) Unfamiliar with any languages that don't let you shoot yourself in the face so easily.
2) More like a machine than a man.
3) Trying to show off his "hacking skillz".
4) Being overly nostalgic.
5) Hasn't actually used C or C++ in about a decade.
IMHO using C or C++ when not necessary displays a depressing amount of machismo and masochism. Why do it to yourself?
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?
Rich And Stupid is not so bad as Working For Rich And Stupid.
C++ is successful for one big reason: it provides most of the advantages of C with the conveniences of an object-oriented language. Performance is excellent (close to C, which with a good compiler is close to hand-written assembly in most cases) and there's enough capability that you can write just about anything in it, including things that you would never consider writing in manged languages (like device drivers or the VM for those managed languages).
The problem is that the developers of C++ have trouble saying "no". There are a bunch of C++ features that aren't really necessary, but that exist either out of legacy or because someone thought it would be a good idea.
Look at Google's C++ style guide: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Inheritance
Like most users of C++, Google uses a severely restricted subset of the language. The thing is, most of what Google has left out is quite frankly unnecessary for 99.9% of C++ users. But we're all stuck with it anyway.
Once you get past some of the C-legacy anachronisms and restrict C++ to a small subset of its functionality, it's actually a nice language. The problem is that we can't take things out at this point.
It seems appropriate to bring up that C++ was all one big joke: http://www.ariel.com.au/jokes/An_Interview_with_Bjarne_Stroustrup.html
I've never actually read anything written by him. He sounds like some dumb 15 year old high school programmer.
Boggle.
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.
There certainly is no perfect language but I find any programmer that really spends time learning Ada, or Python or other language really well ends up being a better C++ programmer in the end too. Brief interludes don't really cut it either.
--- Liberty in our Lifetime
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.
Do you even lift?
These aren't the 'roids you're looking for.
I won't bother speculating why C++ became dominant (any more than I feel like rehashing VHS vs BetaMax), but I will say this: any language that needs a series of books explaining how NOT to use the language (lest you create obscure bugs) is an inherently flawed language.
With assembly there's an excuse - you have no boundaries (no pun intended). You realize you're operating on bare metal, or at least one step above it. But with C++ you have this belief that you have the illusion of power and safety, but the reality is you have a jumble of constructs and tools that can easily be used wrong (and often are by novices and intermediate developers).
I daresay you could teach an intermediate coder how to do OO in straight C and get better results than if they were trying to use C++.
And yeah, I'm in the camp of "Obj-C is better than C++". But then, I like Ruby, Lisp, Clojure, and Scala too. C++ really needs to die. Any further energy spent on C++ needs instead to be put into JVM and other abstraction technologies.
.sigs are for post^Hers.
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.
Bjarne and the Community's creation was the bona fide beginning of my career. When I started, I thought I was a 7 in C++. Several years later, I was a 5. I wrote my best and worst code in the language, over 15 years, and I am still running into issues in the language that challenge me today. C++ helped me learn a lot about myself along the way, and I am grateful to Bjarne and the Community at large for that. A good article and interview, if not a tad brief.
Depends on which assembly you are using. If it is X86 assembly, sure, it is baroque.
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.
Why on earth would you want them to be? They aren't the same type of data. If you add 45 degrees to pi radians, the answer should not be approximately 48.142.
Having written both, I disagree. I will grant you most of my assembler has NOT been x86.
C++ is a disaster on many levels. Syntactically, it's obviously so; when a simple loop through an STL vector of int is // blah
for (std::vector::const_iterator citer = myvector.begin(); citer != myvector.end(); ++citer)
{
switch (*citer) {
}
}
Semantically it's full of land mines. Copy and conversion constructors called when you least expect it. Temporaries galore. Idioms that work, but would be inefficient if compiler-writers hadn't developed specific work-arounds (RVO, NRVO). Byzantine rules about declaration and definition and scoping. The list goes on.
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.
Once you start despising the jerks, you become one.
that would be [someObject drawSquareX: 100 y: 120 width: 30 height: 40] (not actually much of a square) or [someObject drawRectangle: myRect]
Do you even lift?
These aren't the 'roids you're looking for.
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.
It's because Bjarne Stroustrup spent 23 years at Bell Labs, and ran the Large-Scale Programming Research Department there.
Bell Labs was the birth-place of Unix, and was always Unix central. Anyone even cursorily familiar with these facts would be a bit surprised to see someone who was so close to such a Unix stronghold for so long running a non-POSIX compatible system for day-to-day use.
Bjarne Stroustrup Reflects On 25 Years of C++: My bad
Unfortunately, although Linus Torvalds is an excellent leader of technology development, he sometimes exhibits unsophisticated social behavior.
In the linked message from Linus, *YOU* are full of bullshit, he gives good reasons why he doesn't like C++, but he does not fully analyze the entire situation.
For example, he says "C++ leads to really really bad design choices". That's true in many cases, but C++ programming could be limited to the features that work well. Many of the problems with C++ are caused by programmers using features that they don't fully understand, only so they can get some experience using them. Often, it seems, programmers just want to experiment, and don't care about the long-term end result of what they are coding.
Another problem with C++ is that, while Bjarne Stroustrop was a good leader when C++ was introduced, he has basically exercised too little power in the last 20 years in making sure the C++ language and libraries developed rapidly enough, and in the correct direction.
Still, as bad as the situation is with C++, what is better? Java and C# are easily decompiled; both suffer from ugly politics. C++ is better than C in that it helps programmers control the scope of variables, for example.
When Linus Torvalds says "*YOU* are full of bullshit", he is acting out his anger, he is not acting like a leader. He is not helping make the situation better.
Unfortunately, the people on whom we rely to be our leaders are not always good leaders. We can, however, be thankful for everything positive they have done for us.
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.
How is that superior to -1?
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:
object.area(L,W)
or
object.area(W,L)
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:
object_area_L_then_W(L,W)
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.