Interview With Bjarne Stroustrup 502
koval writes "artima.com has published an initial portion of interview with Bjarne Stroustrup.
The scope of first part is mostly about improving the style of C++ programming and getting maximum from a language."
Improvements? (Score:2, Insightful)
Re:Improvements? (Score:2)
Re:Improvements? (Score:2)
Re:Improvements? (Score:2)
Is that so hard? Is it too much to ask?
I mean, not only would it save bugs, it would make C++ 10000000 times easier to program in.
Re:Improvements? (Score:2)
Re:Improvements? (Score:2)
std::vector already does this. How about using it?
Re:Improvements? (Score:2)
I don't think it does. STL does very little checking in general, because it has to be blazingly fast in order to not be ignored by C++ mainstream (for which performance is everything, never mind the development costs).
Besides, a lot of people who program C++ have to program in environments ( == old compilers) where such pansy features as STL, RTTI or exceptions are not available.
Re:Improvements? (Score:3, Funny)
Am I the first to think that maybe "STD vector" is possibly the worst name for a data type?
Re:Improvements? (Score:4, Funny)
try:
Re:Improvements? (Score:2)
Well, see the first reply to your post -- the STL itsn't what any is used to from C, but it is consistent once you've taken teh trouble to learn it --, and, please recall that writing safe, non-exploitable code is never going to be easy or automatic.
No offense, but if your primary criterion is "what's easiest" you probably shouldn't be writing high-risk code that processes arbitrary-length buffers which could be prone to buffer overflow. Limit
Re:Improvements? (Score:2)
Yeah!! And if seatbelts are such a good idea in cars, how come they weren't in the first Model T?? HuH??
And if small cell phones are such a good idea, how come the first cell phones were BIG?? Well, mister smarty pants?
And if journalling filesystems are so fucking hot, how come linux first came out with non-journalling filesystems!!!!? Huh
And if Swing is such
Re:Improvements? (Score:2)
Maybe because they weren't invented yet?
Maybe because the original C++ compilers compiled to C (cfront, ugh), and so templates were very inefficient at the time?
C++ has evolved over the years.
New things get added.
Python only recently got generators.
LISP has been around since the 1950's, but it didn't get CLOS until sometime in the 1980's.
Just because something isn't in the
Re:Improvements? (Score:2)
Maybe instead of asking your toolset to design for you - security is a design process, not a patch process, which is why it works for qmail but not for sendmail - you sh
Scott Meyers (Score:3, Funny)
Re:Scott Meyers (Score:3, Funny)
Cute, but meaningless. Any language has features that are easily overused or abused. One of the things a programming teacher has to do with any beginning class is explain what you shouldn't do. Or at least he should be spending time on that.
C++ has problems, yes; pretty unavoidable since it was the first real object oriented language. Java has a different set of problems since it w
Re:Scott Meyers (Score:2)
Huh? What about Simula, the first object oriented language?
Re:Scott Meyers (Score:2, Funny)
Re:Scott Meyers (Score:2)
Or what about Common Lisp, the first object-oriented language with a published standard?
It doesn't make much sense to say that any particular language was "the first real object-oriented language" because people have different religious beliefs as to what constitutes a "real" object-oriented language.
People get into hideous flamewars about that word "real" when applied to categories like
Re:Scott Meyers (Score:2)
Re:Scott Meyers (Score:2)
Re:Scott Meyers (Score:3, Interesting)
C++ has problems, yes; pretty unavoidable since it was the first real object oriented language.
This comment alone summarizes the posters knowledge of programming languages. For a better understanding of C++, check it out on the Computer Languages History [levenez.com] website
My reply: Cute, but it unfortunately does mean something. C++ has more features that are so easily misused (not abused), that Scott Meyers wrote 3 large volumes on the subject. Other languages have similar featuers, but not in near the quantity o
Re:Scott Meyers (Score:2)
It is definitely not. Functional programming languages work with "values" not "objects". Objects (with having a state) and Functional languages are mutually exclussive. All attempts to introduce objects into functional programming languages have failed.
Re:Scott Meyers (Score:2)
This comment alone summarizes the posters[sic] knowledge of programming languages. :-)
Re:Scott Meyers (Score:2)
To bolster the point, there are a fair number of other authors which have written such series, and some of them arguably more difficult than the effective trio. Notably, Dewhurst's C++ Gotchas and Sutter's Exceptional/More Exceptional C++ are similar vein, similar-or-greater difficulty issues. None quite so well written as Meyers', though.
Re:Scott Meyers (Score:5, Funny)
Let me guess... you work as a prior art researcher for the USPTO.
Re:Scott Meyers (Score:2)
Check out Ruby, Python, Scheme, OCaml, Smalltalk, Haskell, Objective-C [I mention this last one because a competent programmer in either C or C++ can pick up the language in 20 minutes...], or some other language you've thought about but never made time to learn. Any and all of these languages will change the way you program, and the way you think about pr
Re:Scott Meyers (Score:3, Insightful)
It's not exactly clear to me whether I'm taking a joke on as if it were serious. That said, this is a genuine sentiment with many, so I feel my rebuttal to be germane to them if not nessecarily to you.
The problem with language is that its domain is inherently difficult. The more expressive a language is, the deeper and more powerful structures it can express. Conversely, because ma
Yes! (Score:4, Funny)
Probably fake but . . . (Score:4, Funny)
Interviewer: Well, it's been a few years since you changed the world of software design, how does it feel, looking back?
Stroustrup: Actually, I was thinking about those days, just before you arrived. Do you remember? Everyone was writing 'C' and, the trouble was, they were pretty damn good at it. Universities got pretty good at teaching it, too. They were turning out competent - I stress the word 'competent' - graduates at a phenomenal rate. That's what caused the problem.
Interviewer: problem?
Stroustrup: Yes, problem. Remember when everyone wrote Cobol?
Interviewer: Of course, I did too
Stroustrup: Well, in the beginning, these guys were like demi-gods. Their salaries were high, and they were treated like royalty.
Interviewer: Those were the days, eh?
Stroustrup: Right. So what happened? IBM got sick of it, and invested millions in training programmers, till they were a dime a dozen.
Interviewer: That's why I got out. Salaries dropped within a year, to the point where being a journalist actually paid better.
Stroustrup: Exactly. Well, the same happened with 'C' programmers.
Interviewer: I see, but what's the point?
Stroustrup: Well, one day, when I was sitting in my office, I thought of this little scheme, which would redress the balance a little. I thought 'I wonder what would happen, if there were a language so complicated, so difficult to learn, that nobody would ever be able to swamp the market with programmers? Actually, I got some of the ideas from X10, you know, X windows. That was such a bitch of a graphics system, that it only just ran on those Sun 3/60 things. They had all the ingredients for what I wanted. A really ridiculously complex syntax, obscure functions, and pseudo-OO structure. Even now, nobody writes raw X-windows code. Motif is the only way to go if you want to retain your sanity.
[NJW Comment: That explains everything. Most of my thesis work was in raw X-windows. :)]
Interviewer: You're kidding...?
Stroustrup: Not a bit of it. In fact, there was another problem. Unix was written in 'C', which meant that any 'C' programmer could very easily become a systems programmer. Remember what a mainframe systems programmer used to earn?
Interviewer: You bet I do, that's what I used to do.
Stroustrup: OK, so this new language had to divorce itself from Unix, by hiding all the system calls that bound the two together so nicely. This would enable guys who only knew about DOS to earn a decent living too.
Interviewer: I don't believe you said that...
Stroustrup: Well, it's been long enough, now, and I believe most people have figured out for themselves that C++ is a waste of time but, I must say, it's taken them a lot longer than I thought it would.
Interviewer: So how exactly did you do it?
Stroustrup: It was only supposed to be a joke, I never thought people would take the book seriously. Anyone with half a brain can see that object-oriented programming is counter-intuitive, illogical and inefficient.
Interviewer: What?
Stroustrup: And as for 're-useable code' - when did you ever hear of a company re-using its code?
Interviewer: Well, never, actually, but...
Stroustrup: There you are then. Mind you, a few tried, in the early days. There was this Oregon company - Mentor Graphics, I think they were called - really caught a cold trying to rewrite everything in C++ in about '90 or '91. I felt sorry for them really, but I thought people would learn from their mistakes.
Interviewer: Obviously, they didn't?
Stroustrup:
Christ, this hasn't died yet? (Score:2)
It's not "probably" fake. It's complete crap. He debunked this in his FAQ a couple days after the first troll posted it.
Re:Probably fake but . . . (Score:2)
Re:Probably fake but . . . (Score:2)
Or even move on to Objective-C, which is pretty much parallel to C++ in that it can use plain-vanilla C but Objective-C uses a Smalltalk-type messaging system for object calls. The cool thing is that the latest Objective-C compilers can also use C++ code so that you don't need to re-write old code.
Basically Objective-C is C with objects, but done in such a way that it doesn't feel like the object-oriented stuff is
Re:Probably fake but . . . (Score:2)
Check out Objective-C for a better Object-Oriented C environment. Unlike C++, Objective-C is fully compatible with standard C.
Compilers (Score:4, Interesting)
Re:Compilers (Score:2)
If you don't want to spend a lot of money, and you don't want to stop using the compiler that you have, I highly recommend The Comeau Compiler [comeaucomputing.com]. It is a compiler front end derived from the EDG codebase, and only costs you $50. The big downside is that your c
Re:Compilers (Score:5, Interesting)
Re:Compilers (Score:4, Interesting)
I believe that MS VC++ 7.0 (or whatever it's marketed under now) and G++ are the most compliant of the bunch. IBM's compiler may be standard, but their linker is anything but -- thanks to it we can't use dbx or gdb on our code base (both simply core either while loading the core image or when you do a "where"; IBM's dbx occasionally works but never gives proper symbol names and setting break points is impossible). I don't have any experience w/ Intel's compiler so I can't say there. HP's compiler is abysmal.
One interesting place to look at compatibility is the Boost [boost.org] library -- Boost is a rather large C++ library being developed by some of the big names in C++ that may wind up in the next standard -- and how well it compiles on various platforms and compilers. Check out the compiler status [boost.org] page. It's certainly not a definitive test of what is and is not standard, but it's a data point.
You're certainly correct in that C++ compilers and their STL libraries have come very far in the past couple of years. One of the worst (Microsoft) is now one of the best -- largely due to them hiring a project lead that's a STL advocate.
Re:Compilers (Score:2)
G++ is, AFAIK, actually the least compliant of the compilers I mentioned in that list, which is in i
Re:Compilers (Score:2)
export seems to remain a mystery to everyone besides Comeau
More accurately, the only implementation of "export" to date is by the Edison Design Group. Comeau uses the EDG frontend, as do some others (including Intel, I believe, though I'm not sure).
The EDG members have had some scathing things to say about "export" with the benefit of experience. It was horrendously complicated, and it doesn't (and arguably can't) really achieve any of the goals that motivated its invention in the first place.
There'
Re:Compilers (Score:2)
This makes 0 sense. If someone is worried about C++ portability, they will a) test on multiple compilers, and b) not use super-new features (though AFAIK everything except export is supported by every major compiler). Why would you want a compiler that supported such otherwise-not-supported-by-anyone feature
Re:Borland!! (Score:2)
Re:Compilers (Score:3, Interesting)
This isn't the only such article, but it's the only one I'm finding on a brief search; IIRC, I think I've also seen similar stances from Meyers and Dewhurst. Not certain, though, 'cause I can't seem to find them (yay 30 second searches.)
Confusion (not a Slashdot interview!) (Score:2, Informative)
You cannot organize this (Score:2, Insightful)
Re:You cannot organize this (Score:2)
Re:You cannot organize this (Score:2)
I'm really picky about variable names.. in the end if you can stay consistent and make good decisions on variable names it ultimately makes the biggest difference as to the readability of your code
Hungarian notation (Score:2)
It depends what you consider "real" Hungarian used "reasonably".
The idea of annotating variables to show certain fundamental properties has merit. For example, using "m_" or something similar to distinguish member variables can be useful to avoid name-clashes or developers resorting to not-quite-pseudonyms. Using "n" as a prefix consistently to indicate that the variable is a count of something can be useful.
Notic
Re:You cannot organize this (Score:2)
You can write bad code in any language. I don't see how your statement and the prvious sentence can both be true unless you equate it to some individuals are capable of programming and some are not, but, at some point in time, we had to be "told" how to write programs which kind of invalidates your statement.
The other point is, there are a number of rules that you can use that if abided by will have fewer chances o
Re:You cannot organize this (Score:2)
Not exactly sure what you are saying here. But by when I say how to program, I am speaking of style. Which is what the interview is about.
The other point is, there are a number of rules that you
Re:You cannot organize this (Score:2)
Sadly, the original idea behind Hungarian notation seems to have been lost to the ages. The idea behind it was that the C language's weak typing made it quite easy to accidently use the wrong type, particularly when doing parameter passing. The idea was to encode the type into parameters and variables, such that it would become blantantly obvious when one was making such a
It's an education issue (Score:4, Insightful)
However, you very much can improve how a language is used by telling people how to program with it. The single biggest problem C++ has isn't dangerous pointers, or ugly template syntax, or lack of a garbage collector, it's lack of good programmer education. C++ is a power tool, and requires skill to use. When most of the C++ textbooks in the world are teaching decade-old crap themselves, and most of the university professors don't know their own subject, it's not too surprising.
I can sympathise a lot with Stroustrup here. His tool is unjustly battered by the ignorant more than perhaps any other mainstream language today, and it creates a self-fulfilling prophecy: most people who learn C++ learn it badly, and write code with buffer overflows and other kindergarten mistakes. Others pick up on this, and learn from people who themselves learned badly, and write more code with kindergarten mistakes. It's about time the C++ programming industry reached High School, but few ever seem to, and when they do, they aren't valued as much as they should be.
From the article (Score:3, Insightful)
Thank You! This is the number one java peeve. Every time I just want to make a structure I've got to make a whole class. That's a whole file. That's a whole lot of extra code. In C/C++ I can make an equivalent struct in a few lines.
This is why I like python so much. I can do all the object-orientedness I want and all the proceduralness I want and they work together perfect. And everything pops out into super efficient C code and then into executable with my gcc. And if I want it cross platform I can just use jython and get workin
Re:From the article (Score:2)
Re:From the article (Score:2, Informative)
Re:From the article (Score:2)
public class X{ public int a; public int b }
X z = new X();
z.a = 1;
z.b = 1;
is it really THAT much different from
typedef struct { int a; int b; } X
X *z = ( *X ) malloc( sizeof( *X ) );
z->a = 1;
z->b = 2;
Complaining that you can't do the equiv of struct{
Re:From the article (Score:2)
Re:From the article (Score:4, Insightful)
Re:magic programmer education (Score:3, Interesting)
Just use an inner class (Score:2)
Re:From the article (Score:3, Informative)
But that's a story for another day...
Cheers,
J
Re:From the article (Score:2)
You could just make an inner class with only data members. It would probably take you two more lines than it would to make a struct. You can make it private or make it public and use it in other classes.
But really, making a whole file isn't that hard either - you copy some other file and then change the innards. Done. You don't have to write get/set, you can just have accessible data members.
-andy
Re:From the article (Score:2)
Re:From the article (Score:5, Insightful)
This is an excellent template for recognizing language bigotry. Try this as a template for recognizing language agnosticism:
"I can enumerate dozens of less-than-perfect features in my favorite language."
Until you understand the weaknesses as well as the strengths of your favorite language, you either haven't explored it fully or you don't know enough languages well enough to have a basis for comparison. (C|C++|Java|Perl|AWK|Python|COBOL|RPG|Fortran|BAS
Weird guy (Score:3, Informative)
Well, as one may expect, someone asked about java. He got very biligerant and brief about it. "C++ is supported on N many more platforms than java." (Can't remember N). It was also the last question too, which left that "weird" sense in my mind's eye.
Re:Weird guy (Score:2, Insightful)
He's certainly no weirder than most other programmers I know, if you make allowances for him being Danish
Re:Weird guy (Score:2)
Invariant/struct discussions and binary compatibil (Score:3, Interesting)
Lean classes and supporting library (Score:2)
I would disagree with that statement. While I can understand the concern (less dependence on data structures in the 50 methods), this creates an API that sucks. As a developer you want to have all helper functions for a data type at a
Re:Lean classes and supporting library (Score:2)
Also keep in mind that nothing says that your Date functions have to be "spread all over the place". Indeed, it is quite logical to have calendar-type manipulations in one place, standard temporal operations in another, and formatting stuff idealling in a third place. Amazingly, this is actually what happens in the case of Java, despite the fact that it uses classes for all this stuff.
Why separation is a good thing (Score:2)
Why? Adding all the supporting functions into the type itself just clutters the interface and makes it hard to find the "heart" of what the class does. As mentioned in the interview, it also removes much of the benefit of abstraction and encapsulation.
That argument doesn't generalise, though. How do you find
C++ Programming Language (Score:2, Funny)
The real trouble with C++ (Score:4, Insightful)
We went through this with Wirth. Wirth devised Pascal, which had reasonable data structures, although not objects, terrible I/O, and strings that only worked if they were short. He then insisted that it shouldn't change. From this came a whole range of incompatible Pascal dialects (Turbo Pascal, Object Pascal, Clascal...), and some successor languages (Modula I, II, III). Modula III was actually rather good, but nobody except some researchers at DEC SRL (now an empty building in Palo Alto) used it. Two decades later, few use Pascal or its derivatives, and Wirth is a forgotten and bitter man in Switzerland.
This cycle is being repeated with C++. The first version of C++, before templates and the STL, was terrible. Without templates, horrible schemes involving huge defines were used to make generic objects. Strostrup used to have great hostility to run-time type information, which led to unchecked downcasts all over the place.
Round 2 of C++ came late, and it took a long time before the compilers did templates. Then came the STL, which is wierd and unsafe, although useful.
C has little abstraction and little safety. Java has both abstraction and safety. C++ has abstraction without safety, a terrible combination. The basic problem with both C and C++ is that the language requires the programmer to obsess on storage allocation and release, yet gives no assistance in this. Attempts to encapsulate storage allocation in C++ fail miserably (look at the history of auto_ptr). Attempts have been made to fix the language by adding another layer of rote ritual ("patterns") on top of it, but compilers can't check that, so it doesn't reduce bugs.
Another area of trouble comes from the history of C++ as a preprocessor for C. Bell Labs had a tradition that "you can't change the linker". (This is probably because the original UNIX linker was written in assembler and had few comments.) Because of this, some tasks that should be deferred to link time (such as building vtables) are done at compile time.
The price paid for not changing the linker is substantial. Private function members appear in header files so that vtables can be built at compile time. That's the real reason, despite what you read. If it weren't for that, you could have much stronger separation between declaration and implementation. And you wouldn't be recompiling class users just because the class implementation changed. Ada and Modula got this right, but C++ got it wrong. And Strostrup refuses to fix it.
Yes, there are "patterns" for working around this. But they're workarounds. The programmer is doing the compiler's job. This imposes a cost on every programmer and distorts C++ programs.
Strostrup still insists there's nothing really wrong with his language. Read what he's written about the C++200x standards revision cycle. Meanwhile, C++ is being abandoned for Java, C#, C, and scripting languages.
Re:The real trouble with C++ (Score:2)
I guess the poin
Re:The real trouble with C++ (Score:2)
That's more of a Borland problem than a language problem. No single-vendor language has ever gone very far. Even Java and C# are open enough that others can write compilers for them.
Which ADTs? (Score:3, Interesting)
Come on. If you're talking about vectors, lists, sets, queues, stacks, hash_maps, etc., then I think the STL does, via templates, quite a stunning job of encapsulation. Stroustrup's comment in the article concerns wider adoption of the STL as a starting point for more developers, and I challenge stra
C++0x (Score:3, Informative)
I think perhaps there's a misunderstanding in the grandparent post. Stroustrup, and others on the standards committee, are on record as saying that they don't see the need for many language changes. They do, however, propose to make extensive library changes. Their reasoning is simply that there is likely to be more than one sensible way to approach topics such as, say, concurrency and
Not awake yet- (Score:3, Funny)
oooops...
So... (Score:2)
Looking through, I can't believe I didn't see someone else asking it...
C++ in the long term. (Score:3, Interesting)
The discussion of class design has nearly nothing to do with C++. I can use Java to build overly complex towers of inheritance. I can also use it to build poorly defined libraries. One think I *can't* easily do is blow myself (and the underlying OS) up do to a memory allocation problems.
I see C++ remaining for many years to build those "cycle critical" components, which are going to be consumed by languages with a guard over the chainsaw blade. Programmer efficency should always trump speed concerns until you have exhausted *algorithmic* improvement. I don't know how many times I see programmers saying "I'm using C++ for performance" while simultaniously writing something that is going to run in o(n^2) time, when a o(log(n)) algorithm is available. Yes, your C code will run your inefficent algorithm quicker than I would in a protected environment, but if my protected environment allowed me to see the abstraction that runs the fastest algorithm, my code will still be faster for large data sets.
Re:"memory allocation problem" (Score:3, Insightful)
Confirmed: C++'s not very object-oriented (Score:5, Insightful)
The interview is interesting in that it confirms the impression I've had from using and/or struggling to use C++. When I try to do anything object-oriented, specifically anything involving polymorphism, it seems to be fighting me all the way. After some struggling I usually emerge triumphant, but it's almost always a battle.
What Stoustrup seems to be saying is that classes should be treated as a special big deal, and shouldn't be used unless you're sure they're necessary. He seems to be recommending that there be, um, a class of elite programmers who put in the intense work to develop good, usable, well-debugged classes, and that the rank and file should, by all means use those classes but should not aspire to write new ones.
And this is not unreasonable, given the effort of writing classes and getting the storage management right and so forth.
The thing is, it's not a big deal to use classes in a truly object-oriented language. I'm not just talking about Smalltalk. Heck, they're trivial to use in REALbasic.
Well, is that good? It certainly leads to overuse of OOP. To a man with a hammer everything is a nail, and every programming language tends to encourage overuse of the things that it facilitates. Every programming language has a tendency to induce brain-warp.
C++, for better or for worse, does not induce object-oriented brain-warp.
People who try to use OOP in C++ because it's cool or because of some article they read (or some instructor they had) find that C++ punishes such behavior. And Stoustrup is right: when you are programming in C++, OOP should be used sparingly and only when it's needed.
Again, I'm not saying whether that's bad or good. That will depend on the degree to which you think OOP ought to be encouraged. If you think OOP should be just as much a part of a programmer's mental toolbox as iteration, or recursion, then it's not good. If you think OOP was the overhyped IT fad of the nineties, then it's not bad.
What I'm saying is that it has always seemed to me that C++ is not a very object-oriented language, and Stoustrup's remarks seem to me to confirm the objective validity of that observation.
What is OOP? (Score:3, Interesting)
class F {
float a;
public:
F(float a0) : a(a0) { }
template<class X> X operator()(X x) const { return X(a)+x; }
}
is it OOP? It looks like OOP: it has a member variable, a method, a constructor and so on. But actually I'm defining a function closure. In Haskell you coud write an F(a) object as (a+).
My point is this: for many programmers today objects are often a(n awkward) vehicle for computing with closures. This has many payoffs: it gives the ease of functional programming but also potentially provides many performance benefits. I code like this all the time as do hundreds of others. This is how you need to code if you actually want to do anything non-trivial with the STL.
So in some sense I'm an OOP programmer. But in another sense I'm not. I'm not writing my code this way because I want to work with objects - I do it because this is the only way I know to treat a polymorphic function as a first class object in C++. Really I'm a functional programmer forced to use C++. It seems to me that many of Bjarne's remarks are way off the mark for programmers like me. We have to define classes for every damn little thing!
Re:What is OOP? (Score:4, Interesting)
Why is this useful? I do a lot of numerical/engineering work. Say I have a root finding algorithm that throws a bunch of methods at a function in an attempt to find roots. It might first try doing some interval arithmetic to bound the roots and then when it's close enough go in for the kill with a newton solver. So I need to be able to write a polymorphic function that can be evaluated on the types appropriate to these methods (first intervals and then maybe doubles) but also be able to hand it in as an argument to a solver routine (which in this case would be rank-2 polymorphic though people will tell you C++ can't do that!). The above is the only way I know, And the cool thing is that It can also be a partially evaluated function (ie. in the simple example I gave I'm passing in the two argument function + but partially evaluating it by giving one of the arguments 'a'). This is all routine stuff in the functional world and is beginning to be routine in C++, but not yet. It's kinda object oriented but the object oriented frame of mind really is the wrong way to look at it.
Greenspun's rule. Yes, someone said that about some code of mine recently. But I have a response. For one thing the primary function of Greenspun's rule is to provide strokes for Lisp programmers' egos but these are the wrong people! C++ is a typed language and Lisp isn't. This makes a big difference. These methods push C++ more towards typed functional languages like ML or Haskell. Secondly: The example I gave is of a closure, written as (a+) in Haskell. But look where the work is happening: I haven't written any kind of interpreter, the compiler's doing the work. In fact if you take this stuff to its logical conclusion you're not implementing a Lisp interpreter but instead twisting the C++ compiler into a Haskell compiler. And if you don't believe me, here [gatech.edu] is that logical conclusion. If you look closely very little of that code is executed at run time (the lazy lists are), instead that minor mountain of code is directives to the compiler telling it how to behave like a Haskell compiler.
As for performance penalties: yup, they exist. It's the so-called abstraction penalty. I don't really understand why it exists because it takes only simple rewriting rules to eliminate the overhead but compiler writers don't use them. Luckily people like Veldhuizen are writing papers [iu.edu] showing the compiler writers how they should be doing their job.
Read Stroustrup's Design and Evolution of C++ (Score:4, Interesting)
If you hate C++, it's unfair to suggest you read a book on it. But if you have any fondess for C++, or use C++ (even if you dislike it), Design and Evolution of C++ [att.com] is probably worth your time. You learn why C++ is the slightly confusing mess that it is, and why Stroustrup believes it's the only way it could have succeeded. Having a grasp on why C++ is C++ (and not Objective C or Java) can improve your C++ coding abilities. And understanding why behavior you don't like is there can at least help minimize the suffering ("This is stupid, but there really isn't any way to change it.").
C++ is too simple. (Score:3, Funny)
What C++ really needs is more features... LOTS more features. The language is not "rich" enough. C++ should add many other features to its syntax.
- For example, the ability to name identifiers with any character in any character set.
- As C++ is not complicated enough, we need a way to dynamically create syntax. It would work like operator overloading, but much more complicated. And it would be called Syntax Overloading. For example, the code, ("for (" class "in" class ")")() { [insert code here] } would allow you to specify a new type of for loop with your own syntax. The compiler, upon reading this line, would add the new syntax to its language rules. Then, you could type for (className in otherClassName) { some.code.here(); } and it would work as expected.
- The language desperately needs some built-in cryptography functions. For example, the function const unsigned void do_it(const unsigned short void const crypto % arg) takes one parameter, arg, which is encrypted inside a processor register and cannot enter main memory for security reasons.
- More complicated template syntax is needed. For example, suppose you want to create a class that is unknown at compile time... obviously, a way to specify runtime template processing is desperately needed.
- Support for returning multiple return values from a function. For example, the function const unsigned short, const int *, const long long grok_the_file(void) might return three different return values, seperated by commas, as in, return i, j, size; Oh yeah, and you could specify functions that return an unknown number of values using ellipses, as in unsigned short... function_name() or simply
... function_name(). Suppose you want to call a funciton that takes 3 parameters... you could instead pass it one function that returns 3 return values and C++ would know what to do with it.
- C++ needs a reserved word, like please_reconsider_cast, or something, that uses common sense to figure out what the heck you're trying to typecast into what, so that even if the code is faulty, the compiler will figure out what you really mean.
These are all just a drop in the bucket. C++ is obviously too small and simple of a language.Re:What about... (Score:2, Interesting)
I think I'll just clarify that. In four or five years, what changes would you like to see happening to the language, and how realistic it is to be able to achieve those goals in that time period?
Re:What about... (Score:2)
Wrong question. Being that there is no (AFAIK) compiler that even conforms to the existing standards, the only change in the language in the next 4 or 5 years would be to make this happen.
C++ is a neat language to study & learn, but I've found little use for it in the real world. Granted, I'm not a fulltime
Re:What about... (Score:2)
Re:Who is Bjarne Stroustrup? (Score:2, Insightful)
Re:OOP IS FOR PUSSIES (Score:2, Insightful)
For very contorted definition of real men. OOP requires higher degree of abstract thought than assembler, and obviously not everyone can hack it. Assembler, Fortran and Visual Basic are for people whose brain can't handle abstraction, but rather just want to get their hands dirty doing stuff. People who would rather do than think what they are doing. Others take delight in creating abstract architectures and systems that Last.
Obviously many self-proclaimed C++ programmers belon
Re:OOP IS FOR PUSSIES (Score:2)
I'm afraid that assembler IS for real programmers. Why? Because to do anything complex in it is DAMN hard and not only do you have to understand what data structures you require
(the abstraction) but you have to understand how to map them down efficiently in a way the computer architecture can handle. I'm sorry , but writing even complex C++ is like a walk
Re:OOP IS FOR PUSSIES (Score:2, Funny)
Since when did Steve Gibson start posting here as an Anonymous Coward?
Some people use a screwdriver, others use a butter knife. That's the beauty of programming; there are numerous tools and technologies at your disposal that will all achieve the effect (or at the very least, a semblance of the effect) you desire. Business users typically don't know the difference anyway, so it's really a matter of programmer's preference. Pick those you feel most appropriate to your project
How OOP helps reusability. (Score:2)
See, in your assembly language, if you want to add new code, you have to not only write the new code, you have to dig through your Asm to find the little tiny spot where you JSR (or whatever your opcode may be) to the new code.
In my C++/Java, I just subclass that puppy when I write the n
Re:Java ? (Score:2)
"I think Java is kinda nifty."
Best answer you'll get.
Re:Java ? (Score:3, Informative)
Re:Java ? (Score:2)
Re:Why did they need to interview bjarne about tha (Score:2, Insightful)
Being that there is a large codebase out there that breaks either one of these rules I would venture a guess that is why he commented on it. He does not believe that there is a sliver bullet to solving software problems nor does he believe that C++ is one either. It is just a language he designed to solve problems he encountered while programming.
C++
Re:How to improve C++ (Score:2)
"Unlamda - Your Functional Programming Language Nightmares Come True"
http://www.eleves.ens.fr:8080/home/madore/
Re:How to improve C++ (Score:2)
I thought to myself, "Hmm, sounds like this might have potential." So I asked Google, and it pointed me to a quick tutorial. I clicked immediately on "how to write a loop in Unlambda," and was met with the following example code:
```s``sii`ki
``s``s`ks
``s``s`ks``s`k`s`kr
``s`k`si``s`k`s`k
`d````````````.H.e.l.l.o.,.
k
k
`k``s``s`ksk`k.*
I never thought I would find a language more intimidat
Re:Invariants and Design by Contract (Score:2)
No, the kind of invariants he's talking about are already there. The STL is built around a whole host of invariants. All that C++ lacked was a user friendly way of expressing these invariants. Some of the work the Boost [boost.org] folk have done has provided standard libraries for expressing this stuff more clearly, using the language as-is. Nothing wrong with his ways, and nothing need be added.