Bjarne Stroustrup On Concepts, C++0x 346
An anonymous reader writes "Danny Kalev has an interview with Bjarne Stroustrup about the failure of concepts, the technical issues of concepts, whether the ISO committee's days are over, and whether C++ is at a dead-end. 'I don't think that concepts were doomed to fail. Also, I don't think concepts were trying to fix many things or to transform C++ into an almost new language. They were introduced to do one thing: provide direct language support to the by-far dominant use of templates: generic programming. They were intended to allow direct expression of what people already state in comments, in design documents, and in documentation. Every well-designed template is written with a notion of what is required from its arguments. For good code, those requirements are documented (think of the standard's requirements tables). That is, today most templates are designed using an informal notion of concepts.'"
Really Unfortunate Initials (Score:4, Funny)
Donkey Kong: The specification of concepts has taken seven years. By contrast, the standardization of the entire STL took about half that time. What is so complicated about concepts?
... etc.
Bull Shit! I count the concepts work as started in 2002! I presented my first design papers in 2003! In 1994 Alex Stepanov presented a complete implementation of the STL to Andrew Koenig and me, but 2002-to-2009 and 1994-to-1998 are not comparable time lines! Alex had been working on the STL from at least 1976!
What's really unfortunate is that he's one of the very few language maintainers out there that isn't of the mentality "Rah rah! My language/tool/design-philosophy/whatever is the solution to all your problems and will take over the world tomorrow." (phrase lifted from the interview) Wish we had more people like you out there, Stroustrup. Also, if this isn't fixed by now, I'm sorry Slashdot couldn't even get your name right in the title to this story.
Re:Really Unfortunate Initials (Score:5, Insightful)
What's really unfortunate is that he's one of the very few language maintainers out there that isn't of the mentality "Rah rah! My language/tool/design-philosophy/whatever is the solution to all your problems and will take over the world tomorrow."
Care to actually provide the names of those other language maintainers, with appropriate citations, that make such claims?
Re: (Score:2, Funny)
You've never seen a Python coder, have you?
Re: (Score:3, Insightful)
You've never seen a Python coder, have you?
He said language maintainer, not language user. Care to quote the Python language maintainer(s) making such a claim?
Re: (Score:2, Interesting)
What about this quote [slashdot.org] from Guido van Rossum?
Re:Really Unfortunate Initials (Score:5, Informative)
Care to actually provide the names of those other language maintainers, with appropriate citations, that make such claims?
Few people remember this days, but Java was positioned that way back in late 1990s. I cannot find any reference because I don't remember the exact words, but I recall Scott McNealy saying something along the lines of "Now that you have Java, why would you write in anything else"?
Bertrand Meyer and his Eiffel programming language is another example. He isn't really stating directly that it's the best thing since sliced bread, but virtually all his papers on the matter read like aggressive advertisements, praising the virtues of Eiffel, and sniding other languages because they don't "see the light" in form of design-by-contract and command-query separation (conveniently ignoring the major flaws of Eiffel such as universal generic type covariance). He also edited Wikipedia article on Eiffel to match that, got extremely offended when other people have tweaked the article to remove self-promotion, and tried to "revoke" his GFDL'd contributions (read from here [wikipedia.org] on, and check the article history, for the full story of that drama).
Re: (Score:2, Offtopic)
Donkey Kong [...] Bull Shit
Bertrand Meyer and his Eiffel programming language is another example.
Let me guess: Bowel Movement?
Re: (Score:3, Interesting)
Check out the history of the actual article. The comments should be read in context of that.
By the way, the "blue font" issue might need clarification as well - it's not that he tried to use blue just for the keywords, it's that he used blue as the base text color for all code snippets, including inline ones (as it's mandated by the "Eiffel methodology"). This just looked ugly [wikipedia.org], and caused confusion with hyperlinks, which is why most other editors of the article have supported not using blue text for code s
Re:Really Unfortunate Initials (Score:5, Insightful)
It's well designed
I would disagree. Anonymous inner classes are clearly a hack necessitated by a lack of first-class function types. Lack of a more concise capturing mechanism (i.e. true lambdas) is crippling. There's nothing in the language to help solve, or even warn about, the brittle base class problem (@Override is one piece of the puzzle, but more are needed to solve it - see C# for a proper take on this problem, and API versioning in general). Type-erasing generics are one huge hack (I don't care about perf, but they are simply not first-class, and not fully typesafe - consider `instanceof` for a generic interface). Etc.
and efficient - so much so that you can implement other languages in it, to speed them up significantly.
Can you give any example of something being sped up significantly by reimplementing it in Java?
C/C++, ASM, and Java are basically the big three that everything is built on top of. Many people would be shocked that an interpreted language could make the cut.
I wouldn't be shocked, as Java isn't an interpreted language. JIT compiler still produces native code. And back when there was no JIT, Java was slow.
Re:Really Unfortunate Initials (Score:5, Insightful)
What are they supposed to say (Score:5, Insightful)
They are supposed to make the claim against the area for which their language is most appropriate. Although to be fair, it is often the people who are marketing the self-help books that tend to be the most vocal advocates of a particular language. I remember picking up an early O'Reilly book on Perl in a bookstore and reading the introduction and putting it back on the shelf in disgust because of the zealousness of the advocacy in the introduction.
I have also been down the "should not" path on several languages much to my chagrin. Fortunately, I've paid the price allowing me to spare my students the pain.
Re: (Score:2, Insightful)
Wow. Calling out Matz of all language maintainers as one with a "rah rah" mentality really shows that you have no clue at all what you are talking about. I've read most of his posts on the Ruby mailing list throughout the past 9 years and I don't think you could find a worse example. At least pick someone like David Heinemeier Hansson -- the creator of Ruby on Rails and one of the most annoying self-marketers I've encountered in software development.
Re: (Score:3, Insightful)
Larry Wall of Perl: "Perl is designed to give you several ways to do anything, so consider picking the most readable one. " - From the Perl Man Pages
Wait, wait, wait. You're seriously citing THAT as an example of (quoting from the GGP)
"Rah rah! My language/tool/design-philosophy/whatever is the solution to all your problems and will take over the world tomorrow."
?
The other examples are actually quite similar; Ruby says, in essence, "we think Ruby is good", and Java says, in essence, "Java is good". Nothing wrong with that - certainly it's not saying anything about other languages. In fact, in Ruby's case, it's explicitely said that if other languages work for you, then by all means continue using them.
But Perl? You're even crazier there. Larry isn't even saying "Perl is good"; in
Kudos: Indignation +1 (Score:3, Informative)
Yukihiro Matsumoto of Ruby: "Why should you switch to Ruby? If you are happy with Perl or Python, you don't have to. But if you do feel there must be a better language, Ruby may be your language of choice." and then "I believe people want to express themselves when they program. They don't want to fight with the language. Programming languages must feel natural to programmers."
Nice job quoting him out of sequence, and implying that his response regarding his guiding philosophy is even relevant to the question that's posed to him about switching. And also, nice job omitting the phrase "I tried to..." from his guiding philosophy. Since such a qualifier implies personal doubt that he even achieved such a goal, that doubt was endangered your thesis, so kudos removing it -- that makes his response (that you've already completely distorted by quoting out of sequence, and quoted from a
Re: (Score:3, Funny)
Re: (Score:2)
I play too much WOW. I read "Blacksmither" and "Death Knight".
The C+- Language (Score:5, Funny)
The C+-* Language
* pronounced "C, more or less."
Unlike C++, C+- is a subject oriented language. Each C+- class instance known as a subject, holds hidden members, known as prejudices or undeclared preferences, which are impervious preferences, which are impervious to outside messages, as well as public members known as boasts or claims. The following C operators are overridden as shown:
C+- is a strongly typed language based on stereotyping and self-righteous logic. The Boolean variables TRUE and FALSE (known as constants in less realistic languages) are supplemented with CREDIBLE and DUBIOUS, which are fuzzier than Zadeh's traditional fuzzy categories. All Booleans can be declared with the modifiers strong and weak. Weak implication is said to "preserve deniability" and was added at the request of the D.O.D. to ensure compatability with future versions of Ada. Well-formed falsehoods (WFFs) are assignment-compatible with all Booleans. What-if and why-not interactions are aided by the special conditional evenifnot X then Y.
C+- supports information hiding and, among friend classes only, rumor sharing. Borrowing from the Eiffel lexicon, non-friend classes can be killed by arranging contracts. Note that friendships are intransitive, volatile, and non-Abelian.
Single and multiple inheritance mechanisms are implemented with random mutations. Disinheritance rules are covered by a complex probate protocol. In addition to base, derrived, virtual, and abstract classes, C+- supports gut classes. In certian locales, polygamous derivations and bastard classes are permitted. Elsewhere, loose coupling between classes is illegal, so the marriage and divorce operators may be needed:
Operator precedence rules can be suspended with the directive #pragma dwim, known as the "Do what I mean" pragma. ANSIfication will be firmly resisted. C+-'s slogan is "Be Your Own Standard."
http://baetzler.de/humor/c_more_or_less.html [baetzler.de]
Why not just do duck typing? (Score:3, Interesting)
Templates are what Python calls 'duck typing'. ("If it looks like a duck and quacks like a duck...") Why not just do that? You could add methods for introspection and so forth...
Re: (Score:2)
Templates are what Python calls 'duck typing'. ("If it looks like a duck and quacks like a duck...") Why not just do that? You could add methods for introspection and so forth...
Because C++ is a statically typed language, which means that type errors are discovered at compile time. For C++, discover = kilobytes of error messages, which is one of the key things concepts would fix.
Generic (static) programming is one of the areas where C++ is far outshines it's competitors, though heaven knows it has enough other flaws. Sigh, someday I will get a language which satisfies my quite reasonable list of requirements for a decent language.
Re:Why not just do duck typing? (Score:5, Insightful)
Well, many type errors are discovered at compile time. Unfortunately, static typing tends to have the side effect of requiring more complex code, and often has to be worked around.
Personally, I write mostly in Java and Ruby. Java is pedantically static to a level that would make C++ blush, while Ruby is completely duck typed. I've had situations where Java's pedantic nature has caught bugs before test runs, but I've also had situations where the code was 10x as long and harder to debug because of the inflexibility. I think it's highly debatable which approach is better, and the answer probably depends on the kind of problem you're solving.
Re: (Score:2)
Well, many type errors are discovered at compile time. Unfortunately, static typing tends to have the side effect of requiring more complex code, and often has to be worked around. Only if said checks are broken, I believe. Do you have an example? But yes, declaring your types leads to more verbose code for sure; this is one of the trade offs for static typing.
Personally, I write mostly in Java and Ruby. Java is pedantically static to a level that would make C++ blush, while Ruby is completely duck typed. I've had situations where Java's pedantic nature has caught bugs before test runs, but I've also had situations where the code was 10x as long and harder to debug because of the inflexibility. I think it's highly debatable which approach is better, and the answer probably depends on the kind of problem you're solving.
I myself has worked extensively in C, C++, Ruby, Perl and Java and many other languages, and of those I do like both Ruby and C++. Java feels like a straightjacket to me, and it sounds like you have the same problem. Perhaps you should try a more powerful language, such as C++?
Re: (Score:2, Interesting)
Well, either you believe in static typing, or you don't. If you do, Java is a good choice. If you don't, Ruby is a good choice. C++, on the other hand, is static enough to be annoying, but not static enough to be safe.
I actually much prefer Objective-C to C++. Once again, the worse solution won.
Re: (Score:3, Informative)
I'm not the original poster, but many PL people would consider memory safety violations as breaking type safety. This includes buffer overruns, multiple frees, etc.
Er, you said it yourself - there's "type safety" and there's "memory safety". Those are two entirely orthogonal concepts, and I'm not aware of anyone who's into PL design (professionally or otherwise) who would mix those.
There's also an argument that the fact that you can even do unsafe casts means that C++ isn't fully type-safe.
Well, Java lets you do unsafe casts as well. Especially with generics (where such casts need not fail immediately), this can be an endless source of fun. Granted, Java at least doesn't say it's just U.B. to do so, but still.
In any case, the original post was (seemingly, at least) made more
Re:Why not just do duck typing? (Score:5, Informative)
I don't think that they are. There is quite a good comparison on the wiki [wikipedia.org] page. The main difference that springs to mind is that duck typing in Python is dynamic (resolved at runtime), where-as the type system in C++ is static (resolved at compile-time). That makes them very different beasts.
Runtime vs. compile-time checking (Score:5, Informative)
The main difference that springs to mind is that duck typing in Python is dynamic (resolved at runtime), where-as the type system in C++ is static (resolved at compile-time).
Compile-time checking has two purposes: enforce contracts between methods [wikipedia.org] and allow for optimization. I'll cover each of these in turn:
Dynamic languages have more overhead to dispatch a method call. But then static languages have to duplicate the template code for each type that it handles. It is disputed whether the more direct dispatch outweighs the overhead of loading the duplicated instructions into the CPU's instruction cache.
Types of arguments to methods make up part of a contract between a method and methods that call it. It's good to have a compiler that can verify some of a contract at compile time, but the halting problem implies that not all parts of all contracts can be expressed in a way that can a machine can verify. Fans of dynamic languages claim that purpose-written unit tests can verify contracts more thoroughly than a compiler's built-in checking, but fans of static languages claim that properly done static typing writes half the unit test for you.
Re:Runtime vs. compile-time checking (Score:4, Informative)
It is disputed whether the more direct dispatch outweighs the overhead of loading the duplicated instructions into the CPU's instruction cache.
Keep in mind that if you can statically determine what function is going to be called, you can potentially inline it. This is important for the stereotypical object-oriented designs where you have a lot of small functions (like getters and setters). This eliminates not just the function call overhead entirely, but will often enable other optimizations. (Of course, virtual functions make determining the function to be called hard or impossible in many cases.)
So it's not just the increased call overhead that dynamic languages have to deal with, it's the lack of ability to perform a bunch of other optimizations as well. Given C++ templates vs. a true interpreted language, I would wager C++ templates would win virtually every time, I-cache pressure and all.
However, not all is lost; JIT compilers start introducing a lot of the benefits from static typing back into the dynamic context once it decides to for-real compile part of the code. Once it does that, dynamic languages can pick up most of the benefits of the static language. (And my understanding is sometimes more, because the JIT compiler has some dynamic information while the static compiler has to make safe assumptions.) Of course, not all languages have true JIT compilers (e.g. Python (specifically CPython, the typical implementation) is bytecode-interpreted with no JIT compiler).
Re: (Score:2)
(Of course, virtual functions make determining the function to be called hard or impossible in many cases.)
obj.method() has three steps:
In a typical C++ implementation, __vtable is an array, and each virtual method corresponds to an element of this array indexed by a constant number. But in Python, __vtable (actually called __dict__) is an unordered map from each method names (as a string) to its entry point. Computing a string's hash value for a vtable lookup takes time, so unless you have a JIT (and CPython does not), it can s
Re: (Score:2)
Re: (Score:2)
duck typing in Python is dynamic (resolved at runtime), where-as the type system in C++ is static (resolved at compile-time).
It's not quite that simple. C++ templates are a Turing-complete programming language, evaluated at compile time. So "runtime" for templates is compile time. Type checking for templates is done when they are evaluated, not when they are defined, that is, at runtime (to repeat, the template runtime that happens during compilation). So they are indeed, like Python, duck typed. Concepts would have added a system for checking templates when they are defined, which would be the equivalent of a static type system
Re: (Score:2)
Re: (Score:2)
Re: (Score:2, Informative)
Other people have said that that breaks C++'s static typing, but what they didn't say is that static typing is one of the explicit design goals of C++.
Some quotes from The Design and Evolution of C++:
"The importance of static type checking was also strongly emphasized. In other words, C++ follows the Simula rather than the Smalltalk model of inheritance and type checking."
"This delayed type-error detection [as present in Smalltalk or Python] was considered unacceptable for C++."
"However, the most fundamenta
Re: (Score:2)
First, what you young bucks like to call 'duck typing', as cutesy as that sounds, the computing science world calls 'dynamic dispatch'. And it's hardly a new concept (see Smalltalk for a classic example). But, hey, what's old is new and shiny again, right?
No. Dynamic dispatch is what for example virtual methods (or multimethods) do, where which version of the code gets called depends on the types of the arguments. Duck typing is where instead of you telling the compiler what types of arguments are allowed, it either figures it out entirely on its own (ocaml, I think) or just checks at runtime instead (dynamic languages).
Re: (Score:2)
Dynamic dispatch is what for example virtual methods (or multimethods) do, where which version of the code gets called depends on the types of the arguments.
Uh, no. That's just multimethod dispatch. Dynamic dispatch is what makes polymorphism possible. Specifically, it's the binding of a method call to an object at runtime (for example, in C++, this is done with vtables). But, you are correct, in that I wasn't being precise enough (see below).
Duck typing is where instead of you telling the compiler what
Re: (Score:2)
First, 'duck typing' is actually a reasonably-standard term.
Only since Python and particularly Ruby fans started using it as a way to market a feature in their pet language (dynamic typing coupled with dynamic dispatch) that's been available in existing languages for *many* years. It's a marketing term, nothing more. It adds nothing to the actual discussion, other than to sound all neat and cutsey.
I would define it as "the operations your object supports are not defined a priori".
And I would define it as
Re: (Score:3, Insightful)
Only since Python and particularly Ruby fans started using it as a way to market a feature in their pet language (dynamic typing coupled with dynamic dispatch) that's been available in existing languages for *many* years. It's a marketing term, nothing more. It adds nothing to the actual discussion, other than to sound all neat and cutsey.
Standardized terminology adds quite a lot to any discussion.
And I would define it as dynamic typing and binding. Nothing more. The language determines, at run time, how to bind a method call to an object. It's just that simple.
What do you call what Ocaml does?
Templates, on the other hand, are realized at compile time.
C++ templates are a turing-complete functional programming language, and are executed by the compiler. What you think of as "compile time" is the same as "runtime" for the templates.
What I should've said is that duck typing == dynamic dispatch + dynamic typing. Either way, it's hardly a new idea. And it's an idea that does *not* fit in a language that's meant to be strongly, statically typed (eg, C++).
The principle of duck typing says that you shouldn't care what type of object you have - just whether or not you can do the required action with your object. [voidspace.org.uk]
CeePlusPlus: Templates can create compile-time polymorphism via DuckTyping (a [c2.com]
Re: (Score:2)
"compile-time duck typing" is, by definition, a contradiction.
Not if compilation involves evaluating a Turing-complete language. In that case, "compile time" is also the run time for the language that is evaluated during compilation. Compiling lisp code that uses macros also involves running those macros. Likewise, compiling C++ code that uses templates involves running those templates; compile time is also run time. Dispatch that happens when these templates are evaluated is as much duck typing as the dispatch that occurs during the evaluation of a Python program. Ju
No need to dramatize (Score:5, Interesting)
I've seen a lot of people dramatize about concepts being removed from C++0x.
Really, it's no big deal. There are alternative solutions, like some based on SFINAE -- that has now been extended to arbitrary expressions --, that provide almost the same feature set, the same quality in error messages, and are not much harder or more verbose to write or use.
Actually, getting rid of concepts was probably the best solution for C++0x, since they were a lot of work to implement on top of not being that well polished, not integrating that well with the rest (concepts are not types, nor are they templates, they're a whole new category of things) which would probably have led to different categories of compliance to the new standard.
This even gives a new chance to more vital features, such as polymorphic lambdas (understand lambdas were the types of the arguments is not given and which thus exhibit parametric polymorphism), to now being reconsidered.
Re:BIG need to dramatize (Score:5, Interesting)
It is a big deal. The two most important things concepts were going to do was make generic programming in C++ (1) explicit and (2) accessible.
Currently, generic programming in C++ is supported through a number of template meta-programming patterns and practices, most of which exist as Boost tribal knowledge - hail King Dave!* It is implicit in many library designs, but there is nothing enforcing it at the language level. If you're not familiar with the concepts of generic programming (pun intended), it's easy to mistake what's going on in the standard libraries as something else. This is especially true if your primary use of the STL is to have polymorphic container classes - you might just design a generic extension to another language that completely misses the point of generic programming (see Java Generics).
At a more fundamental level, a lot of the power in generic programming comes from the specializations that are possible when you meet type requirements. Right now, there is no way, outside the documentation, to state requirements and possible specializations. Making this explicit in the language makes it clear to the library user what the requirements are and what specializations are available.
This leads into the accessibility problem. Generic Programming using template meta-programming is difficult. To use it, you have to understand both the template system and generic programming. The former is defined in the standard, but the latter, as mentioned above, is tribal knowledge. By making generic programming explicit in the language, it immediately becomes accessible to a large number of developers who didn't have the time, patience, or fortitude (dealing with the Boost mailing list requires a large supply of this) to become proficient with template-based generic programming.
As an analogy: consider object-oriented programming in C. Prior to (and even after) C++, lots of OO code was been developed in C. But, each object system was different and based on local best-practices. C++ (and Objective-C) took those practices and codified them into a language extension. As soon as that occurred, one method for OO was standardized. Developers no longer had to implement their own object systems and adhere to documented (but not language enforced) policies. And, with a standard set of rules around this flavor of OO, many other developers felt comfortable jumping in the the fray.
Concepts in C++ should have had the same effect for Generic Programming in C++ that C++ had for Object Oriented Programming in C. The should have democratized generic programming and brought forth a renaissance in C++ library design. Instead, petty politics killed the most exciting change to C-like languages in years.
-Chris
*(Dave - I mean that in the nicest sense... you've done a great job with Boost (oh, we need to jam again, too)).
Re: (Score:2)
Concepts in C++ should have had the same effect for Generic Programming in C++ that C++ had for Object Oriented Programming in C. The should have democratized generic programming and brought forth a renaissance in C++ library design. Instead, petty politics killed the most exciting change to C-like languages in years.
Given "Things could have been much worse. In particular, we could have made the seriously flawed "concepts" part of the standard." and "By building directly on the pre-Frankfurt concepts and applying modifications along the lines I suggested in "simplifying the use of concepts" we could have had something acceptable (IMO) within months, but that will not happen now. Instead, we must re-evaluate the basics of concepts and rebuild more or less from scratch (relying on the experience gained so far)â"and e
Re: (Score:2)
Nice explanation, especially the "OOP in C" analogy. Thanks.
Re: (Score:2)
It's only a big deal to certain programming groups and applications. The programming I do cannot use templates so generic programming is useless to me and removal of concepts is not a big deal at all.
Re: (Score:3, Insightful)
I think you're overstating things a bit. It's certainly true that Concepts would have been an improvement, and would have made life a whole lot easier for a whole lot of people -- but let's fa
Re: (Score:2)
Actually, it would seem that the is an implementation, a fork of gcc. Well.
Uncluttered article (print = easy to read) (Score:5, Informative)
operator= versus operator== (Score:3, Insightful)
Uncluttered article [devx.com], without any extra crap and multiple pages. Printable == readable.
There fixed that for you.
You know, this tends to bug me a bit...
I mean, yeah, here we are talking about C++ in which "=" means assignment and "==" means an equality test... But the world at large is not governed by these definitions. An equation like "y = 3*x + 4" establishes a relationship in which the two sides of the equation are equal.
If you want to apply the meanings of C operators to English text, then really neither meaning is correct:
"Printable = Readable" - means "Henceforth, until further notice, 'Printable' will have t
Dynamic allocation and data types. (Score:2)
I believe some features that might help C++ is automatic memory allocation (where objects are automatically resized and freed when they go out of scope), and dynamic types (which automatically convert according to some rules based on the context they are used in), basically to give it the same effects as Ruby. This would be optional and avialable alongside present manual systems. It would be an interesting concept rather than just hardcoding this, instead allow it to be implemented on top of some API, sort
Re: (Score:2)
I believe some features that might help C++ is automatic memory allocation (where objects are automatically resized and freed when they go out of scope
Even C had that.
You mean smart pointers? About 10 minutes work to implement... and anyone who's used C++ probably has one in their arsenal somewhere.. not that I'd want them except where they can do some good.. too much overhead for general use.
C had typing rules too. So does C++.
henever an object goes out of scope or something is stored into it, a callback
Concepts aren't enough! (Score:5, Funny)
Can't we just skip "concepts", and move straightaway to "meta-concepts"? After all, a "concept" is just a concept itself, so with meta-concepts we'll be able to define "concepts" recursively. Which doesn't sound like a win, until you realize then you can redefine concepts to fit your own idiosyncratic needs. Like how in my code, the first thing I always do is overload "+" to mean "*", and vice versa. I've always liked them the other way around, not sure why. Anyway, back on point: Concepts by itself is like the 4-blade razor, a lame, stupid half-measure. The real prize, the 360-dunk-off-the-free-throw-line, is 5 blades on a razor. I move we skip "concepts" and go for the big win. Those effeminate Python dorks will have no answer to this, they'll be stunned to see just how inferior they really are. Who's with me on this?
Broader point: I'm sick and tired of these language designers not giving us enough features. For the last 20 years I've been waiting for a language that will allow me to redefine keywords. If that too much to ask? What if I don't happen to like "for", or "while", or "return"? Do you people lack vision, or competence, or both? Second thing on my must-have list is a pre-pre-processor. I'm tired of writing all these header files all the time. I want a way to generate them programmatically, at compile time. A small embedded scripting language would do fine, just make sure it has templates and operator overloading and multiple inheritance, so I can stretch my legs and get comfy with it. Come on people, start earning your paychecks and get some of this stuff done!
Re:Concepts aren't enough! (Score:5, Insightful)
All that you want exists already, no need to wait 20 years - in fact, it was there already when you've started waiting! It's called Common Lisp.
It's the only language I know of where you can use its macro facility (reader macros, to be specific) to fully implement another language with arbitrary complex syntax. In other words, a program written in any textual language can be a Common Lisp program if you insert a corresponding CL reader macro definition at the beginning of the code.
Come to think of it, maybe the fact that it hasn't taken over the world yet has something to do with that...
Re: (Score:3, Informative)
Broader point: I'm sick and tired of these language designers not giving us enough features. For the last 20 years I've been waiting for a language that will allow me to redefine keywords. If that too much to ask? What if I don't happen to like "for", or "while", or "return"?
Unless my memory fails me, SNOBOL4 could do this 30 years ago.
Re: (Score:2)
Second thing on my must-have list is a pre-pre-processor. I'm tired of writing all these header files all the time. I want a way to generate them programmatically, at compile time.
That would actually be kinda cool. Have something that will take your file and pull out function declarations, pull out the public parts of your class definitions, and rewrite your classes to use the pimpl idiom to hide the private parts properly. It'd also be good to have it get rid of slicing problems, but first you'd have to be able to overload the "." operator and determine the base classes of your template parameters.
fnord (snippets) (Score:2)
Concepts and design by contract (Score:2)
Interviewer acted like an ass (Score:5, Insightful)
Papering over the mold (Score:5, Interesting)
It's kind of sad. The C++ committee has taken the general position that the underlying defects of C++ should be papered over by making it possible to write templates that hide the problem. But the hiding never quite works; the mold always seeps through the wallpaper.
The root of the problem is that C and C++ backed into a type system. Originally, C barely had types at all; there were ints and there were floats. Pointers and ints were almost interchangeable. Fields in structures were just offsets, and field names had to be unique across all structures. Gradually, C evolved into a strongly typed language. Sort of. "void *" was introduced as a sort of escape hatch for the type system.
More importantly, there was never a clear distinction made between arrays and pointers. That single design decision is responsible for most of the buffer overflows in the world. We should have had syntax like
int read(int fd, char buf[n]&, size_t n);
to replace the old
int read(int fd, char *buf, size_t n);
which says nothing about the size of the array. Right there is the cause of most buffer overflows - the language doesn't properly support talking about the size of arrays.
Part of the problem there was a major error in the original design of C++ - it didn't have "&" references. So you couldn't talk about a reference to an array; you had to use a pointer to the first element. That pointer has the type of the element, not of an array. Every time you write "char *buf" instead of "char buf[n]&", you're lying to the compiler. The cost of that lie is millions of crashes a day.
Instead of fixing the mess underneath, C++ papered it over. Arrays were wrapped with classes in the Standard Template Library. The STL is a good thing, but it's not good enough to totally replace built-in arrays. So real-world programs remain a mixture of ambiguous built-in arrays, pointers to arrays, and STL arrays.
Then the STL approached iteration as an extension of pointer arithmetic. For "compatibility" with C pointer arithmetic, iterators are not only unchecked, but are not explicitly bound to the collection over which they iterate. So the safety problems of C were carried over into STL arrays. This was another bad decision. Most modern languages approach iteration by providing a "do this to all that stuff" construct used for most common iteration cases. C++ does not.
This is why I'm so critical of the C++ committee. If they'd focused on safety, instead of cool but obscure template features, software would be much better today.
Re: (Score:2)
The Java design team did focus on safety, and look where that got them.
C++ is dangerous because it needs to be. There needs to be one high level language in the world that's like juggling operating chainsaws to code in it, because of the options that gives you.
As the cliche has it, with great power comes great responsibility. C++ is greatly powerful. Using it correctly is a great responsibility.
Re:Papering over the mold (Score:4, Informative)
C++ is dangerous because it needs to be. There needs to be one high level language in the world that's like juggling operating chainsaws to code in it, because of the options that gives you.
Wrong. It's not essential that a language be unsafe to have low level constructs. Ada, Modula I/II/III, Clascal, Object Pascal, Eiffel, and other hard-compiled languages have been much safer than C++, with comparable power. You don't have to go to an interpretive environment to get safety. That's an illusion from Java, which was made interpretive because Sun wanted portability between their SPARC architecture and the competing Wintel systems.
Re: (Score:2)
As any semi-competent C programmer will tell you, that's a feature.
Re: (Score:3, Interesting)
Fortran is a much older language than C++, and it supports variable sized arrays with known sizes in calling functions. It is also one of the few languages that are faster than C on supercomputer number crunching applications.
C++ should be several different languages, that can be compiled and linked together. The source files should have DEFCON levels to show how dangerous / fast they are.
DEFCON 5 - Peace. The most passive Java/Python/Scriptish code imaginable; run-time types; and built-in automatic
Subscript checking is cheap if done right. (Score:3, Informative)
Now, we damn well know that, barring memory corruption or a serious bug in the STL, that this won't overrun the boundaries of the container. So why should i be range-checked ten million times?
It shouldn't. If the compiler, rather than the template library, knew about subscript checking, it could optimize much of it out. Most subscript checks in FOR loops can be hoisted [compilerop...ations.com] out of the loop. Only a single check at loop entry is required, and that may resolve to a constant expression which is always true, e
Re: (Score:3, Informative)
See Optimizing Array Bounds Checks Using Flow Analysis [kfupm.edu.sa]. The Java JVM does some array bounds checking optimization. C and C++ don't, because the language doesn't know how big arrays are. And millions suffer because of that.
The hell with concepts (Score:2)
Fix the damned error messages. Seeing something referring to "std::vector>" when I used "vector" is bad enough. Having it at the end of a 255 character error message? Even worse.
C++0x (Score:4, Funny)
Is that some kinda of filthy ASCII art?
Re:C++0x? (Score:5, Informative)
Re: (Score:2)
ogood, I didn't. :D
C++0x0A (Score:3, Funny)
and we'll all be calling it C++10.
I, for one, will be calling it C++0x0A.
Re: (Score:2)
Its C++012 !!
Re:C++0x? (Score:5, Informative)
It's named in parallel with language-revision names like Fortran77 and C99, that use the base language plus the last two digits of their revision year. When the process started years ago, though, they didn't know what year it would finish, but expected it to be in the 200x decade, hence "0x". So, C++0x. Now that the finalization has slipped past 2009, it's C++1x. When it actually comes out, it will have a year with no 'x', like C++10 or C++11.
Re: (Score:2, Funny)
And here I thought they were just glomming on random bits of language syntax
C++
C++0x
C++0x[]
C++0x[&]
C++*0x[&]
etc.
Re:C++0x? (Score:4, Insightful)
Hehe, it does seem a pretty good symbol of C++'s syntax: bits of syntax that make sense individually turning into a monstrosity when combined.
Re: (Score:2)
What the hell? Do I have to RTFA to find out what C++0x is supposed to mean?
If you don't know what it means, then most likely TFA is of no interest or concern to you, anyway.
Re: (Score:2)
Yeah... which is why I didn't want to read it. I only R'dTFS in the curious hope that it would explain what C++0x meant, and it didn't. Hence my frustration...
meh, it doesn't really matter.
Re: (Score:2)
That was a really optimistic placeholder. I can hardly wait for C++21XX to come out! Hopefully it won't be just the final version of C++0x. *wink*
Re: (Score:3, Insightful)
There are plenty of features that I would say are a lot more important than a GUI framework. A standard way to convert C style FILE pointers into an iostream would be a great feature, one that se
Re:The feature C++ REALLY needs. (Score:5, Insightful)
What on earth does a GUI have to do with a language? A GUI belongs in the C++ specification about as much as Java belongs in the kernel.
Each has its place and is used when necessary and shouldn't be forced into a place it doesn't belong for convenience.
Re: (Score:2)
There's a trend towards language platforms, rather than merely languages, which has some pros and cons. I do think that, for example, it'd be nice if C++ had network sockets in the standard library. Yes, it's strictly speaking an OS feature, but it's close enough to standardized that you can provide a portable abstraction layer in the standard library, which would simplify a lot of things. I agree, though, that a GUI is probably not really in that category.
Re: (Score:2)
If any one feature could ensure the continuation of C++ as a language it would be a standardized GUI library.
That would be OpenGL..
Re: (Score:2)
Nothing will work on 100% of platforms. For platforms that have no multithreading support, the code should just enter an error state (or throw an exception) if an attempt to spawn a new thread is made. For platforms that have unusual thread models...too bad, find a way to make those models fit into what the C++ standard calls for, or just don't support that par
Re: (Score:2)
You might as well have made the same argument about a standardize iostreams library -- after all, what about platforms that use record based IO?
Each line of a text file is a record. In most popular operating systems for workstations and servers, the record separator '\n' becomes a fixed sequence of bytes when it is written to a text file (e.g. {0x0D, 0x0A} on Windows or {0x0A} on *Linux, *BSD, or Mac OS X or {0x0D} on ProDOS or classic Mac OS). In others, each record starts with a length in bytes (e.g. non-stream text files in VMS or STR# resources in classic Mac OS). Or are you talking about systems where all records of all files are fixed-length?
Re: (Score:2)
What about binary files?
CR/LF doesn't separate binary file records on Win/*nix/OSX.
z/OS does have records in binary files though.
Re: (Score:2, Informative)
Qt 4.5 has been released LGPL. As long as you link to the Qt's dynamic libraries, you can completely close the rest of your app. Qt has become the standard cross-platform GUI framework for C++.
Re: (Score:2)
Then they should have released it under BSD.
Re: (Score:2)
If C++ had a set of GUI libraries that were part of the standard and could be counted on to be in every compiler... Hate to bust your bubble there sonny, but the new C++ specification has ALL SORTS of crap that won't translate to a lot of platforms. For instance, multithreading will be built into the language... but what about something like DOS where there is no threads? Or something that uses bazaar threading mechanisms like protothreads/contiki?
What about the Altair 8800? We have to make sure the new C++ spec supports it too!
Re: (Score:2)
Your DOS C++ runtime would need to support threads. I imagine you'd have to write a scheduler that ran them sequentially rather than concurrently. Your performance wouldn't be as good as it would be on a multitasking OS, but that's sort of the point.
At any rate, it doesn't mean that you can't implement the language, it just means that the language can't teach your OS new tricks.
Re: (Score:2)
DOS supports threads, it's just limited to 1.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Plus, if people wanted that then themes for various programs (and the OS itself) wouldn't be so popular.
Re:Maybe the vendors don't want C++... (Score:4, Informative)
Do you realise that most of the guts of Windows is actually written in C++? And that the secretary of the C++ Standards Committe, Herb Sutter, works for Microsoft?
Are you even a C++ developer at all?
Re: (Score:2)
Re: (Score:2, Interesting)
I would be willing to bet that some vendors that make more than one language are probably not too crazy about doing more with an open language like C++. Not that I would make any association with a large software vendor founded in the 1970s that leveraged a pretty good BASIC interpreter into operating system and tools dominance... but
Yeah, Microsoft is so uninterested in C++ that for the Visual C++ 2010 release that they've added in a whole bunch of new features including partial support for this new standard.
Re: (Score:2)
Yet they released Visual Studio 2008 with a showstopper bug that stopped large C++ projects being compiled (it barfed about being unable to read the pdb file halfway through, then just gave up).
They've made it that unless you #define a load of stuff to switch the crap off or start using proprietary Windows extensions none of your code will compile without warnings.
They deprecated huge chunks of both the C and C++ standards without asking any of the standards committees.
Oh, and they *still* haven't caught up
Re: (Score:3, Insightful)
as it is, I think C++ is pretty much dead as it is, and its' probably going to have to be up to gcc to just grab the bull by the horns and implement new features by fiat and create a defacto standard.
Well, that's how it used to be - the standards committee generally checks what all the major implementations implement that isn't specified by the standard, and then try to get the common non-standard parts into the next standard. Basically - see what the industry is doing, and if they all seem to agree then standardise it.
Re:Maybe the vendors don't want C++... (Score:5, Insightful)
C++ is far from dead in all piece of code that need performances. Intel released a C++ library called TBB to use multi-core architecture a few years ago. They do not believe it is dead. Parallel programming framework such as cilk stoped using C to use C++ to gain templates.
Don't get me wrong, for most task people don't care about the performance provided by a low level language and thus don't need it. It is even harmful to use C++ if you are not going to do it properly.
C++: even iostream is doing it wrong (Score:4, Insightful)
It is even harmful to use C++ if you are not going to do it properly.
For example:
Re: (Score:2)
I wrote homebrew code for the nintendo ds. I'll make some test to see how it changes. I definitely liked using C++ there to change data structure easily. I started with generalist STL structures and changed the slowest for more dedicated/optimized ones.
I do not recall wheter I used iostream or not (probably not)
Re: (Score:2, Informative)
Re: (Score:3, Funny)
Stupid name, it should be
C+++=1
or is equiv
C+=2
C++0X is a syntax error!
Actually, the two forms aren't equivalent.
I mean, I was pretty annoyed when they said, "Hey, here's C++! We added that increment operator to show you that we made C better!" But, then, wouldn't you know it... Yeah, they made a better C, but what they actually gave to us was the same old C, as it was before they improved it. Later on I kept checking back to see if C++ really was substantially different from plain old C: and it was, but each time I looked at C++, the result was something different from wh