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."
C++. lol. (Score:4, Insightful)
And if anyone thinks C++ is the perfect language they're an idiot.
C++ inside (Score:3, Insightful)
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...
The "Right Problem" (Score:4, Insightful)
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.
Re:the best. (Score:3, Insightful)
Sometimes, though, it's just simpler to go with Python, Ruby or (death coming) Perl. But I think that *real* projects use either C or C++. I do not go deep into C# and all other shitty C-ish things. They may be conquering the market, but I curse the fucktards who started using it and promoting it.
"replacement language for C" (Score:3, Insightful)
trollface.jpg
Alan Kay said it best... (Score:3, Insightful)
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.
Re:A tool for when you need to get the job done (Score:5, Insightful)
Re:A tool for when you need to get the job done (Score:3, Insightful)
Ever wondered why?
Tradition, momentum, and the fact that it occupies a very specific niche (large, low-level, high-performance applications). But taken on its own, you could do far far better than C++.
Hell, by your logic, Windows must be the greatest operating system in the history of computing.
Coders fault - Not the language (Score:4, Insightful)
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!
Programming Machismo (Score:2, Insightful)
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?
Re:A tool for when you need to get the job done (Score:2, Insightful)
C++ is the lowest common denominator language, and hence its entrenchment. Large companies, especially, are prone to entrenchment. For the first few years of OS X, Apple's devs all worked on C++ (i.e., Carbon) versions of the APIs before they worked on their Objective-C counterparts because both the Apple devs and outside companies were stuck in the era of C++. Even as they pushed Objective-C and Cocoa, it was prioritizing C++; it takes time to get away from old standards even when there are better options.
If not for entrenchment, how else can you explain why so many people who hate C++ bothered to learn it? I only learned it because it was prevalent, even though as I was learning it I saw how terrible it was.
Re:the best. (Score:4, Insightful)
Uh g++ catches that error for me. Though on the other hand, I consider -Wall -Werror to be basically non-optional arguments.
Re:the best. (Score:3, Insightful)
Except what? It means g++ is essentially doing the same thing as Visual C++ -- fixing problems with the standard in logical ways. The subset of C++ where you can't have a non-void function not explicitly return anything is a good subset of C++.
Obviously I'm taking it as given that the C++ standard has flaws. :)
Re:the best. (Score:5, Insightful)
Objective, generic, functional -- its all there and accompained with the best preprocessor, macros and code generators by leading Intel, Microsoft, AMD and even Apple C++ compilers, but again the most important thing is that nothing is really forced upon you. No "automatic memory manager" or other "nany" and "dumb things down" features that create artificial limits, slow execution, unpredictable behavious and most importantly do not restricts you to somebody's elses narrow minded coding practices.
The problem with C++ (Score:5, Insightful)
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 [googlecode.com]
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.
Re:the best. (Score:4, Insightful)
The fact that Visual C++ won't compile that code means that (1) Visual C++ implements a language that is not exactly C++
I don't understand. If the behavior is undefined, doesn't that mean that it's up to the compiler to decide what to do in those cases? That doesn't mean that VC++ implements a language that is not exactly C++, it means that it chose to throw an error when this particular undefined behavior occurs. A compiler which doesn't throw that error is still deciding how to handle behavior undefined by the standard.
Boggle. Is That Really Linus??? (Score:2, Insightful)
I've never actually read anything written by him. He sounds like some dumb 15 year old high school programmer.
Boggle.
Re:For some critical views of the language... (Score:3, Insightful)
The "Why C++ sucks" author is an idiot.
He states, "In Stroustrop's mind, making C++ compatible with C was instrumental, crucial to its success." And then tells you why it's a bad thing.
But, as someone who actually lived through that time frame, I'm here to tell you that he misses the point completely. C++ compatibility was in fact instrumental to it's success.
Why? Because C++ was originally a preprocessor that converted everything to C, and then fed the C code to the C compiler. And almost EVERY platform had a C compiler. By making it compatible, he got many C-language adherents to try it, and he got it on every platform so they could do so.
Re:For some critical views of the language... (Score:2, Insightful)
The FQA is a sad hack job by somebody who doesn't know C++ all that well but is obsessed with criticizing it. I wouldn't go there. If you can filter out the actual valid stuff in it, you know it already.
Re:A tool for when you need to get the job done (Score:3, Insightful)
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?
Completely coincidentally, the set of software (both FOSS and commercial) written in C++ seems to overlap closely with the set of software for which large and prominent security flaws are discovered every month.
Ever wonder why that is?
Re:Doom (Score:2, Insightful)
Except when it isn't. Like the vast majority of iPhone/iOS stuff that is written in Objective-C, and every id game released before Doom III.
I'm not saying C++ isn't damn near ubiquitous, but the guy specifically suggested that Doom wouldn't have been possible without C++, and that's demonstrably bullshit.
Ada Programming (Score:3, Insightful)
Re:Programming Machismo (Score:3, Insightful)
No, it is not like that at all. Especially since C already gives you most of the features that make higher-level languages easy to use (variable names, records, control structures etc.). So you're getting more efficiency without making extreme efforts (unlike what your analogy would imply).
Just as early optimization is bad, I also consider early "pessimization" to be bad, and in many cases you already know from the start that your application will have to be efficient.
What makes you think that there are more appropriate tools for the task at hand? Sure, for some tasks there may be. But not for all tasks, and I think we're straying a bit from the original point which is that C can be nice to work with. No one's saying that it's always the best choice.
I'm not so sure. Bad programmers always find ways to shoot themselves in the foot, no matter how much the language tries to cripple their efforts.
Re:A tool for when you need to get the job done (Score:3, Insightful)
actually, it's because if you know what you are doing you can make it run as fast as C, and access the hardware as easily as free, and also, if you know what you're doing you can make higher level and more flexible abstractions.
people seem to have an objection to the "know what you are doing" requirement, and seem to think that in C, you don't have to know and the code manifests well. If there is any truth to that... that C code is all nicely organized now, and naturally safe, then it's only because the C programmers have internalized certain idioms and avoided other possible ones... which is what you have to do in C++ as well to use it well.
the idea of a language which works well without knowing what you are doing is laughable to me. The illusion comes, for example, from languages where you can build a robust web server in five lines (or whatever)... yes, because it has a webserver built in! if you are going to do something besides say "run this program which was already written", then you need to understand logic and machines. There is no way around that.
C++ can be made as fast as C, don't deny it because I can write a C++ program that IS C. So it's a truism. That means you only need any feature that imposes any performance hit if it saves you some other way, like protecting memory or allowing one to save time in what is actually the most precious resource, developer time.
Running with scissors and suckers on ice (Score:5, Insightful)
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.
Re:the best. (Score:5, Insightful)
What really killed C++ for me was when a student created a situation like this:
std::string somefunction(){}
After all that discussion about whether it really is a problem with the language specification, I have to say that this example is the lamest reason to damn an entire programming language. It is like damning staplers because they shoot staples into your face when you hold it backwards. Here's a tip: don't do that.
Re:Coders fault - Not the language (Score:5, Insightful)
AMEN TO THAT
C++ is like barbecue sauce. Too much and it will ruin everything.
One of the most important things in a C++ project is setting coding style and clear rules of what's ok/not ok.
So you don't have 10 levels of inheritance, 'creative use' of STL, etc, etc
Brings back memories... (Score:3, Insightful)
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.
Re:the best. (Score:5, Insightful)
That's exactly how I learned, and probably a lot of the pro coders. I started with GW-Basic, turbo pascal, visual basic, then hit a wall. Why won't my crc-32 work quickly? Use a .dll in C. So I learned C, and had some polymorphic class type stuff happening.
Then I decided to learn C++. Bloat I thought, but I basically used C syntax with a few C++ things like new. Then I had a reason to use polymorphism, and I have to say it made the code clean. I learned a lot by looking at various open source code bits, and there is a big difference between well-organized code and poorly organized. Without an intelligent IDE like MSVS 2005, where you can say "find definition" or "find references", C++ can be so poorly laid out that it's incomprehensible. But the compiler can figure it out.
At the same time I learned C++, I also regressed into x86 assembly and some 6502 as well. Now, when I debug poor C# or SQL performance, people are amazed that I can figure out where the bottlenecks are without even profiling or running the app. Knowing the language helps, but knowing what the computer has to do under the hood is priceless. You don't know the exact algorithm, but you know enough. When you see something like SqlCommandBuilder that magically knows the insert or update or delete commands for each table, you have to be able to know not to use it if you need performance. IF that's not obvious then you should really go back to the basics and unlearn.
Like when Java came out and everyone called it slow and bloated. Sure it was on some machines, but a lot of it was inefficient string concatenation. Using strings and putting them together instead of using StringBuilder or whatever it's called. Each append required allocation, copy, copy, and a free or two. The language could have helped clarify the intended usage, and examples could have been better, but lots of people don't learn the right way.
I see way too many posts on forums when I'm searching for information on poorly documented language features that indicate people don't read a single book or have any formal study of the language. They just start copying things they see, and re-use it because it worked last time. And it's even worse now, there are snippets everywhere on how to do things and no explanation on why, or what not to do. If I ever get to be a hiring interviewer, I'm going to have some very basic questions, not a programming exercise. Things like give me an example where a struct would be a better choice and where a class would be better. And for advanced positions, how to write a polymorphic class in C. Top-tier would have to modify the behavior of a program, without having the source code. Replacing me would require doing it without altering the binary.
In short, learn how the damned thing works and any language will be decent. More importantly, you can decide which one is most appropriate.
Re:Olde Saying (Score:1, Insightful)
No he isn't, he's saying that good programmers avoid C++. He's far from the only knowledgable person to hold this opinion [cat-v.org] and the most telling quotes on that page are from Stroustrup himself.
Re:Objective C (Score:5, Insightful)
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.
Re:Relative (Score:3, Insightful)
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.
Re:the best. (Score:3, Insightful)
C++ is just C without memory leaks. You can use any language to write bad code, and many people think C++ is "C with Classes" and go on to make a mess of it, but it's the ability to have only one line of code in your entire project which frees resources (and then be quite sure that one line has no bugs) which makes it great. Resource management is a constant PITA with C, but it's even less of a worry in C++ done right than it is in C# or Java (unless you genuinely need a non-trivial dynamic cyclic data structure, but somehow that's never come up for me).
It's None of Those Things (Score:4, Insightful)
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.
Re:Freedom (Score:3, Insightful)
I have been writing with C++ for 20+ years as well. Started with cfront in 87.
I'll second what Flawed Logic just said. I know and use other technologies as necessary, i.e. PHP for web development, Python for scripting...ect. But for embedded and desktop, C++ rocks. Use a framework like QT with the language and you can be every bit as productive as C#. When developers talk about all of the pitfalls of C++, it just tells me that they lack design principles and discipline. I learned object orient design from Neil Goldstien at Apple Developer University. I just bought his book, "Objective C for Dummies" (never stop learning) and he conveys some of his coding principles in that book. Those ideas have served me well. I also learned C++ at Apple Developer University. I don't remember that instructor, but if I dug through the boxes in the garage, I'm sure I could find the course work. That guy rocked and taught the principles and techniques needed for coding sanely. I can't remember that last time I referenced a null pointer, double dereferenced a pointer, over wrote the stack or other things that people complain about C++. If you do these things, you have not developed a consistent set of rules of engagement. Yes you can have garbage collection but I find I just don't need it. People often ask how I get my programs to run so fast. C++ on today's processors are blinding fast. If someone were to say that they must not have been very complex application, I would tell you that they were consumer applications for large companies: Intuit, Wind River; Qualcomm, Sony Entertainment and others. (I was a contractor.) Many of you used applications that I wrote...along with other talented people.
What I see today are developers learning a niche and then railing against anything that might threaten that niche. What is lacking is passion and the desire to learn different technology solely because it is fun. The company I am currently has Java guys who insist that Java is the end all and be all. We have C# guys who insist that the language is the end all and be all. We have Python guys who swear it is the only language one needs. When I hear the language wars between them, I just sense that maybe they do it for the money, not because of the joy of it.
If you find yourself here pontificating that your language is superior to another, maybe technology isn't your thing.
Re:Olde Saying (Score:4, Insightful)
Good leaders are not *always* good leaders. (Score:5, Insightful)
In the linked message from Linus, *YOU* are full of bullshit [lwn.net], 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.
Re:the best. (Score:3, Insightful)
Objective, generic, functional -- its all there and accompained with the best preprocessor, macros and code generators
LOL
Re:Freedom (Score:3, Insightful)
Because C and C++ are enabling, not disabling, languages. And while 99% of the time it's a bad idea to do something (like write a custom allocator for a class), occasionally, it is the right thing to do, and you're glad to have that option.
Re:Running with scissors and suckers on ice (Score:1, Insightful)
C++ is a bag of powerful tools that let you write high performance code efficiently, if you know what you're doing. Every tool in that bag was put there by someone who was trying to solve a problem. Not all of them work for all situations, but the nice thing is, the language doesn't make you pay in overhead for features you don't use; that was one of BS's design principles. When I need to write high throughput real-time code, I can bypass STL/boost, code in a "C with classes and simple templates" subset, and get my code to meet spec. When I don't need the performance, STL lets me get code working about as fast as I could do it in python, and it's still 100X faster. I could code in half a dozen different languages, but by coding mostly in C++, I can leverage utilities and libraries that I've written for my application space over and over, saving time. I can mix high performance low-level coding styles for performance-critical areas with high-productivity coding styles for the other half of the code, seamlessly. And by constantly practicing in one language, which can solve the full range of problems I am faced with, I stay good enough at it to get stuff working fast, without having to struggle with syntax and idiom.
It takes some time and dedication to learn. But the thing is, if you want a career writing complex software, learning a programming language, even a big one like C++, is the easiest thing you will ever do. There are dozens of well written books and thousands of web sites and classes, and all the work has been done for you. After you learn the language, you will have to design an entire program yourself, or, worse yet (and more likely), understand existing code well enough to improve it without causing damage. There will be no well written books about that program, and no web sites. If you're lucky, there will be some kind of documents the developers wrote, which won't exactly match the code, and they will suck compared to an O'Reilly book, even if you wrote them yourself, years ago. The language is the easy part.
People have been complaining for years that English is a terrible language, with inconsistent spelling rules and difficult grammar - but it has a million words, and is spreading all over the world. Other languages may be easier to learn, but that's not what matters. Power and ease of use, once you have climbed the learning curve, matter much more than ease of learning. You will spend much more time using English than learning it. The same is true with C++.