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."
the best. (Score:4, Informative)
Re:C++. lol. (Score:5, Informative)
I don't know why you were modded as a troll. FTA itself:
Stroustrup: I'll just note that I consider the idea of one language, one programming tool, as the one and only best tool for everyone and for every problem infantile. If someone claims to have the perfect language he is either a fool or a salesman or both.
Doom (Score:5, Informative)
Doom was written in C, not C++.
Re:Reflect? (Score:5, Informative)
Re:Written in C++? (Score:1, Informative)
So was Doom II, Quake, Quake II, and Quake 3 Arena. All straight C.
Dunno about Doom 3/Quake IV, they haven't released source code for those yet.
Re:the best. (Score:5, Informative)
std::string somefunction(){}
The fact that such a thing can compile is a glaring error.
Here's something interesting: Visual Studio wouldn't compile it for me (error C4716, complains about no return value, as you had expected), but it compiled on my FreeBSD box without any complaints. Perhaps this is more of a compiler problem than a C++ problem.
Re:the best. (Score:3, Informative)
Re:the best. (Score:5, Informative)
What you are saying is not correct. The C++ standard says:
"6.6.3 The return statement
[...]
A return statement without an expression can be used only in functions that do not return a value, that is, a function with the return type void, a constructor (12.1), or a destructor (12.4).
[...]
Flowing off the end of a function is equivalent to a return with no value; this results in undefined behavior in a value-returning function."
It is perfectly legal for a compiler to issue a warning for this or even an error. I consider a compiler refusing to compile it a superior compiler.
Re:the best. (Score:4, Informative)
If you had invested enough time to learn the language well enough to get to a position that you are competent enough to teach others how to use it then you would know that that is indeed a glaring error. For example, if you take the time to check out ISO IEC-14882 (i.e., the international standard which defines the C++ programming language) you will eventually stumble on section 6.6.3 - the return statement. In that section you can read the following definition:
Flowing off the end of a function is equivalent to a return with no value; this results in undefined behavior in a value-returning function.
If you also aren't familiar with the concept of "undefined behavior", then you can read up regarding that on section 1.3.12 - undefined behavior, where you can find the following quote:
behavior, such as might arise upon use of an erroneous program construct or erroneous data, for which this International Standard imposes no requirements. Undefined behavior may also be expected when this International Standard omits the description of any explicit definition of behavior. [Note: permissible undefined behavior ranges from ignoring the situation completely with unpredictable results, to behaving during translation or program execution in a documented manner characteristic of the environment (with or with-
out the issuance of a diagnostic message), to terminating a translation or execution (with the issuance of a diagnostic message).
So you see, what you tried to define as "not making sense in C++" is nothing more than ignorance of the language associated with the use of a compiler which fails to work well in this particular scenario. The standards may be a bit permissive in not declaring this to be illegal but the only parties dropping the ball are the ones in charge of specific compiler projects and/or ignorant users who fail to understand both this basic aspect and how to properly configure their compiler of choice.
Re:Objective C (Score:2, Informative)
Nothing prevents from having that exact same syntax in C++, along with many different possible others (whatever is a valid C++ expression).
C++0x also allows the nicer Cosine(3.14159_Radians) through user-defined literals.
You are making the grand parents point for him. As he said, You are forcing the polymorphism via typedefs. Your Radians and Degrees are no longer simply floats. What you really meant to do is use a label not a type-- but since there is no syntax for that in C++ you have to use a crescent wrench as a hammer. As the parent pointed out you can do that but it's not simple and does not enforce self documenting code.
Re:Freedom (Score:3, Informative)
Except C++ is not slower than C... It's actually equally fast, and can give a lot of performance optimizations with a fraction of the code needed to do the same on C.
You're just a troll who doesn't actually know C nor C++.
Re:Objective C (Score:3, Informative)
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.
C++ actually faster than C (Score:5, Informative)
Except C++ is not slower than C... It's actually equally fast, and can give a lot of performance optimizations with a fraction of the code needed to do the same on C.
It's even better than that. There's extra type checking and tighter rules on aliasing in C++ (unless you turn them off), so it can actually generate faster code. If you trivially convert a C program to the slightly less relaxed rules of C++, you should expect at least the same performance (if not, file a bug with your compiler provider), and often better.
I agree with the sentiment that anyone who thinks C++ is slower then C understands neither. It perfectly demonstrates their lack of understanding.
Re:Doom (Score:1, Informative)
& id tech 4 & 5 are written in C++. The last C game they did was Quake3...
Re:Good leaders are not *always* good leaders. (Score:2, Informative)
Note that he was shutting down an annoying newbie who suggested something like reworking the git codebase to use "nice abstractions" to solve no real problem. C++ advocacy on the net seems to be dominated by such newbies, or then they are the gurus who know obscure C++ quirks inside out and have written a book on that.
Re:Olde Saying (Score:1, Informative)
Reputed Academics have been less shy:
"C++ is an insult to the human brain" (Niklaus Wirth)
"I invented the term Object-Oriented, and I can tell you I did not have C++ in mind" (Alan Kay)
"There are only two things wrong with C++: The initial concept and the implementation" (Bertrand Meyer)
"C++: an octopus made by nailing extra legs onto a dog" (Eric S. Raymond)
"Whenever the C++ language designers had two competing ideas as to how they should solve some problem, they said, 'OK, we'll do them both'. So the language is too baroque for my taste" (Donald E Knuth)
PROOF?
Compare the BOOST C++ library to htt://gwan.ch/ ANSI C scripts (footprint, reliability, performances, ease of use...)
Re:Olde Saying (Score:2, Informative)
The lessons learned from this experience (outside the fact that g++ was unstable) is that C++ has some strong limitations when used in a kernel and that he would never use again C++.
Good C++ compilers have appeared only recently (before 2000, Comeau C++ was the single almost standard compliant compiler). Comprehension on what is good coding style in C++ is more recent. We keep many garbage from the previous era: bad libraries, bad coding style guides,
For people that have discovered C++ recently, Linus opinion may look exaggerated, but do not accuse him of not understanding C++. You will look very misinformed.
Lables versus typedefs (Score:3, Informative)
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.
Re:Lables versus typedefs (Score:3, Informative)
Mod parent up. Nice explanation.