An Interview With C++ Creator Bjarne Stroustrup 509
DevTool writes "Bjarne Stroustrup talks about the imminent C++0x standard and the forthcoming features it brings, the difficulties of standardizing programming languages in general, the calculated risks that the standards committee can afford to take with new features, and even his own New Year's resolutions."
C++0when? (Score:4, Informative)
Re: (Score:3, Funny)
No, it's going to be called C++0xc or 0xd.
Re:C++0when? (Score:4, Funny)
Oh wait, it already is.
Re:C++0when? (Score:5, Funny)
My user name seems appropriate here.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
As Bjarne himself says, "The x is hexadecimal"
Re: (Score:2)
Is C++ ever the right tool for the job? (Score:5, Interesting)
It seems to me that most tasks that seem good for C++ would be better handled using a mix of an easier-to-program language (Ruby, Python, heck even lisp or smalltalk or anything else) with C extensions.
IMHO C++ seems not very good at very low-level programming; since with C++ it's not always obvious what a compiler might want to do with '+' thanks to operator overloading and rather convoluted implicit casting rules. In C you're using a pretty good tool for low-level programmings (especially with a dialect where you can sneak in a few assembly calls where you need to). In Ruby you're using a reasonably nice and efficient to develop in OO language. With the incredible ease of writing C extensions for Ruby, it's easy to use the best tool for each part of the job you're doing. The only compelling reason to use C++ I can think of is if some political policy forces you to use a single language for an entire project; and then I guess C++ not quite as clunky as java or c#.
( though I'm kinda repeating myself - a longer rant I made on slashdot about the pains of C++ years ago is here http://slashdot.org/comments.pl?sid=100202&cid=8540772 [slashdot.org] . An even more condemning annoyance about C++ is that thanks to so many convoluted tricks in the language, most people who claim C++ knowledge don't actually know it, as evidenced by the comments in that old thread )
Re:Is C++ ever the right tool for the job? (Score:5, Insightful)
I tried to use ruby for a while, but ended up back with C++. I couldn't live without static typing, as it turned out, and also C++ had more libraries leading to faster development (for me, at least).
C++ is the worst language, excepting every other language I have tried. And I am happy about the new features, they should make coding much nicer.
Re: (Score:3)
Re: (Score:2)
The only compelling reason to use C++ I can think of is if some political policy forces you to use a single language for an entire project;
I think you answered your own question there.
I've found that a lot of 'outsourced' programming jobs go to people who only know one language. And that language tends to be C++, because its easier to teach someone 1 language than it is to teach them the theory and how it applies to 5 languages.
Re:Is C++ ever the right tool for the job? (Score:5, Informative)
I aggree that people tend to do too many things in C++ (me first). However, there are quite some place where C++ should be used. Mainly gaming engines and high performance computing. You NEED low level programming to deal with that. They could be written in C. But numerous C++ programming techniques (mainly template mechanism) makes it much easier to program. You could not get reusable algorithm accross multiple data type with efficient compile-time type checking at no runtime cost without templates. You could do it with macros but you will have terrible compilation problem if you screw up. Or you could use inheritance but will pay the cost at runtime.
Re:Is C++ ever the right tool for the job? (Score:4, Interesting)
Re: (Score:2)
Yes. C++ (and Java) are indispensable for scientific software. In scientific software, the spec is ever changing as the science progresses and hence the flexibility to morph the programs as needed and maintainability are of paramount importance. On the other hand, we need the speed.
Some of these can be resolved by invoking ready-made C libraries and then called in higher level languages such as Python or R or Matlab. However, in many occasions, this luxury isn't available (e.g., Markov Chain Monte Carlo sim
Re: (Score:2, Insightful)
No offense but you have to be stupid to not know what + does. If it does something unexpected, chances are you wrote it incorrectly yourself, or are using a terrible library that has undocumented operators that are working incorrectly on top of that. It's not the languages fault when programmers code like retards.
Re: (Score:2)
You have to take into account the absolute pain which is to manage a multi-language project, let alone debug any problem. Moreover, the level of mind-numbing bloatedness which interpreted languages such as those you described (ruby, python and the like) may, in your opinion, make a language a bit easier to program in, but in practical terms it leads to terribly bloated software which, unless you are running a high end desktop, runs mind-numbingly slow when compared with native, 100% C++ apps.
Re:Is C++ ever the right tool for the job? (Score:5, Informative)
It seems to me that most tasks that seem good for C++ would be better handled using a mix of an easier-to-program language (Ruby, Python, heck even lisp or smalltalk or anything else) with C extensions.
IMHO C++ seems not very good at very low-level programming; since with C++ it's not always obvious what a compiler might want to do with '+' thanks to operator overloading and rather convoluted implicit casting rules. In C you're using a pretty good tool for low-level programmings (especially with a dialect where you can sneak in a few assembly calls where you need to). In Ruby you're using a reasonably nice and efficient to develop in OO language. With the incredible ease of writing C extensions for Ruby, it's easy to use the best tool for each part of the job you're doing. The only compelling reason to use C++ I can think of is if some political policy forces you to use a single language for an entire project; and then I guess C++ not quite as clunky as java or c#.
( though I'm kinda repeating myself - a longer rant I made on slashdot about the pains of C++ years ago is here http://slashdot.org/comments.pl?sid=100202&cid=8540772 [slashdot.org] . An even more condemning annoyance about C++ is that thanks to so many convoluted tricks in the language, most people who claim C++ knowledge don't actually know it, as evidenced by the comments in that old thread )
I disagree on several points. C is great for low level programming, but many times you want to use OO rather than procedural programming. C++ allows you to do exactly the same low level programming you can do in C (including inline-assembler if needed), but also offers the ability to design in OO. I can't think of a good reason not to use C++ rather than C unless it is a simple monolithic (preferably small) project. Mixing languages brings a whole other set of headaches (including staffing issues). Ruby, Python or other languages are fine and have their place, but I can't imagine using them for systems level programming anymore than I would use C++ to build a web application. Languages like Python, Ruby, (errr.. LISP? - there is considerable debate over whether LISP is even a true "programming language" but rather an alternate implementation of a Turing machine, but I digress) are orders of a magnitude too slow to be used as systems programming languages.
Re:Is C++ ever the right tool for the job? (Score:5, Informative)
I used to be a huge C++ fan, though that has waned over the years as I've used better-designed languages and have also seen other people struggle with C++'s testier features.
That said -- I'd still take C++ over plain C for essentially anything in a heartbeat. (Basically the only exception would be stuff like microcontroller programming or other environments where there isn't really a good C++ compiler.) RAII alone is enough to seal that deal.
I don't buy most of the arguments of C over C++. For instance, take your statement that "IMHO C++ seems not very good at very low-level programming; since with C++ it's not always obvious what a compiler might want to do with '+' thanks to operator overloading and rather convoluted implicit casting rules."
But with modern compilers, I feel it's already very not obvious what the compiler is going to do with your code. What function calls are inlined? What loops are unrolled? For what I think is a reasonably dramatic example of this, take the following snippet:
and compile with optimization on. Look at the resulting assembly. There's no branch! (I'm assuming a variant of x86 or x64 here.)
If you're on a 64-bit system with GCC you'll probably see a cmov (conditional move) instruction, which kind of makes sense. But you don't even need that instruction to be available for it to omit an actual control-flow jump. Recompile with -m32 and look at the assembly again. Much longer, but still no branch. Instead, it uses one of the setxx instructions (setg in my case) and a bit of bit twiddling.
In my opinion, today's optimizers make the generated code so far removed from what you type into your editor that saying "+ can do anything!" is a drop in the bucket.
Re: (Score:3)
I don't think the point was what sort of optimizations might be employed or what the resulting binary would look like. It's not about implementation, it's about semantics.
For instance, in C, the bit shifting and boolean operators have precise and well-defined meanings. I know that anything which compiles with one of those operators is going to do exactly what that operator says. I personally don't have a problem with operator overloading (and truly miss it in Java), but in C++, the standard library co-opts
Re:Is C++ ever the right tool for the job? (Score:5, Insightful)
So you have to be paranoid and check the class definition just in case.
So I have two responses to your general comment, though they are related.
You don't need to check the class definition at all -- you just need to know that one of the operands is an object. That's all. IMO, that's the only* difference between an overloaded operator call and a normal function call.
Once you're at that point, I don't see any difference between calling the function "+" and calling the function "doSomethingSimple". If you're paranoid enough about the class defining "+" in a way that will cause it to open sockets and thus you have to check the class definition to see if it does, you should be equally paranoid that "doSomethingSimple" will do the same thing and you have to check the class definition anyway.
The second part of my response is this: why do you CARE what "+" does internally? I can think of two reasons.
First, because you're concerned about efficiency. I've already said why I think this is a red herring, especially because I suspect most overloaded operator functions will be inlined to something efficient in general other way.
The second reason is because you want to know whether "+" is a good name for that function. But again I don't see how this differs from normal functions. If I call a function add and write a.add(b) instead of a + b, why are you more suspicious about the latter? I can come up with bad names without operator overloading plenty easily enough. Hell, I come up with bad function names for my non-overloaded functions far more often than bad function "names" for my operators. (And that even neglects the personal opinion that the normal convention of a.add(b) for a + b -- e.g. like what's used in Java's complex class -- feels wrong to me. a.add(b) feels way more like a += b than a + b to me. But again -- this isn't the fault of Java not supporting operator overloading per se, but rather the fault of Sun's function naming.)
* Okay, there is one other difference. Operator overloading is cool and tempting to use. It invites abuse way more than function naming does. But some high-profile cases aside (in particular, the proposal to overload the comma operator or whatever it was to load containers, a la Vector v = 4, 5, 6, 7, 8; or something), it certainly seems to me that, in practice, programmers are actually able to hold their tongues pretty well. Strangely enough, the biggest exception to this, I feel, is the bitshift overloading in iostreams. And IMO, that's easy enough to learn and brings about enough benefits (I/O type safety, non-repetition of type information, and extensibility vs a printf-style interface, and way less syntactic overhead vs repeated function calls) that it's probably the best solution even though it's not entirely satisfactory.
Re: (Score:3)
Overloading can certainly muddle code readability, but it still depends on someone doing something wonky or overcomplicated with an operator instead of a named function. Which you could argue, comes down to "bad code is bad".
In Java on the other hand, I find it totally unpredictable and unreadable. Bad Java code uses operators and tends to have major bugs due to object VS primitive issues. The "better" Java code uses functions everywhere for equality, addition, etc. So instead of being able to quickly t
Re: (Score:3)
Re:Is C++ ever the right tool for the job? (Score:5, Informative)
There is no mandate that you must use templates or operator overloading in C++. If you are going to complain that it gives you the option then why aren't you complaining about C having goto?
In my experience when someone wants to use C over C++ for a new project it is generally because they don't know C++.
Re:Is C++ ever the right tool for the job? (Score:4, Insightful)
I always cringe when I see this statement in a discussion about programming languages. The presence or absence of a particular feature will impact the third-party libraries you use, the code samples and tutorials you come across, and the legacy apps you inherit. Even if you develop in a vacuum, some features can impact you by accident [operator overloading isn't a good example, but implict-conversion-of-numeric-types-to-boolean is].
In $FEATURE desirable or not for a particular programming language? Most always, that's going to be a complex usability/design question answerable by some combination of analysis, research, experience, testing, etc. Read the programming languages weblog [lambda-the-ultimate.org] or the discussion forums for D, Haskell, etc., to see the level of thought that goes into make these tradeoffs.
Re:Is C++ ever the right tool for the job? (Score:4, Funny)
No. THIS is a joke.
Two bytes meet. The first byte asks, “Are you ill?”
The second byte replies, “No, just feeling a bit off.”
Re: (Score:2)
Re: (Score:3)
Both the tools and the products are more complex, but the increase in complexity of the former is lower than the increase in complexity of the latter.
Re:Is C++ ever the right tool for the job? (Score:5, Funny)
Re:Is C++ ever the right tool for the job? (Score:4, Insightful)
Re: (Score:3)
Many games use two languages (C++ for the core, and something like Lua for the game logic) and it works perfectly fine.
Make it stop..... (Score:4, Interesting)
All this does is result in yet more more syntactic sugar to teach people in order to accomplish the same tasks they can already do with the older standards, and yet another round of relearning so you can tell what someone who learned a 'neat new trick' is doing. And of course you STILL need to teach the old methods to newbies so they can understand C++ code that they have to maintain.
Seriously.. this really does not help.
Re: (Score:3)
Some of us wants them. For you that do not, pass std=c++98 to gcc and be happy. Think of it as a new language :)
Re: (Score:2)
Re: (Score:2)
This will be the, what, second standard? Third? And besides the new libraries, it's not that many new hard-to-grok features that are added. Actually, I can only think of lambda, but a language without lambda is an atrocity. Is there any particular feature you are thinking of? Have you read the wikipedia page?
I have worked on a number of projects, usually as some sort of project lead or technical lead. I have had problems with people who could not grok C++ (though not many), but I have not had the problem y
Re: (Score:2)
Re:Make it stop..... (Score:4, Insightful)
Well, variable declared at the top of the function are the least evil c-ism. The real problem is a lack of understanding of RAII, and a fear of exceptions. The last time I read Googles C++ coding standards I died a little inside. People just don't "get" C++ for some reason.
Re: (Score:3)
Those ARE atrocious, are they not? Personally, my coding standing are usually "types looks like this, member variables like this, code nice".
Of course, the last bit takes a bit for people to learn, but it works nicer than a detailed standard, in my experience.
Re: (Score:2)
Some of us like it when language designers make things easier for us.
for each(int i : some_container) {
}
vs:
for(std::container_type::iterator i = some_container.begin(); i != some_container.end(); i++) {
}
One of those is immediately obvious and one takes a second to think about. Who cares if you have to learn one new piece of syntax in a language you'll use for decades?
That said, I see the standard library improvements as more interesting (mainly multithreading and hash tables). Sure
Re: (Score:2)
Er.. for the "for each" part, I mean just "for". I was confused by Microsoft extentions.
Re: (Score:2)
This is just one of MANY reasons C++ needs to die. Just about every interaction with the STL is like this. And suppose you're going through multiple parallel containers (what python calls "zip")? Then the new sugar doesn't work except for one container.
C++ is the language which allows you to just about anything, but nothing that is all of complex, clear, and efficient. No amount of hacked-on extr
Re: (Score:2)
Sounds like they could fix that by adding a 'zip' function ;)
Re: (Score:3)
And suppose you're going through multiple parallel containers (what python calls "zip")? Then the new sugar doesn't work except for one container.
The sugar is meant for a simple case, just like Python's "for". When you need something more complicated, then - again, as in Python - you use a library solution. In case of zipping two sequences together, you'd use a zip_iterator [boost.org]. In general, you can also simplify many STL patterns by using Boost range library.
And STL is unwieldy mainly because of the need to explicitly spell out types everywhere. With auto in C++0x, most STL operations are much more concise.
Re: (Score:2)
Re: (Score:2)
The problem is it's been added in a haphazard way. This is a language where a major feature (template metaprogramming) occurred _by accident_.
Re: (Score:2)
I do not agree. most of the changes are good, and really needed. They will make programs easier to read and add expressiveness. How can you be against things like auto variables and lambda expressions?
Re: (Score:2)
Re:Make it stop..... (Score:4, Interesting)
Stop trying to add more redundant features to C++...
Did you even bother to read about what these supposedly "redundant" new features are? Personally, I think these redundant new features will help maintain C++ as one of the 2 or 3 most used programming languages for the next decade. Especially since this time all of the new features already have reference implementations, so the compilers will be very quick to implement them (GCC already supports a long list of them).
I would say the single most important feature is finally having standard support for threading and concurrency. Hopefully, this will gradually lead to a standard library of high-level abstractions for parallel programming as well as concurrent algorithms (did you ever try the parallel mode of the gnu stl? parallel sort on 8 cores is sweet...).
There are also a lot of little tweaks under the hood, that programmers will benefit from even if they never need to know about it, just by using the STL. For instance even if you have never heard of move constructors, they will make some methods of standard containers more efficient and make it possible to have a proper implementation of the new unique_ptr (useful for Resource Acquisition Is Initialization paradigm). And most of the added syntax is straightforward enough that it doesn' t really add complexity:
Initializer lists:
Range-based for+auto types:
I always wanted to say this in public : (Score:2)
Re: (Score:2)
Interview (Score:5, Funny)
I always preferred this [chunder.com] interview with Bjarne Stroustrup.
(Yes, I know it's not real, but...)
Re:Interview (Score:5, Insightful)
Could they not have named it something sensible? (Score:3)
See-plus-plus-zero-ex doesn't really roll off the tongue. How about something a bit easier? Super-C, C-flat, Cmega+ or something lame that people can actually say.
(Here's your queue to explain to me what the proper pronunciation is. AND the reason for picking such a weird name)
Re:Could they not have named it something sensible (Score:4, Informative)
Because it's still just C++. C++0x is just one particular version, like C++98 or C++03. Java 1.6.23 doesn't exactly roll off the tongue either.
Re:Could they not have named it something sensible (Score:4, Informative)
Re: (Score:3)
I hope we are not using C++ anymore by 2098...
Slashdotted, here is article text (Score:4, Funny)
Interviewer: Well, it's been a few years since you changed the
world of software design, how does it feel, looking back?
Stroustrup: Actually, I was thinking about those days, just before
you arrived. Do you remember? Everyone was writing 'C'
and, the trouble was, they were pretty damn good at it.
Universities got pretty good at teaching it, too. They were
turning out competent - I stress the word 'competent' -
graduates at a phenomenal rate. That's what caused the
problem.
Interviewer: Problem?
Stroustrup: Yes, problem. Remember when everyone wrote Cobol?
Interviewer: Of course, I did too
Stroustrup: Well, in the beginning, these guys were like demi-gods.
Their salaries were high, and they were treated like
royalty.
Interviewer: Those were the days, eh?
Stroustrup: Right. So what happened? IBM got sick of it, and
invested millions in training programmers, till they were a
dime a dozen.
Interviewer: That's why I got out. Salaries dropped within a year,
to the point where being a journalist actually paid better.
Stroustrup: Exactly. Well, the same happened with 'C' programmers.
Interviewer: I see, but what's the point?
Stroustrup: Well, one day, when I was sitting in my office, I
thought of this little scheme, which would redress the
balance a little. I thought 'I wonder what would happen, if
there were a language so complicated, so difficult to learn,
that nobody would ever be able to swamp the market with
programmers? Actually, I got some of the ideas from X10,
you know, X windows. That was such a bitch of a graphics
system, that it only just ran on those Sun 3/60 things.
They had all the ingredients for what I wanted. A really
ridiculously complex syntax, obscure functions, and
pseudo-OO structure. Even now, nobody writes raw X-windows
code. Motif is the only way to go if you want to retain
your sanity.
Interviewer: You're kidding...?
Stroustrup: Not a bit of it. In fact, there was another problem.
Unix was written in 'C', which meant that any 'C' programmer
could very easily become a systems programmer. Remember
what a mainframe systems programmer used to earn?
Interviewer: You bet I do, that's what I used to do.
Stroustrup: OK, so this new language had to divorce itself from
Unix, by hiding all the system calls that bound the two
together so nicely. This would enable guys who only knew
about DOS to earn a decent living too.
Interviewer: I don't believe you said that...
Stroustrup: Well, it's been long enough, now, and I believe most
people have figured out for themselves that C++ is a waste
of time but, I must say, it's taken them a lot longer than I
thought it would.
Interviewer: So how exactly did you do it?
Stroustrup: It was only supposed to be a joke, I never thought
people would take the book seriously. Anyone with half a
brain can see that object-oriented programming is
counter-intuitive, illogical and inefficient.
Interviewer: What?
Stroustrup: And as for 're-useable code' - when did you ever hear
of a company re-using its code?
Interviewer: Well, never, actually, but...
Stroustrup: There you are then. Mind you, a few tried, in the
early days. There was this Oregon company - Mentor
Graphics, I think they were called - really caught a cold
trying to rewrite everything in C++ in about '90 or '91. I
felt sorry for them really, but I thought people would learn
from their mistakes.
Interviewer: Obviously, they didn't?
Stroustrup: Not in the slightest. Trouble is, most companies
hush-up all their major blunders, and explaining a $30
million loss to the shareholders would have been difficult.
Give them their due, though, they made it work in the end.
Interviewer: They did? Well, there you are then, it proves O-O
works.
Stroustrup: Well, almost. The executable was so huge, it took
five minutes to load, on an HP works
The problem with C++ is it's too powerful (Score:2)
And, we all know that power corrupts. So, when Joe Shortcut figures out that he can overload the '=' operator to slice his ham sandwich, you invariably end up with illogical, non-intuitively behaving code. Plus, the language in an effort to be ultimately configurable, doesn't take care of some menial, repetitive tasks. That opens the door for insanely dangerous, obscure bugs like object slicing. I wish that the standards community would have just drawn a line in the sand and said "OK, here's the cleaned
Re: (Score:2)
I never understood the first complaint. Yes, you can make = or + or whatever do crazy thing you like, but that goes for every function call. I remember debugging some (Java code, but that is besides the point) where the programmer had decided that getFoo() should actually change the internal state of the object in such a way that calling getFoo() twice totally screwed up the program. That was every bit as bad as if he has overloaded operator- to do the same.
Slicing, I agree, is a real problem, though I hav
Linking (Score:4, Interesting)
The biggest beef I have with C++ is linking.
Linking to a library that was compiled in a different C++ compiler (or even a different version of the compiler you have) is somewhere between painful and downright impossible; this is because function name mangling was never standardized and the core libraries are often incompatible.
Couldn't they standardize this in C++? It would make life so much nicer for those who deal in binaries.
Re:Linking (Score:5, Informative)
It can't be standardized in the language spec itself, because there's no notion of "object files" or even "linking" in general in the spec - it's not tied to a particular implementation technique. That's why you can actually write a conformant C++ interpreter.
Now a separate standard for C++ ABI is quite possible, and they do, in fact, exist. The trick is getting the compilers to subscribe to them, and the problem is that they already have their existing ABI (usually incompatible with other vendors), and moving to standardized ABI would break compatibility with libraries compiled with older compiler versions. It's not a big deal in Unix world where source code is generally available these days, which is why Unix compilers (e.g. g++ and Intel) converged on a common one; but Windows stuff is still broadly incompatible.
C++0x compiled! (Score:5, Funny)
Re: (Score:3)
Re: (Score:3)
Look at your comment preferences. You can change the value that is assigned to comment moderation. Funny is at +1. Just change it to -5 and you'll never see another "funny" post.
google cache (Score:3)
It is ugly as hell but it is readable... why more sites do not have a printer friendly page is beyond me (or I missed the link)!
Oh yeah, be prepared to scroll down a lot to get to the meat.
Page 1/3:
http://webcache.googleusercontent.com/search?q=cache:http://www.codeguru.com/cpp/misc/article.php/c18357/An-Interview-with-C-Creator-Bjarne-Stroustrup.htm&hl=en&client=firefox-a&hs=5K7&rls=org.mozilla:en-US:official&strip=1 [googleusercontent.com]
Page 2/3:
http://webcache.googleusercontent.com/search?q=cache:http://www.codeguru.com/cpp/misc/article.php/c18357__2/An-Interview-with-C-Creator-Bjarne-Stroustrup.htm&hl=en&client=firefox-a&hs=kN7&rls=org.mozilla:en-US:official&strip=1 [googleusercontent.com]
Page 3/3:
http://webcache.googleusercontent.com/search?q=cache:http://www.codeguru.com/cpp/misc/article.php/c18357__3/An-Interview-with-C-Creator-Bjarne-Stroustrup.htm&hl=en&client=firefox-a&hs=kN7&rls=org.mozilla:en-US:official&strip=1 [googleusercontent.com]
Now since I have posted a comment like a good /.er I can go RTFA.
Re: (Score:3)
They should have added nullptr 20 years ago. It's always amusing to read about C++'s design for type safety when we've been forced to sling around magic '0' literals all this time because someone got their panties in a bunch over automatic casting of void*.
yeah, void* was destroyed (Score:4, Insightful)
Early C++ introduced void* and it was good. C adopted it.
Then C++ took away the automatic casting, I guess about the time C++ was first standardized. OK, now what is the point? The value of void* is gone. Now we write code with nasty casts. We can even hide the nasty casts in macros. Oh joy.
C remains fairly sane. There haven't been any serious fuckups since the trigraph disaster which no compiler enables by default. C99 is damn nice in fact.
Re: (Score:3)
"void *" is a stupid misfeature, which I avoid in all new C code that is written by me.
C++ never took away the automatic conversion from "void *"; it never had such a conversion. C perverted the "void *" idea by adding that conversion. As recently as last week, I ran into a void * bug. Some stupidly defined third party API defined an important handle type like this:
typedef void *handle_t;
A typedef for void * usually spells trouble. Anyway, one of the functions of this API is like this:
Re:c++ 1x sucks (Score:4, Funny)
It's a long time before anyone starts to use nullptr.
If you ever ran Visual Studio 2010, you have used a product that uses nullptr in some parts of its source.
(while we're at it, it also has C++0x lambdas)
Re: (Score:3)
The reason nobody has ever wanted lambdas
Why do you speak for other people? I don't know a single experienced C++ developer who wasn't excited about lambdas. For one thing, they finally make STL algorithms actually usable, because you don't have to write insane amount of boilerplate.
For that matter, consider the fact that someone bothered enough to write Boost.Bind and Boost.Lambda, and that even more people used that. This alone shows that a lot of people wanted lambdas.
they're ugly, confusing, and difficult to maintain.
Ugly is subjective.
Confusing - every mainstream language today except Java ha
Re: (Score:3)
It's a long time before anyone starts to use nullptr. NULL is still shorter to type and too entrenched in the documentation.
In which documentation? "The C++ Programming language" mentions it twice, and says it's a C thing which you should avoid -- just use 0. Which is what I do.
Of course you can still *call* it "the NULL pointer" when you talk about it.
Re: (Score:3)
NULL is defined to be integer 0 in C++, so you have to do these workarounds when you use NULL, as well; indeed, one of the advantages of using 0 is that it serves as a bit of a reminder that you need to keep these workarounds in mind.
Re: (Score:2)
Re: (Score:2)
My experience with C++ developers in the late 90's was that 99% of them knew only a tiny, tiny percentage of the language.
My experience is that 99% of people muddle through life with a combination of hubris and clandestine effort.
A similar proportion express that their knowledge and talent is well above average and insist that almost every challenge is trivial.
This group is overrepresented on Slashdot.
Re: (Score:2)
What's stopping you?
Or do you want abstractions built-in to the language, and not the implementation?
Re: (Score:2)
Then again I have noticed a lot of people (and schools) seem to be allergic to threading.
Re: (Score:2)
For which processor classes, and which problem domains? The more flexibility you want, the more you'll sacrifice in efficiency/engineer-time or efficiency/computer-time.
Re: (Score:3)
Limited to your local desktop's CPU cores, written in C or C++? You probably want to look at OpenMP, probably combined with some compiler intrinsics for vector math. (Or you can use a third-party library which already does things like that.)
I'll note that, limiting yourself to your desktop's CPU cores cripples even the average web-targeted netbook. You'd be much better off delegating the number crunching to your GPGPUs. (Even my desktop's HD3200 integrated video chipset ought to be able to trounce my Phenom
Re:Multi-processor Extensions (Score:4, Informative)
The std::thread and std::async libraries should give you all the tools you need in a plaform-independent way. The popular compiler vendors seem to be eager for C++0x - once the standard is official, Visual Studio will do a patch, and I'm sure G++ will beat them to release. Many of the C++0x features are already there with the -std=gnu++0x option to G++, though I'm not sure if that includes the threading stuff.
Re:Multi-processor Extensions (Score:5, Interesting)
So, I am an unapologetic Qt freak.
It does everything pretty damn easily and extends your C++ compiler by using a MetaObjectCompiler (MOC pre-processor) and gives you most, not all, of what C++0xForever is promising. Platform independently.
Of you don't like Qt, then there is Boost. Both are just C++ libraries.
Re:Multi-processor Extensions (Score:5, Interesting)
The core Boost classes were written by guys on the C++0x committee - they were written with the intent of becoming part of the standard library eventually. It's nice to have commonly used libraries incorporated into the language standard, especially to standardize cross-platform interfaces to platform-dependent stuff like threads.
But some stuff like Lamba just gets better syntax sugar if you change the language instead of using a library. While I'm not all that happy with the new C++ lambda syntax (what's wrong with making lamba a keyword, guys? same for you C# guys?), is still way easier than the Boost lamba syntax.
And some stuff like move semantics are just an outright fix to the language. Vector will stop requiring that Foo be copyable - finally!
Re:Multi-processor Extensions (Score:4)
lamba is not a keyword for two reasons:
a) it mostly evokes elvish pastry (properly spelt lembas)
b) lambda (/\), the Greek letter, is very common in scientific code, and making it a keyword would be painful.
Re: (Score:3)
XBMC [xbmc.org]
GitHub Source. [github.com]
Re: (Score:2)
It only uses C++ because it was originally XBMP (xbox media player) which had to be built using an illegally obtained XDK where C and C++ were the only choices.
Had other languages been available, I'm sure it would've been written using them.
Re: (Score:3, Insightful)
Not that I disagree with your feelings but QT is a major C++ magnet -- of course you could argue that QT is a language on its own, not really C++.
Re:Too little and too much, way too late (Score:4, Informative)
That there is a code generator there is really an implementation detail. From programmer's point of view, signals and slots are really just a language extension, and could as well be implemented by the compiler directly.
Re: (Score:3)
Re:Too little and too much, way too late (Score:5, Informative)
> Games developers, a few corporate app maintainers and...
Most Mozilla project applications including Firefox.. Pretty much all of KDE and some of GNOME. WebKit. Google Chrome. Opera. A good chunk of OpenOffice. Most Adobe applications. Most Microsoft desktop applications including Internet Explorer. CUPS. The Qt toolkit and pretty much everything that uses it. MySQL. Autodesk Maya. Winamp.
I wouldn't say a *few* corporate apps are written in C++, I'd say pretty much every major desktop app that's undergone a major re-write within the last two decades is probably C++.
Re:Too little and too much, way too late (Score:4, Informative)
Chop off half of the software applications on that list, at random -- can you still use your computer now? How about the internet?
Re: (Score:2)
Man, that was high-quality flamebait.
(I use C++ for almost everything in which the environment *lets* me use it, so I was the right target I guess)
Re: (Score:2)
> Games developers, a few corporate app maintainers and...
Most Mozilla project applications including Firefox.. Pretty much all of KDE and some of GNOME. WebKit. Google Chrome. Opera. A good chunk of OpenOffice. Most Adobe applications. Most Microsoft desktop applications including Internet Explorer. CUPS. The Qt toolkit and pretty much everything that uses it. MySQL. Autodesk Maya. Winamp.
I wouldn't say a *few* corporate apps are written in C++, I'd say pretty much every major desktop app that's undergone a major re-write within the last two decades is probably C++.
...National Instruments, Teradyne, pretty much any hardware interface vendor will provide a C++ instrument driver. All your pretty toys and joys of modern life have components that are tested and researched using the language. (Unless they are using LabView, but let's not go there).
Re: (Score:3)
I concur with your anecdotal evidence with my own observations and I share your opinions. But it seems like its moot compared to some of the hard data [regulargeek.com] I've seen in the past. [tiobe.com]. It may be trending down, but it's not down yet.
I believe it is also a regional thing, C# seems to dominate the Mid-Western US with Java domination on the US coasts. With C++ being, well, elsewhere out of my ethnocentric regionalisms. Again, just my own personal anecdotal evidence.
Re:Too little and too much, way too late (Score:5, Insightful)
There's still a market for low level C programmers, and for Java, C#, Perl, Python, VB, and just about everything else, but who uses C++ these days? Games developers, a few corporate app maintainers and... uh... hang on...
Not sure if you're being facetious or not here, but C++ is consistently in the top 3 languages (the others being C and Java) in terms of popularity and usage. It's well above PHP, C#, Perl, Python, VB, Obj-C, and so on. I realize that stats from Tiobe index, Sourceforge, Langpop and other sources are merely an educated guess as to what people are really using, but the fact that nearly all agree on these three languages as being the top contenders seems to add credibility to their accuracy. It certainly beats the opinion of some individuals who are biased toward their favorite (or least favorite) languages.
kept alive by beardy wierdies and a few caffeine soaked kids who'll burn out and end up writing SQL for banks in a couple of years
Hey wait a minute! I resemble that remark!
Re: (Score:2)
...It certainly beats the opinion of some individuals who are biased toward their favorite (or least favorite) languages.
I'd also say it's less religious. I mean compare C++ programmers to Java programmers, or, dare I mention -- Perl programmers (and I used to program in both for years... Criticism of the languages themselves was not taken well).
Re: (Score:3)
And for a lot of C++ programmers, the word JAVA triggers the thought "Lego coder". It will change, no doubt.
I understand your point, but I would argue that a really good programmer that only knows a single language does not exist. I don't see how one can become a good programmer without a little intellectual curiosity which would drive them to experiment and learn other languages. I started out many moons ago with Assembler, Basic, Fortran and COBOL, tried LISP (didn't like it), moved on to Pascal and PL/I, then picked up C, followed by C++, tried Objc-C (didn't like it) then Java, Perl and later C#, Groovy, Ja
Re: (Score:2)
Re: (Score:3)
We could add more, it would be a trivial change.
Re: (Score:3)
Don't judge a website by the stylesheet.
Re: (Score:3)
I never realized that the standard for C++ hadn't been updated in 13 years...
Actually, the last update was in 2003 - known, surprisingly, as C++03. It's what most C++ compilers these days implement. It was just comparatively minor, mostly bug fixing and clarifying ambiguous points etc. Though some new features sneaked in - e.g. it lets you write new int[10]() to dynamically allocate a default-initialized array.