Bjarne Stroustrup Previews C++0x 741
Szplug writes "Bjarne Stroustrup has a sneak peek at the additions to C++ that he expects will be completed (hopefully) by 2009. Included are language-defined threads, optional garbage collection, some automatic type deduction, and template concepts. From the article: 'The list of current proposals is still quite modest and not anywhere as ambitious as I'd like. However, more proposals are being considered and more libraries will appear either as part of the C++0x standard itself or as further committee technical reports.'"
Comment removed (Score:4, Interesting)
Re:What a name! (Score:2)
Sounds like a great name if it is supposed to appeal to C programmers. What would you call it? Brenda? Somehow I can't see C ever catching on with the non-geek population.
Also, I was assuming that it would be called C++09 once the launch date is sorted out. Or should that be C+=9?
Re:What a name! (Score:2)
Re:What a name! (Score:2)
Gnaaaaaa (Score:3)
Re:What a name! (Score:2)
Because C10 sounds like 2 of these [caradisiac.com]
(Note to American readers - Citroên is a car manufacturer :))
Re:What a name! (Score:2, Informative)
Re:What a name! (Score:3, Funny)
As us unfortunate VBers would say, GeekFactor.Value = True
Re:What a name! (Score:5, Insightful)
Now "C++0x"? How is that even pronounced? "See Plus Plus Zero Ecks"? Or maybe just "C...ocks"?
Actually, the correct pronunciation will be "See Plus Plus". The name of the language won't change, just as C is just called C, even though K&R C, C89 and C99 are quite different animals.
Re:What a name! (Score:2)
Re:What a name! (Score:2, Funny)
Definitely. That way, all the losers who haven't moved on to modern languages by 2009 can be known as
[drum roll]
C++0x-suckers!
Should've just done it in Python/Ruby anyways (Score:4, Interesting)
What I started to hate in C++/Java/C# is that there's no easy and standard-conforming way to express complex data 'inline'. Yeah, it's cleaner to make it XML and load it runtime, but there's no simple+quick way to do that either.
Hell, you can't event put known non-uniform data in C++ vector without doing it one-by-one.
Re:Should've just done it in Python/Ruby anyways (Score:3, Insightful)
ohh...
wait...
(reads 30 years of literature on databases, furrows brow)
I think I've seen a problem with that!
(looks up brightly)
I'd just like to point out - we own it (Score:4, Funny)
http://techupdate.zdnet.com/techupdate/stories/ma
You know where to send your royalty checks.
Thanks
Darl McBride
Don't worry - We'll license you case-by-case (Score:4, Funny)
"C++ is one of the properties that SCO owns today and we frequently are approached by customers who wish to license C++ from us and we do charge for that. Those arrangements are done on a case-by-case basis with each customer and are not disclosed publicly. C++ licensing is currently part of SCO's SCOsource licensing program."
Thanks
Blake Stowell
Comment removed (Score:3, Funny)
Re:Lisp (Score:4, Funny)
In size, maybe... (Score:5, Insightful)
They don't have writers the caliber of Guy Steele or Kent Pitman, so it'll still read like gargling razor blades
Their legacy syntax straightjacket will insure the code stays verbose and hard to read. Compare:
struct ltXMLCh {
bool operator() (const XMLCh* s1, const XMLCh* s2) const
{
return XMLString::compareString(s1, s2) 0;
};
};
with
#'string<
or (comparing apples to apples):
(lambda (s1 s2) (declare (string s1 s2)) (string< s1 s2))
Re:In size, maybe... (Score:3, Insightful)
So let me get this straight: an in-place function definition isn't clear unless you like graph theory; but a structure pretending to be a function that takes two pointers to unmodifiable hieroglyphics and promises not to change the data members it doesn't have as it
Re:In size, maybe... (Score:3, Informative)
I object to the C++ STL method of denoting function objects because it's verbose, and it's verbose without being enlightening. In C++, this kind of stuff happens routinely because of having to avoid new syntax and new keywords that might conflict with old C code. Is 'operator()' clear and intuitive to you?
The
Adding new features is not always an improvement (Score:5, Insightful)
I also have come to realize that if there is one bad thing in C++ than it is this preprocessing which it inherited from C. Especially in a large project the trouble of including the right files and linking against the matching libraries becomes a pain in the ass. In this respect I would like C++ be more like Java (or TurboPascal for the matter) where interface declarations and compiled code are unified. At the moment moving around code from one DLL to another is a lot of work, while in my perception, it could have been completely transparent from the users point of view.
I do realize that keeping backwards compatibility was one of the design features of C++, and that it also determined the success of C. But as many C++ tools are now able to make use of precompiled headers, it seems that the problem should be able to be done away with.
Re:Adding new features is not always an improvemen (Score:3, Interesting)
Even though headers and libraries are the most common problem I come across from day to day, it wasn't until now that I thought about it as an implementation problem.
I'm not sure about the preprocessing bit. ifdefs and includes to get prototypes an
Re:Adding new features is not always an improvemen (Score:3, Interesting)
I think you haven't understood the issue. Preprocessing is exactly not sufficient to assure type-safety. It has happened often enough (especially in large project with many include paths) that the wrong version of a certain .h file was included to produce a mismatch between to .dll files that would lead to mysterious crashes due to member variables being align differently.
This is because the .dll file does not contain any information of .h fil
Re:Adding new features is not always an improvemen (Score:3, Informative)
Java can have the same problem since it links in EVERYTHING at runtime. Put an outdated class in the classpath before or instead of the correct class and you've got a problem.
I don't think any other language handles the situation any better.
The only way to "fix" this is by doing some sort of version-number (timestamp?) checks, the mechanics of which aren't dependant on a
Re:Adding new features is not always an improvemen (Score:3, Insightful)
As a systems language, right now, no. But there is some really interesting-looking work on the MS Research page (the Singularity project, if I remember) with using it as that with some crazed tools they have, and exploiting the features of "safe" languages to make a differ
More features - is that what C++ really needs? (Score:5, Insightful)
If we want to write complex and secure programs quickly, we need better languages, and more features does not mean better.
Re:More features - is that what C++ really needs? (Score:3, Insightful)
Sorry, I have.
Ruby and Python are more or less equivalent languages, extremely similar in most constructs and ways of life, and rougly 90% of the "differences" between the languages boil down to syntactic sugar.
And please, I beg you, don't bring Blocks in this by saying something as stupid as "woohoo, blocks are liek magic, no one else has it, they're cruise control for greatness", blocks are anonymous functions period (in the Functional Programming sense of the term, e.g. functions with closures that are
Try reading your own post. (Score:4, Insightful)
Re:More features - is that what C++ really needs? (Score:3, Informative)
You'd be absolutely right, assuming, of course, that Python actually supported true lexical closures, which it doesn't...
Of course, I'm not so silly to think that Ruby is unique in supporting this concept. After all, the creators of Ruby stole most of their ideas from Smalltalk, who, in turn, stole many of their ideas from LISP (although, admittedly, LISP didn't switch to lexically scoped closures unti
Re:More features - is that what C++ really needs? (Score:3, Insightful)
Python indentation defines blocks (end of blocks, to be precise). I kind of fail to see how using braces or begin/end construct is "cleaner", especially since you indent languages using braces or blocks keywords by blocks anyway (see, getting rid of keywords/braces is all python does).
Less typing, less misindented code and a lower rate of confusing constructs look cleaner to me.
Re:More features - is that what C++ really needs? (Score:3, Insightful)
C++09??? (Score:3, Funny)
C++ octal-9???
Slashdot interview? (Score:5, Interesting)
Re:Slashdot interview? (Score:3, Informative)
http://slashdot.org/developers/00/02/25/1034222.s
This has brought out the C++ haters (Score:5, Insightful)
Re:This has brought out the C++ haters (Score:3, Funny)
And the guys who write those apps are the very ones who hate C++.
You have to use C++ for a couple of years to truly, honestly hate the language.
Re:This has brought out the C++ haters (Score:5, Insightful)
Not all of them. I've worked for 6 years as a game developer, and I've seen (and written myself) some pretty horrible stuff.
Yet I actually love C++ now, even though I hated it at first.
What I hate are people not thinking thing through before they code and hence writing monstruous code.
And most of these monstruosities are not C++ specific. A programmer who is not able to figure out what to put in a separate function or how to make a proper class hierarchy won't magically do better in Java, C#, Python or whatever else.
Re:This has brought out the C++ haters (Score:3, Funny)
Whereas Perl only takes a few minutes. Such efficiency!
Re:This has brought out the C++ haters (Score:4, Insightful)
I don't know about that, depends on how you classify "commercial applications right now"
-Number of stand alone applications running on people's PCs around the world? Definitely not.
-Number of programmers employed and/or counting webapps as applications? Probably yes.
Re:This has brought out the C++ haters (Score:4, Insightful)
An earlier poster commented that the very programmers who have to write the C++ apps are the ones who hate C++.
I would like to add that the very users who have to use the Java apps are the ones who hate Java.
Lots of detractors here (Score:4, Interesting)
My wish-list for c++ (Score:4, Insightful)
interface and implementation (both are keywords, comes from pascal) section: lets get rid of seperate header and code files. The idea is aged, inefficient and doesn't help clarity nor ease of coding.
Bit-arrays: yesyes, I know. Boost contains a class which does that. But I think it would be so much nicer if the language had that feature.
Re:My wish-list for c++ (Score:2)
Interface/Implementation split is good- Objective-C does that. Maybe you should consider that.
Bit arrays are dead simple in C, and boost::'s version is complicated as hell. What exactly did you have in mind?
the state of being advanced (Score:2)
I was advanced once, but unfortunately it just left me waiting for everyone else to catch up.
Just get rid of it altogether (Score:2, Interesting)
The GUI. (Score:3, Insightful)
Although this might be considered a disappointment, his citing the fact of low resources, time and money are best spent in other areas. Lets get something out the door that we can use now instead of waiting for the GUI. I'm no C++ expert, as a matter of fact I'm only into about 400 pages of my first teaching book
Nobody will deny the power of some of the C++ GUI's out there, QT is probably best of breed. Its probably good to have commerical interest in the GUI space, since the desktop is forever evolving faster than a C++ committee could handle.
Re:The GUI. (Score:3, Interesting)
Using a procedural, compiled programming languague for GUI's is a fundamentally flawed concept to begin with. If you want to create a user interface, just use HTML, XUL, XAML whatever. 300+ lines of Visual C++ code just to display hello world is indicative of an underlying problem.
Re:The GUI. (Score:4, Insightful)
If you're right, WTF would you want to use a MS product? You can do a hello world in C++ with just 3 lines (TUI) or 12 (GUI with QT).
Concerning XML-based GUI descriptors, it is in general not smaller. It is smaller to define and place the components but things goes wrong when you have to manage events. In fact, from my experience, a GUI in HTML+JS, C++/QT and Java/Swing has more or less the same number of SLOC.
Re:The GUI. (Score:3, Insightful)
All the frameworks I know tend to use their own string class, their own containers, etc -- and obviously as well their own threading library.
Threads Cannot be Implemented as a Library (Score:4, Interesting)
if you do threads in a library, you run into problems with semantics or performance. Semantic problems == compiler breaks your multithreaded program. Performance problmes == compiler does naive translation of program, terrible performance.
what's in a name (Score:3, Funny)
C++x0r (Score:3, Funny)
what is he taking OUT? (Score:3, Interesting)
-russ
Is the C++ standards committee serious? (Score:5, Insightful)
Why do they want so many years to decide on so simple things that are other languages take for granted for more than 15 years now? Let's see what they have in store:
But what makes the most negative impression is the willingness to recognize that the programming language world has made huge steps in the last few years, and C++ is light years behind. Here are some of the negative points, in random order:
As one can see, C++ has a lot of ground not covered yet. Many will say "don't use C++ then". Well, that argument is not acceptable, because C++ is the only widely accepted and portable language with the correct set of basic features. C++ is the only language, for example, that allows me to have stack based objects, thus saving resources and simplyfing programming. C++ is the only widely accepted language that allows direct usage of C libraries.
C++ could have been the dominant language, if it was not for the stubborness of the C++ committee to accept that programming languages are developed based on what the world needs, and not on what a few good men know.
Re:Is the C++ standards committee serious? (Score:5, Informative)
I'm surprised that you feel qualified to make this statement, since it would require you to have the rare combination of having top secret clearange (in order to know about all military projects) and have a "need to know" about each one of them and be in the habit of posting what you know to Slashdot.
But you're simply incorrect in your statement.
Re:Is the C++ standards committee serious? (Score:3, Insightful)
I disagree since if you knew of a reasonable sample of declassified or public military projects and none of them used language X, there's no reason to assume that secret or top secret projects are going to be m
Re:Is the C++ standards committee serious? (Score:5, Insightful)
If these are your points, then use another language, like Java.
I don't want C++ to look like Java.
I want C++ to solve a different kind of problems in an easy way.
Frankly _none_ of your points would be something that I'd like to see added to the language; it would be likely to introduce complexity and confuse users even more, instead of helping them; and maybe it would also break compatibility with old C++ programs. It seems that the ISO committee agrees with this idea.
Some of your points debated:
So please: change programming language and don't complain non-sensically trying to look cool because you can speak a little jargon.
Re:Is the C++ standards committee serious? (Score:4, Informative)
If these are your points, then use another language, like Java.
But I never said that C++ should look like Java. All that I want can easily fit in the C++ style, and they can be optional.
Garbage collection: making this the default would be utterly insane. GC has to run on another thread, thus making a program unpredictable
Nope, not at all. First of all, GC does not need to run in a separate thread. I have programmed several GCs, some of them naive, some of them hardcore, and sent them to Stroustrup. None of them required a separate thread. Secondly, you shouldn't talk about predictability and C++ in the same sentence, since C/C++ pointers can easily make a program unpredictable. And if you want "predictability", as you mean it, then be aware that GC can be optional.
the lack of import declarations: thanks God we don't have them! Keeping headers and implementation in two different files is a wonderful idea
It makes code management difficult. I have to type the same things twice. I have to decide if a piece of code goes in the header or implementation file.
I can ship to the user directly my clean and documented header files. No Java-style cluttered and bloated source files. Btw, Java is different because it's compiled in bytecode.
First of all, you do not need to ship source files. Take a look at programming language D, in which the compiler produces symbol files to be directly imported to programs. Secondly, it is totally irrelevant that a language is in bytecode or not. There are bytecode compilers for C, for example.
C++ isn't, so implementing an import semantic would break C++ ABI (yet) another time.
Importing a file it is just another way of accessing declarations between programs. The difference is that imports are already pre-compiled in compiler format, and therefore faster to compile. As for compatibility between compilers, just define a standard (like D does).
What would be the point of laying out a framework in the C++ standard when nobody would use this because they already do it their own way? We're talking about graphical toolkits with millions of users and bindings in a lot of different languages.
But new projects will not use the existing graphical toolkits, but the standard one.
Changing the way they do things without breaking binary compatibility for library users is just impossible.
Nobody said "stop using the other libraries". But the other libraries are a pain in the a$$ to use. Qt requires MOC, GTK sucks, wxWidgets sucks more, Motif sucks even more. Swing is nice though.
No closures: I don't know if I understood your example correctly, but with Gtkmm + sigc++ I do what you said without particular problems.
Nope, you did not. What you are referring to is a callback framework. I am talking about closures. See Smalltalk's blocks, or lambda functions of Haskell/Perl for examples.
No initialization of an object's fields at the point of their declaration: yes, this is left as a boulder for the programmer. No harm in that, you're just speaking about syntactic sugar
properties: mark a member public if you want to spare some typing. Else use an IDE that generates accessors for you. All in all, it's just laziness...
Yes, syntactic sugar, but a very important one: it will save much reduntant work.
No true message passing: use a library that provides them. As simple as that.
Obviously, you have no idea.
Re:Is the C++ standards committee serious? (Score:3, Insightful)
(I think "you don't pay for what you don't use" is a fundamental design flaw of the language, but if you dis
Disagree (Score:5, Informative)
Windows XP, NT, 9x. See: http://public.research.att.com/~bs/applications.h
and no one has used C++ for any hardcore military project.
I'd beg to differ.
-everphilski-
Re:Disagree (Score:3, Informative)
Those kernels are mostly written in C. They allow you to use C++ for drivers but they even "discourage" it in the documentation. Userspace is another matter.
As a linux kernel hacker said: "a language where '+' is allowed to do something that it's not really '+' is not a good choice for a kernel"
Re:Disagree (Score:3, Informative)
As for military projects, I know since I work in that sector. Ada is the primary language in these 'hardcore' military projects.
How fascinating (Score:3, Insightful)
1) It is no more portable than C. In particular, various fundamental data types are still dependent on the underlying CPU architecture for their size and format, leading to copious macro #ifdef sections in low-level code that must run on a variety of different systems.
2) Use of the extra abstraction mechanisms provided by C++ tends to result in code that is both larger and less performant. This is not a desirable attribute in a systems programming language.
3) It is already an extremely complex language that requires an extremely complex compiler to implement it. This makes it very difficult to validate, thereby rendering it useless for whole classes of systems programming tasks (e.g. high-reliability embedded systems).
4) The language is a mine-field of ambiguities, overloaded meanings, and counter-intuitive default behaviours that conspire to make it incredibly difficult to learn properly. There are so many potential pit-falls that even very experienced programmers from other languages have trouble writing high-quality code with it, meaning that the language is actually a source of problems in many projects rather than a mechanism for solving them.
It is thus not (as Bjarn claims) a "better C", at least in a systems programming context, because nearly everything it adds is largely superfluous to systems programmers, and comes at a cost that they are unwilling to pay. This is especially true in what is by far the largest segment of systems programming, i.e. embedded systems, many of which are programmed in _significantly simplified_ versions of C, not the goya-esque monster that is modern C++.
NB: it is very difficult to design a single language that is equally useful for both high-level applications programming and low-level systems programming because they have fundamentally different requirements. Systems programmers require precise control of minutiae, whereas applications programmers want something that lets them churn build quality end-user systems with a minimum of pissing around. C++ falls between these two stools, adding nothing useful to C's systems programming capabilities, while being so concerned with nit-picking minutiae that writing high-level applications in it is like scrubbing a very big floor with a very small toothbrush. It is IMO well-suited to only one notable application domain: games development, which is unusual in requiring a mixture of both low and high level code.
I like some of the proposals for C++0x (Score:3, Interesting)
language provided thread support. This would need to provide the following (at least):
1.Proper thread safety at the language level (including mandates that the standard library is thread safe)
2.Thread-local storage (i.e. a way to say "this variable is local to this thread")
3.A way to say "this block of code should only be accessed by one thread at once" or "this variable should only be accessed by one thread at once" (something like a critical section on win32 I guess)
Plus of course ways to create threads and such.
Complete compatibility with C99 (i.e. any valid C99 program is also a valid C++0x program and will compile and run)
something similar to (and compatible with) fstream/ifstream/ofstream except that it reads from a block of memory instead of a disk file
A nice sane cross-platform way to detect memory leaks (i.e. the compiler implements the standards-specific memory leak detection in the implementation of new and delete and then the progammer would enable it e.g. with a new #paragma or something. (this goes with the garbage collector idea mentioned elsewhere)
Complete unicode support throughout the C++ language and standard library (although I think this is already mostly there)
New classes or functions (e.g. a new string class and new/improved collection classes) designed such that they help prevent or miinimize buffer overflows and memory corruption and the resulting effects (sort of like how compiler vendors like microsoft have started to add "safe" string functions only standardized)
Standardized definitions for constants like pi (plus more math functions as standard)
A standard library to do data compression and uncompression (perhaps an implementation of what is defined in RFC 1950, RFC 1951 and RFC 1952 i.e. the algorithim and format used in gzip, pkzip and zlib would be appropriate). Further to this, a new fstream/ifstream/ofstream derivitive that will compress data when writen out and uncompress it when read back in (without the programmer having to do anything).
I like the idea for a standard library way to do directory and file manipulation and the idea for a standard sockets library although (like the compression idea I have above), I do wonder if they are really appropriate for C++ or if they are better provided by third party libraries.
From a former C++ fan (Score:5, Informative)
Sorry for rather long and muddled post, and also for my poor English... Also, if you have allergic reaction to Lisp advocacy, don't read any further.
Some years ago when I had some spare time I was struggling a lot trying to make C++ a better language. I was trying to reinvent reflection, easy serialization, extend metaprogramming facilities and so on. My hopes were mostly in http://www.boost.org/ [http]">Boost C++ libraries.
At some point I've decided to try to write some extended metaobject generator, like Qt's moc, but friendlier to "modern C++", using GCCXML [gccxml.org]. In addition to generating reflection info, I was thinking of generating proxy classes and other stuff like this.
Among other things I've tried to do some of XML translation work using XSL (i.e. XML AST from GCCXML -> some more AST convenient XML representation -> (transformation) -> resulting metaobject AST. I've discovered some interesting things about XSL, e.g. that it's possible to "emulate" iteration (which is somewhat lacking in XSL) with recursion. Nevertheless after a few days of fighting with XSL I've decided to try some language which is more suited for processing various trees. Of course, when C++0x is ready, I thought, it will be the best language in all respects, including tree stuff, but as of now, STL+boost::lambda+whatever is still somewhat quirky (for instance, look at those 10 pages long error messages when you make a typo). So, although I was heavily influenced by standard myth-based mindset concerning Lisps (slow, interpreted, purely academic, "lost in a sea of parenthesis" and so on) I've decided to give Scheme a try, as I've heard that it can be used as a better XSL [okmij.org].
After playing with Scheme for a while, I've found out (to my surprise) that the language can be used for many other purposes besides list (tree) processing and simple scripting (as in Gimp). As an example, there are wonderful things like Scsh [scsh.net]. It's possible to write Web applications, many Schemes can do OO. My deep respect to C++ (The Most Powerful Language Ever) began to fade, albeit slowly.
So I've begun to try to do some real things in Scheme. Disillusionment has come rather quickly due to the fact that a lot of critical stuff in Scheme (e.g. OO and packages) is not standardized and thus is 100% non-portable between implementations. Moreover, every implementation has its bugs and limitations, and when you come to the point when you need to change your implementation you discover that most of your code needs to be rewritten from scratch.
I was nearly ready to continue developing my "metaobject generator", pushing Scheme's role back to "better XSL". But something made me try Common Lisp before doing so.
What quickly became apparent to me from my CL experience is that most of problems Boost guys are fighting against are just plain nonexistent for Lispers. Look at this, for example: variant.hpp [boost.org]. A good workaround for C++ typing model. What do we have in Common Lisp?
(sorry for mangled indentation)
Now look at this beauty: boost::lambda [boost.org]. Don't forget error messages it produces when you mistype something or stumble across a bug. CL example?
Not to mention Lisp's GC versus boost::shared_ptr.
OK, these are areas where dynamic languages like Perl, Python and Ruby, and even statically typed like C# or Java are catching up to some degree. Now let's look at some CL's more-or-less unique features.
Re:From a former C++ fan (Score:3, Informative)
The examples in your first link requires a special Lisp machine to run on. I'm sure you could write Tcl drivers for a Tcl machine as well.
CPUs of "Lisp machines" were not Lisp interpretes. Their instruction set resembled something like Java or .NET bytecode actually AFAIK. Later Open Genera [rcsri.org] was released that allows one to run the Lisp OS on Alphas. Using high-level opcodes is
not critical for Lisp (most modern CL compilers save CLisp produce native machine instructions for their target architectures).
T
Re:Worth it? (Score:4, Insightful)
I agree that ADA and FORTRAN are out and Java and Python are in, but isn't C/C++ an expection?
C/C++ have been around for many years and show no signs of going away - C++ was initially developed in 1983, while C itself hails from the early 1970s - and they're still popular to this day. And, of course, C++ "bolted on new features" to C. In fact, C++ was initially called 'C with classes'.
As far as I'm concerned, as long as C++ is "the standard language" in so many places we may as well make it not suck in comparison to other languages, which we can do by appropriating the nice features of those other languages.
Just my $0.02,
Michael
Re:Worth it? (Score:3, Informative)
I agree that ADA and FORTRAN are out and Java and Python are in, but isn't C/C++ an expection?
As someone who's been paid to program in each of those over my career, I'd say that each of them have their places.
Re:Worth it? (Score:3, Funny)
Clearly you use C++ but not Java, or you'd be able to spell "exception".
Besides, Java is so on-the-way-out these days. Didn't you get the memo? I'll forward you a copy.
Re:Worth it? (Score:5, Insightful)
C++ is a tremendously type safe language, to the point where every time I work with it I feel like about 90% of the work I do is in accounting for type. Most of that work is thrown away after the code has been compiled, too, but it does make for a rock solid program if you do it right. It seems to deliver on a lot of the promise of ADA, really. If they can improve access to its features without compromising that type safety, I'm all for it.
Re:Worth it? (Score:5, Insightful)
Re:Worth it? (Score:5, Informative)
From my experience using C++ in the field, I basically agree. While type safety can be a headache, there are many errors that strong typing eliminates entirely, almost to the point that "if it compiles, it's correct".
If you were talking about ML, you might be right, but in the case of C++, that's unadulterated bullshit. C++ can never approach the "if it compiles, it's correct" ideal because it allows unsafe memory operations. I recently worked on a large C++ code base that "compiled" the day I arrived. Within a couple of months, I had fixed about 90 memory handling bugs, which type safety did absolutely nothing to guard against.
Re:Worth it? (Score:3, Insightful)
Yep, c++ == good, but not for prototypes (Score:3, Insightful)
Re:Worth it? (Score:3, Informative)
Re:Worth it? (Score:4, Informative)
Huh?!? C++ is a tremendously type dependant language, which is a very different thing from being type safe. If you type x = y * 3; where x is an unsigned integer and y is a float, a "type safe" language would generate a type-mismatch error at compile. A "type unsafe" language (like C++) would auto-cast without telling you and leave you scratching your head for hours trying to figure out why the results are not what you expected. Yes, that's a programmer error, but a good language should be designed to catch programmer errors at the earliest possible point (compile time).
Re:Worth it? (Score:3, Informative)
C++ is not a type-safe language (Score:5, Insightful)
Re:Why wait to 2009? (Score:3, Informative)
If you read "The C++ Programming Language" you will find out exactly why this isn't enabled in the default libraries. Also how to provide a trivial wrapper with just a few lines using at() and why it is left to you to do so instead of specified by the standard and implimentation details. Granted you said it's not "even possible to even enable..." when in fact this is not true. There are implimentations of C++ t
Re:Why wait to 2009? (Score:4, Informative)
That may be true (subject to debate). But the main reason is that it's everywhere. It spread and support is simply unmatchable. Even a huge corporation like Microsoft, trying to push an alternative (.Net) has a tough time making a dent in C++. Whatever shortcomings C++ may have, it's already here, everywhere, and it's not that bad as to provoke mass migration.
Re:Why wait to 2009? (Score:3, Insightful)
That depends on your benchmark. Mine is pragmatism, where it remains unrivalled for many jobs.
And while C++ has many theoretical design flaws that could be improved in a language without the historical baggage, lack of bounds checking on a vector isn't one of them. Just use at() instead of [] if your implementation doesn't do bounds checking already.
Re:Worth it? (Score:3, Interesting)
C++ is virtually a superset of ANSI C so I don't make the distinction between the two. C++ is C with classes, exceptions & rtti to me. The difference that exist are mostly irrelevant to modern programming. These days as far as most programmers or indeed compilers go, C++ and C are one and the same with a few switches to control stack unwinding or other behaviour for .c or .cpp extensions but little else.
As long as your library's entry points are not mangled,
Re:2009? (Score:2)
Re:2009? (Score:5, Insightful)
(See Stroustrup's C++ Applications page [att.com] for more.)
Re:2009? (Score:2)
Re:Here's an offer (Score:2)
How can one add to something incoherent and get a coherent result?
Re:Here's an offer (Score:2)
Re:Downhill at a fast rate (Score:5, Funny)
Re:Downhill at a fast rate (Score:3, Funny)
ln -s
Then you have to type in your OS on each reboot - kind of like having a 1.5 million character password
Re: (Score:2, Insightful)
Re:Downhill at a fast rate (Score:3, Informative)
> Too bad.
I guess I should have qualified my comment, really. I suppose in part it comes down to what problems one is trying to solve. I'm an embedded designer, working on small systems. Assembly and C turned out to be the right tools for the job. So I guess I should really have qualified my rant with "in my line of work".
The red mist has lifted now!
Re:Downhill at a fast rate (Score:3, Insightful)
Re:Downhill at a fast rate (Score:2)
Go hack mplayers source code, and then come back saying that. C++ might not be a panaeca, but danm, C code can get very, very, very ugly sometimes.
Re:Downhill at a fast rate (Score:5, Informative)
There is no such thing as a reference variable, you clearly don't know the C++ language. references are not variables. references are newly defined identifiers that refer to an object that already has identifiers referencing it, they don't change, ever, hence are not variable... But I see that you *really* meant *pass* by reference, if you want to ensure that the function can have no side effects, cast the parameter to const. Otherwise, if you expect to write software without knowing what the functions do, you should not be writing software.
BTW, when you say "fancy allowing standard operators to be overloaded" I think you mean "overrided". C has overloaded operators (+ is defined for int, char, short, long, float, double, etc). overriding lets you tell the compiler how to do addition for your custom bigint library, or whatever. You can misuse operator overriding, or you can misuse macros, each are there for a purpose, and each get misused by bad programmers.
> And now garbage collection? That just a feature to fix poorly written code.
No it isn't, it is a feature to simplify the determination of object lifetime when that lifetime depends on complex (or more likely, merely chaotic) runtime factors. Bad programmers use it to fix poorly written code. Sure, every lifetime can (maybe) be determined by some complicated equation, but when you have limits on how much CPU you can use and limits on how much time you can spend on maths, you use garbage collection.
The trick is only to use garbage collection when you know that you need it and what it means. There's the problem with most dynamic languages.
Stop complaining about things you don't know! (Score:5, Insightful)
1) people complaining here about C++ or its will-be features either aren't C++ users or don't understand much of C++;
2) people who have at least managed to RTFA to the end are complaining about new features of the _language_, that will be _few_, while the biggest efforts will be oriented towards extending the STL, which is the really important part.
Btw, only a C user that understand C++ poorly could complain about references. If you find yourself at ease with C, by all means, use it. But don't spit on another well engineered language without the necessary knowledge to do so.
By the way, about references: what's so different when passing to a C function a pointer to a struct, instead of a reference to a C++ one? Don't you have still to read the prototype to know you must pass a pointer indeed? There's just one small difference between C and C++: guess what, if the prototype is a const reference in C++ you've more guarantees the object won't change than with a const pointer in C, since C++ enforces constness. And you don't even have to worry about pointers referencing to free'd memory.
It would also have been nice if this
Oh, well: it's Slashdot after all. What was I expecting. Sigh.
Re:Make Bjarne leave it alone! (Score:2)
Re:Make Bjarne leave it alone! (Score:2)
Re:Heh (Score:5, Insightful)
Well, the power of most languages is in the libraries anyway. What is Java or C# without the standard libraries? I program in C++/Qt and rarely if ever touch all that is ugly about C++. The very few places I allocate memory myself for operation with other code I check it rigorously, Qt objects handle themselves. I use QString and QBytearray and never have issues with zero-termination or buffer overflows. Signals and slots will never crash on a dangling pointer. The new Qt4 containers with foreach are brilliant. So yeah, core C++ may be functionally poor but if you need the equivalent of java or C# it's a library away.
Kjella
Re:Heh (Score:3, Insightful)
It might be nice if he could.
Stroustrup lives in a fantasy world where the only reason C++ isn't as fast as C, or produce as small of assembly as C is because of the compilers- which he conveniently disavowes responsibility for.
Compare to Objective-C: You'll note that these new C++ "concepts" feature are extremely similar to Objective-C's "protocols"- only not only can a moderate programmer produce a fast Objective-C compiler, they'll know exactly
Re:C++ template concepts vs. C# generics constrain (Score:3, Insightful)
concepts.
Here's an example. I'm writing a concept for a Stack, which might look like this:
template
concept Stack
{
typename value_type = S::value_type;