Ask Bjarne Stroustrup, Inventor of C++
You can learn more about Bjarne Stroutrup here. Even though Bjarne isn't on your nightly news a lot (like never) he deserves (and gets) heavy respect from fellow programmers. If you have a question for Bjarne that he hasn't already answered on his FAQ page, please post it below. If you're a moderator, please moderate others' questions up or down, as deserved, which is just as important as actually asking questions. Tuesday afternoon (U.S. EST) we'll forward 10 selected questions to Bjarne. His answers are scheduled to appear Friday.
Now that the Java hype has cooled off, what is your assessment of its future?
Actually, seeing this brings to mind another 'Interview' with Bjarne that I saw a while back....
Interviewer: Well, it's been a few years since you changed the
world of software design, how does it feel, looking back?
Stroustrup: Actually, I was thinking about those days, just before
you arrived. Do you remember? Everyone was writing 'C'
and, the trouble was, they were pretty damn good at it..
Universities got pretty good at teaching it, too. They were
turning out competent - I stress the word 'competent' -
graduates at a phenomenal rate. That's what caused the
problem..
Interviewer: Problem?
Stroustrup: Yes, problem. Remember when everyone wrote Cobol?
Interviewer: Of course, I did too
Stroustrup: Well, in the beginning, these guys were like
demi-gods. Their salaries were high, and they were treated
like royalty..
Interviewer: Those were the days, eh?
Stroustrup: Right. So what happened? IBM got sick of it, and
invested millions in training programmers, till they were a
dime a dozen..
Interviewer: That's why I got out. Salaries dropped within a year,
to the point where being a journalist actually paid better..
Stroustrup: Exactly. Well, the same happened with 'C' programmers..
Interviewer: I see, but what's the point?
Stroustrup: Well, one day, when I was sitting in my office, I
thought of this little scheme, which would redress the
balance a little. I thought 'I wonder what would happen, if
there were a language so complicated, so difficult to learn,
that nobody would ever be able to swamp the market with
programmers? Actually, I got some of the ideas from X10,
you know, X windows. That was such a bitch of a graphics
system, that it only just ran on those Sun 3/60 things..
They had all the ingredients for what I wanted. A really
ridiculously complex syntax, obscure functions, and
pseudo-OO structure. Even now, nobody writes raw X-windows
code. Motif is the only way to go if you want to retain
your sanity..
Interviewer: You're kidding...?
Stroustrup: Not a bit of it. In fact, there was another problem..
Unix was written in 'C', which meant that any 'C' programmer
could very easily become a systems programmer. Remember
what a mainframe systems programmer used to earn?
Interviewer: You bet I do, that's what I used to do..
Stroustrup: OK, so this new language had to divorce itself from
Unix, by hiding all the system calls that bound the two
together so nicely. This would enable guys who only knew
about DOS to earn a decent living too..
Interviewer: I don't believe you said that....
Stroustrup: Well, it's been long enough, now, and I believe most
people have figured out for themselves that C++ is a waste
of time but, I must say, it's taken them a lot longer than I
thought it would..
Interviewer: So how exactly did you do it?
Stroustrup: It was only supposed to be a joke, I never thought
people would take the book seriously. Anyone with half a
brain can see that object-oriented programming is
counter-intuitive, illogical and inefficient..
Interviewer: What?
Stroustrup: And as for 're-useable code' - when did you ever hear
of a company re-using its code?
Interviewer: Well, never, actually, but....
Stroustrup: There you are then. Mind you, a few tried, in the
early days. There was this Oregon company - Mentor
Graphics, I think they were called - really caught a cold
trying to rewrite everything in C++ in about '90 or '91. I
felt sorry for them really, but I thought people would learn
from their mistakes..
Interviewer: Obviously, they didn't?
Stroustrup: Not in the slightest. Trouble is, most companies
hush-up all their major blunders, and explaining a $30
million loss to the shareholders would have been difficult..
Give them their due, though, they made it work in the end..
Interviewer: They did? Well, there you are then, it proves O-O
works..
Stroustrup: Well, almost. The executable was so huge, it took
five minutes to load, on an HP workstation, with 128MB of
RAM. Then it ran like treacle. Actually, I thought this
would be a major stumbling-block, and I'd get found out
within a week, but nobody cared. Sun and HP were only too
glad to sell enormously powerful boxes, with huge resources
just to run trivial programs. You know, when we had our
first C++ compiler, at AT&T, I compiled 'Hello World', and
couldn't believe the size of the executable. 2.1MB
Interviewer: What? Well, compilers have come a long way, since
then..
Stroustrup: They have? Try it on the latest version of g++ - you
won't get much change out of half a megabyte. Also, there
are several quite recent examples for you, from all over the
world. British Telecom had a major disaster on their hands
but, luckily, managed to scrap the whole thing and start
again. They were luckier than Australian Telecom. Now I
hear that Siemens is building a dinosaur, and getting more
and more worried as the size of the hardware gets bigger, to
accommodate the executables. Isn't multiple inheritance a
joy?
Interviewer: Yes, but C++ is basically a sound language..
Stroustrup: You really believe that, don't you? Have you ever sat
down and worked on a C++ project? Here's what happens:
First, I've put in enough pitfalls to make sure that only
the most trivial projects will work first time. Take
operator overloading. At the end of the project, almost
every module has it, usually, because guys feel they really
should do it, as it was in their training course. The same
operator then means something totally different in every
module. Try pulling that lot together, when you have a
hundred or so modules. And as for data hiding. God, I
sometimes can't help laughing when I hear about the problems
companies have making their modules talk to each other. I
think the word 'synergistic' was specially invented to twist
the knife in a project manager's ribs..
Interviewer: I have to say, I'm beginning to be quite appalled at
all this. You say you did it to raise programmers'
salaries? That's obscene..
Stroustrup: Not really. Everyone has a choice. I didn't expect
the thing to get so much out of hand. Anyway, I basically
succeeded. C++ is dying off now, but programmers still get
high salaries - especially those poor devils who have to
maintain all this crap. You do realise, it's impossible to
maintain a large C++ software module if you didn't actually
write it?
Interviewer: How come?
Stroustrup: You are out of touch, aren't you? Remember the typedef?
Interviewer: Yes, of course..
Stroustrup: Remember how long it took to grope through the header
files only to find that 'RoofRaised' was a double precision
number? Well, imagine how long it takes to find all the
implicit typedefs in all the Classes in a major project..
Interviewer: So how do you reckon you've succeeded?
Stroustrup: Remember the length of the average-sized 'C' project?
About 6 months. Not nearly long enough for a guy with a
wife and kids to earn enough to have a decent standard of
living. Take the same project, design it in C++ and what do
you get? I'll tell you. One to two years. Isn't that
great? All that job security, just through one mistake of
judgement. And another thing. The universities haven't
been teaching 'C' for such a long time, there's now a
shortage of decent 'C' programmers. Especially those who
know anything about Unix systems programming. How many guys
would know what to do with 'malloc', when they've used 'new'
all these years - and never bothered to check the return
code. In fact, most C++ programmers throw away their return
codes. Whatever happened to good ol' '-1'? At least you
knew you had an error, without bogging the thing down in all
that 'throw' 'catch' 'try' stuff..
Interviewer: But, surely, inheritance does save a lot of time?
Stroustrup: Does it? Have you ever noticed the difference between
a 'C' project plan, and a C++ project plan? The planning
stage for a C++ project is three times as long. Precisely
to make sure that everything which should be inherited is,
and what shouldn't isn't. Then, they still get it wrong..
Whoever heard of memory leaks in a 'C' program? Now finding
them is a major industry. Most companies give up, and send
the product out, knowing it leaks like a sieve, simply to
avoid the expense of tracking them all down..
Interviewer: There are tools.....
Stroustrup: Most of which were written in C++..
Interviewer: If we publish this, you'll probably get lynched, you
do realise that?
Stroustrup: I doubt it. As I said, C++ is way past its peak now,
and no company in its right mind would start a C++ project
without a pilot trial. That should convince them that it's
the road to disaster. If not, they deserve all they get..
You know, I tried to convince Dennis Ritchie to rewrite Unix
in C++..
Interviewer: Oh my God. What did he say?
Stroustrup: Well, luckily, he has a good sense of humor. I think
both he and Brian figured out what I was doing, in the early
days, but never let on. He said he'd help me write a C++
version of DOS, if I was interested..
Interviewer: Were you?
Stroustrup: Actually, I did write DOS in C++, I'll give you a demo
when we're through. I have it running on a Sparc 20 in the
computer room. Goes like a rocket on 4 CPU's, and only
takes up 70 megs of disk..
Interviewer: What's it like on a PC?
Stroustrup: Now you're kidding. Haven't you ever seen Windows '95?
I think of that as my biggest success. Nearly blew the game
before I was ready, though..
Interviewer: You know, that idea of a Unix++ has really got me
thinking. Somewhere out there, there's a guy going to try
it..
Stroustrup: Not after they read this interview..
Interviewer: I'm sorry, but I don't see us being able to publish
any of this..
Stroustrup: But it's the story of the century. I only want to be
remembered by my fellow programmers, for what I've done for
them. You know how much a C++ guy can get these days?
Interviewer: Last I heard, a really top guy is worth $70 - $80 an
hour..
Stroustrup: See? And I bet he earns it. Keeping track of all the
gotchas I put into C++ is no easy job. And, as I said
before, every C++ programmer feels bound by some mystic
promise to use every damn element of the language on every
project. Actually, that really annoys me sometimes, even
though it serves my original purpose. I almost like the
language after all this time..
Interviewer: You mean you didn't before?
Stroustrup: Hated it. It even looks clumsy, don't you agree? But
when the book royalties started to come in... well, you get
the picture..
Interviewer: Just a minute. What about references? You must
admit, you improved on 'C' pointers..
Stroustrup: Hmm. I've always wondered about that. Originally, I
thought I had. Then, one day I was discussing this with a
guy who'd written C++ from the beginning. He said he could
never remember whether his variables were referenced or
dereferenced, so he always used pointers. He said the
little asterisk always reminded him..
Interviewer: Well, at this point, I usually say 'thank you very
much' but it hardly seems adequate..
Stroustrup: Promise me you'll publish this. My conscience is
getting the better of me these days..
Interviewer: I'll let you know, but I think I know what my editor
will say..
Stroustrup: Who'd believe it anyway? Although, can you send me a
copy of that tape?
Interviewer: I can do that..
Sanity is a sandbox. I prefer the swings.
Will/should name mangling be standardized so different implementations can coexist ?
1 reply beneath your current threshold.
I've heard several people mention the story about how you created C++ as a cruel practical joke. While I don't think it's true (C++ has its problems, but I'm very fond of it), the origin of the story intrigues me? How did it come about?
After twenty some years, its obvious that object-oriented programming is not a panacea. What are your thoughts on the future of the OO paradigm? What other paradigms do you see challenging it?
C has long been the UNIX-world's systems programming language, and still remains that way. I know you don't like to compare C++ to other languages, so I'll just ask if you feel that there are any core reasons why C++ either does not make a good systems prgramming language or failed to capture the interest of the systems C programmers.
If you could go back to when you designed C++, what would you change and why?
Templates were added long after inheritance. Unfortunately, templates and inheritance don't fit well together. It is quite disturbing because at the very same time, a kind of dynamic typing was added to the langage yoo.
So where is C++ headed to ?
* Template oriented language (ie: static) ?
* "More dynamic" object langage ?
* Both at the same time ?
1 reply beneath your current threshold.
Ibag
What is your opinion of Eiffel (www.elj.com, or www.elj.com/eiffel/intro) as a language? Object-oriented without C-like syntax.
Oh why oh why did you invent C++?
This most joyful of languages that has e'er graced our lands has been the bane of many a programmer, when good ol' C was doing a pretty good job. Then it comes along, and puts a heap o' stuff on top o' C that makes it all a mess.
Smalltalk did it better and before C++, and much more elegantly. Java does it nice and clearly now, albeit with the wrong way of doing things (bytecode? runtime environment? JIT? non-platform specific classes? Where is the performance?)!
But, I digress my humble acolytes, and I must press thee this fine question: What has held back development of a lot of applications for that C++ infidel, BeOS?
From the FAQ page:
h tml
Did you really give an interview to IEEE?
in which you confessed that C++ was deliberately created as an awful language for writing unmaintainable code to increase programmers' salaries?
Of course not. Read the real IEEE interview.
The real interview is here:
http://www.research.att.com/~bs/ieee_interview.
I'm not a journalist, but I play one on slashdot
Why is deterministic garbage collection such a difficult concept to implement?
Well, this is weird. Just the guy I wanted to talk to this morning!
It would occasionally be handy to have typedef templates (or template typedefs?! help!), something like this:
template< class T >
typedef bool (* func)( const T &r );
. . . but that doesn't seem to be legal. I don't recall seeing anything about this issue in The Design and Evolution of C++. So what's the deal?
"Christianity neither is, nor ever was a part of the common law." --
I (and maybe most of "us") know you solely through your creation of the C++ language and your assistance in authoring the ANSI standard for said language.
Aside from this one (albeit major) project, what do you work on from day to day? What projects are you currently involved in? Do you have any more language definitions/standards in the pipeline?
43rd Law of Computing: Anything that can go wr
2) How would a language like Objective C, which is more Smalltalk like in design, stack up against C++?
I'm trying to teach myself to set people on fire with my mind... Is it hot in here?
Three linked questionsquestions
1) Do you think that multiple inheritance is a requirement for a true OO Language
2) When designing a system with multiple inheritance what do you see as the pitfalls to avoid, especially when it comes to maintainability.
2) Do you know of anyway to simplifying the readability of multiple inheritance to enable first time users to do less damange.
An Eye for an Eye will make the whole world blind - Gandhi
Another item that has gained a lot of momentum in the Eiffel community is Design by Contract, for which I would love to see a standardized approach in C++, but I doubt I'll ever see it.
Lastly, Bjarne, you were quoted once as saying 'When (not if) reference counting becomes available in C++ that it would be optional' (in a book on object oriented programming languages of which I cannot find on amazon at the moment to post the ISBN). Has much progress been made on the front of making reference counted objects available? Or has your thinking changed since you were quoted?
Sanity is a sandbox. I prefer the swings.
Would you agree with me and thousands of others, that in a nutshell, C++ sucks, whereas Modula-3 and Smalltalk rule ?
However, all existing processors are procedural, and there is no real concept of an OO CPU.
Do you feel that OO languages, such as C++, will result in OO systems, at the hardware level, or will it always be easier to confine OO thinking to the abstract, using extremely complex compilers to translate between OO and procedural paradigms?
It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
. . . and let's hope that Stroustrup continues to grasp that fact.
We don't need yet another Perl, endlessly growing useless and obstructionary pseudo-features and random fungus.
The biggest complaint I hear about C++ (and agree with myself, depending on whose code I'm reading), is that it gives you enough rope to hang yourself, your company, and your close family.
Unfortunately, while it's easy to give a language new features without harming backwards compatibility, it's a lot harder to take things out. Are there any features that, in hindsight, you wouldn't have put into C++ to begin with? Are there particular features (templates keep coming to mind) that you would advise inexperienced programmers to avoid?
If I learn C++, will it make girls like me?
Another question, how do you see funtional programming playing a role in the future? Do you think functional programming is an acadmeic fad or a niche market for special purposes like Ada is used for?
This is my signature. There are many signatures like it but this one is mine..
Also, as a Windows programmer, I spend much of my time grappling with imperfect implementations and proprietary versions of classes. As an example, most Windows programs seem to use the Microsoft specific CString rather than the standard std::string operator for strings. This can cause problems because of the poor way Microsoft has implemented their versions of some of these classes. Is this a problem that will continue to plague us, or do you see all vendors moving towards better support for the standards instead of proprietary APIs?
The cake is a pie
I already see a lot of questions being asked that are already on the FAQ list, so here's a handy list, with links:
--
With that said, I wonder if you think that with C++ we've reached a stage where a vast set of computing algorithms has been predetermined and the programming model itself has been honed to a fine edge, or do you think that the future holds a bright spot for some new--or existing, such as Perl or Python scripting--language to enter the scene and change programming as we know it again?
-Daniel.
Have fun: Join D.N.A. (National Dyslexics Association)
Do you feel that 3rd party extensions to C++, such as Microsoft's ATL "attribute" constuct ( www.geocities.com/~chrisbe/Attribu tes.htm ), add or detract from the language, and why?
--
What are your thoughts on languages and the standardization process? Looking at how long it took for C (and C++) to have standards set by ANSI/ISO, and how the most popular implementations are still so very incomplete (MSVC++, even GCC in some ways), one might ask, "Why bother?" Sun might be thinking something similar with Java.
Is it worth the time and the trouble to be able to create and to point at a sort of Platonic ideal while the rest of the world is chasing a poorly realized reflection of that ideal? What are the benefits of handing over the design of a language to the standards organizations instead of pushing forward with the design yourself (see Python, or Perl, or PHP for successes of the latter)?
--
how to invest, a novice's guide
Because they're like Pascal: At no point to they intersect with the reality of computer programming. They're not tools for expressing algorithms and data structures. They're didactic lectures about somebody's ideology. All such languages are doomed to failure, as are purely "pragmatic" languages like Basic (because Basic is in fact pushing an ideology of its own, namely that languages should be inelegant, fucked up, and useless. The idea seems to be that idiots will have an easier time learning a language if the language is as idiotic as they are). C++ is reasonably thoughtful, clean, and elegant, but it's not dogmatic. Principles aren't an end in themselves. They're just a useful guide.
C++ and objective C are both object oriented extensions to C. Do you have any thoughts on why Objective C is so rare & unknown, whereas even non-computer people have heard of C++?
How do you relate the complexity of current C++ with the much-touted simplicity of Object Oriented Programming?
Longer explanation:
Over the years, the C++ implementation has ballooned; If I recall correctly, your book the C++PL has more than doubled in size. C++ has become a very large and complicated language, and I doubt whether there are any individuals (besides you, that is) that know the entire definition by heart, let alone teams of programmers.
This means that it is not practical to use C++ fully in any project, and one also has to set strict guidelines for a project what features to use and which not. Seen, in this light, it is doubtful whether C++ has made writing software more manageable. So I think, that as tool for writing better software more efficiently, C++ is a failure.
C++'s evolution was motivated by a few mottos (you don't pay for what you don't use, C compatibility, etc.), and seen in this light, C++ is a success. Do you think that these mottos need reconsideration?
Han-Wen Nienhuys -- LilyPond
I realize that you like to avoid comparing C++ to other languages. However, how do you feel about the Eiffel language, and more specifically, what is your reaction to the negativity the Eiffel community seems to show towards C++? Have you ever met any of the founding fathers of other languages, such as Bertrand Meyer of Eiffel or the Sun Java people? If so, was it a positive experience?
--- "So THAT's what an invisible barrier looks like!" - Time Bandits
Aren't design patterns and modular design the real selling points of C++? You can easily write stand alone objects and make them into shared objects, and this gives you real power. I personally wrote classes in C++ for FTP, HTTP, NNTP, etc - then combined them inside an shared object with a shared interface ( Url ). Now anyone can 'plug-in' and have these features with a great OO interface to my module. Java can't do libs - that's always made it look like a toy langauge to me.
The original poster asks a good question: is C++ more efficient for those lower-level things (things that would form an operating system kernel, or microkernel servers) than traditional languages (C and architecture assembly)?
Stroustrup's The Design and Evolution of C++ is a fun read, and it addresses that question. The intent was apparently that C++ would be as close as possible to the efficiency of C, and in fact that was something of a litmus test for new features: "Can we do this efficiently enough that C programmers won't make fun of us?" I myself don't know enough about that low-level stuff to be able to comment on the details. YMMV, etc. etc.
"Christianity neither is, nor ever was a part of the common law." --
Mozilla's C++ Coding Guidelines from 1998 at http://www.mozilla.org/hacking/portable-cpp.html advise against using C++ templates, exceptions, namespaces, and Run-time Type Information (RTTI) in order to meet their portability requirements. When can we expect that these features will be uniformly implemented across different platforms?
Secondly, OO has been hashed around for twenty years now...with limited success. No one really believes that it is a panacea paradigm that should be translated up and down the system hierarchy.
If you were to create C+++, how would it be different from C++?
Would you do anything different if you didn't have to care about backwards compatibility?
This message is provided under the terms outlined at http://www.bero.org/terms.html
...ever program in English. I read one of those ABC books and it made a lot more sense then just the C one. You should try English, it's fast (but not as fast as Mexican) and easy, I learned it just by listening to my folks, and EVERYONE understands it, even the angry man at 7-11. He's really stupid (and so am I if you believe him) and he writes English all the time, and so do I, so you should too.
Other than designing and implementing c++, and writing books and papers about the language, what do you use it for? i.e. what programs have you written with it? or What are those programs used for?
The word is flooder, not spammer. This is not email, and it was quite on topic. Not to mention funny.
Lowmag.net
Its an amusing OO tool for illustrating concepts, but Smalltalk's hardware-agnostic design simply couldn't perform as well as C.
What do you think of Effiel?
If ignoance is bliss, you must be very happy indeed.
Okay, in a battle to the death between Linus Torvalds and Bjarne Stroustrup, who would win?
In my view one of the greatest strengths of C is K&R, particularly the second edition. In addition to being both complete and precise, it manages to be concise at the same time. One of my major criticisms of your book was that it's unnecessarily wordy. In particular, it takes far too long to get to the first code examples. Having flicked through the 3rd edition in bookshops, it appears to be noticably better in this respect than my version. Was this a deliberate decision on your part, and if so, what prompted it?
"The invisible and the non-existent look very much alike." -- Delos B. McKown
For example, the GNU C Compiler's FAQ includes an entry detailing the available workarounds. Other compilers are similar (in fact, the GCC FAQ entry makes reference to other implementations).
A number of development shops I've worked in have avoided templates precisely because of these problems, despite their benefits. Code reusability suffers as a result.
Presumably you didn't have this sorry state of affairs in mind when you were working on the specification. What did you imagine people would do? Abandon object files in favor of some other incremental-compilation scheme? (If so, what?) Are there any compilers that get this "right" in your estimation? In retrospect, would you have done anything differently to encourage compiler vendors to do the "right thing"?
As for "a trend towards simplicity"...please tell me what is simple about Java. I understnad the base language syntax is fairly clean, but in terms of tools and implementations, Java is a mess. There are serious discrepencies between the JITs, JVMs, JDKs, browser compatibility etc. that are not trivial for a new developer to deal with. Contrast this with Perl and Python - there is one developer kit, and it runs in a similar fashion on all platforms. Added to which, Java programmers must deal with compatability and support issues (since "write once, run anywhere" is not and will not be a reality), that Perl and Python users typically don't have to deal with.
There is still the potential to make C++ much easier for people trying to do hard things. What kind of tools do you feel are needed to improve C++ usability for people creating large systems.
--
Be insightful. If you can't be insightful, be informative.
If you can't be informative, use my name
Be insightful. If you can't be insightful, be informative.
If you can't be informative, use my name
Compiler support isn't the issue with these features - its code bloat. Templates I can deal with (sometimes), but RTTI is going overboard.
In my opinion, if it ain't working after twenty years, it ain't going to work.
Not nearly enough is written about the negative issues regarding OO.
What's your opinion of Objective C? Why do you think C++ is superior? (Or do you? ;-) )
\\'
.. and would ignore backwards compatibility with C, would the resulting language resemble C++? It seems to me (I mainly do Java) that a lot of language features in C++ are less then optimal and heavily biased to performance rather than usability. Templates come to mind but also such things as macros (eeeww).
I hope you won't put this question aside like you do with most question asking you to compare C++ with <fill in your language here>. While I imagine that the latter type of question must have become a boring one for you, the fact remains that C++ is now more than 20 years old and other languages might exist that address some domains at which C++ was once targeted, better. So rather than asking you to do that I would like you to describe what a modern language should be able to do compared to C++.
Jilles
Oh, my...
I believe the fundamental nature of the questions to be asked were ones not covered in Stroustrup's FAQ. This post is. Sure this flood is funny, but it also fictional and probably offensive to Stroustrup.
So far I've gotten all my Karma from telling people they are wrong... :)
Now that the C9X is the official C standard, don't you think that C++ is a bit poor in *real* capabilities (ie. not just a question of writing style) ? The official C reference is a lot more precise than C++, making the C language a lot more portable than C++. The new C standard has also terrific arithmetic features and supports better internationalisation than C++. The preprocessor itself, can handle Unicode characters, pragma with macross, variable-length macros, etc... There are also new types and qualifiers like 'long long' and '_Complex' that C++ can't handle outside of an emulation in classes. C is not a subset of C++. C++ lacks a lot of things that C has now with C9X. So, for object programming, Java, Objective C and Eiffel rules, while for dirty and optimized code, C is a lot better, safer and more portable than C++. Is there any interest in keeping that language ?
I thought that was a very interesting comment because it supposes that the real reason Java has taken off is not because it's better than C++, but because Sun pushed it so well. In a way the groundswell of support Java has seen is similiar to massive push by developers toward open-source software.<P>
But what if we could take that kind of effort and put it into pushing improvements to C++ libraries or tools. Is there anywhere we could expend that kind of effort and actually see benefit?
--
Be insightful. If you can't be insightful, be informative.
If you can't be informative, use my name
Be insightful. If you can't be insightful, be informative.
If you can't be informative, use my name
Even if you won't recommend a compiler, will you at least tell us which ones you use? How do you decide which compiler is right for a specific purpose? What do you see as the strengths and weaknesses of the various compilers?
How do you feel about the fact the fact that there is not one C++ compiler in existance that implements the whole C++ standard?
bye
schani
I come from a Perl background, and am in the process of teaching myself c++. It seems to me that both c and c++ as systems programming languages, are obsessed with memory management-related techniques. (for instance, a programmer should choose when to use call-by-reference or call-by-value for certain things.) My question is: what do you think will be the future of memory management functions in systems programming languages? Do you see more memory management and code optimization mechanisms creeping in, or less?
Did you know that no question ever asked by an AC has ever been sent to any interviewee in the history of slashdot? Do you think that is fair? Or are you just another karma builder yourself.
I'd love to check them out if just for interest.
C++ is the shittiest language ever Really? If you had said "C++ isn't good for system programming", I might agree, but what's wrong with C++ for GUI programming? Have a look at, for example, the KDE source - it's C++, it's readable, it works and it's reasonably fast. If you look at other UIs written in plain C, say GTK/GNOME, you'll notice that many of them actually reinvent some C++ ways. (Yes, I know the difference, but GTK_WIDGET_NEW(a); really isn't much different from QWidget a();). Which language would you pick for creating a GUI? (And why?)
This message is provided under the terms outlined at http://www.bero.org/terms.html
I'm quite fond of C++, but obviously it will eventually be replaced by something much greater. As an established language expert, what elements do you think will be found in the next great language? And are there any existing languages that you think are close to this level?
Even among programmers who use C++ on a daily basis, there seems to be no shortage of people willing to express varying degrees of distaste for C++. This is similar to the popular dislike among some programmers for Microsoft Windows, in that the loud and frequent negativity doesn't have much of an effect on overall popularity. Do all the jokes and complaints about C++ bother you at all?
For the first five years I used C++ I allways thought of it as C with a little bit of OO stuff slapped on it. After I started using the STL C++ started feeling like a very diffrent (and more usable) language then C.
Is the STL really that much diffrent from other parts of C++? Or is it just me?
I recently returned to c++ after picking it up in college about two or three years ago, and boy was I surprised! New cast operators all over the place, new throwing an exception being the default behavior on failure. STL becoming core functionality and so on, not to even mention RTTI, bool types
Took me a little time to get back up to speed with it I have to say, but all in all I do like most of these features, I have great time for STL, we've been wasting our time writing sorts and searches for so long that its nice to drop kick that issue out the window. A bool type is cute, and even if the only use for exceptions was a throw from new its worth it, at least the guilt factor of not protecting every appearence of new with a NULL test can be dispensed with.
But on with the questions
One: One advantage of C over C++ which noone else seems to have a problem with is that when you are handed a huge stack of code and go to fix a bug or make a small modification, on viewing a chunk of code in C you can assume that most functions will only modify the state of variables that are explicitly passed to them. On viewing c++ code that has a function call, you have to refer to a header to determine if its a function call or a method belonging the the class whose code you are trying to read.. If its a member you have to read the code of that method to see if it is changing the internal state of the object, and if it calls other methods you have to chase all of those down as well to be assured that the state of the object will remain unchanged after a method call that takes no immediately relevent arguments (Obviously keeping an eye out of operator overloads as well, though to be fair you can assume that they will follow the normal behaviour and not modify the object, and behave intuitively)
In one sense from the perspective of someone trying to maintain c++ code, an attempt to understand its logic faces the same difficulties as understanding horrific global variable ridden c code.
Was there ever any actual language constructs considered for this problem ? Granted proper coding practice with consts etc etc can sort out a lot of the problem, but there is still the need to refer to the headers continually, but a good programming editor could sort that out, and so on, but it just strikes me that these are obvious external work arounds for a problem which might possibly be dealt with at a different level. Maybe something like...
- Only member functions can be called from inside other methods unless a scoping operator is used, so you know immediately if a member or a function is being called
- Some of the information about how the method modifies or does not modify the object is coding into the name of the method itself, yes yes hungarian notation and dragging me off to the stake, but you know what I mean anyway.
Two:STL was a definite change away from c's philosophy of minimum requirements and towards a more javaesque conglomoration of a programming language and a more feature rich standard api.I could quite easily imagine threading becoming part of the c++ standard in the future, whereas I could never see something like that happening to c, likewise serialization (Id really like that actually), and a whole other set of currently specialized and large library addons. Would you favour this approach, STL allowed us to stop fiddling with lists, wouldn't adding other libraries to c++ make us more productive ? I can see that we don't want to get stuck with a library which turns out in a year or two to be worthless because of changing technology but then cannot be gotten rid of for 10 years because of standard complience inertia, but perhaps c++ complience levels, level 0 just the language, level 1 the iostream and friends, level 2 networing classes and level 3 a java style api
C.
I sometimes write stuff
Why? Oh God, why? Oh, the pain, the pain!
Oh. Um. Sorry. Just kidding.
What I meant to say was, do you think that an obfuscated C++ contest would be more fun than the traditional one?
'Cause you can still do all the ridiculous things that C lets you do, but now you can also overload operators (like ++, yeah!) to do stupid things (like take the square root if it's on the left, and take the cosine otherwise, yeah!)
And then you can make a couple of classes, and merge them together, and have fun function naming clashes, that's pretty cool too. Or pass 'this' around, or use templates for no reason at all... (and attempt to pass them to the C library Quicksort function!)
I mean, really, C++ has so much more potential here. It's a valuable addition to the set of programming languages that promote obfuscated programming and maintenance code. It's years ahead of BASIC and Perl, IMO.
---
pb Reply or e-mail; don't vaguely moderate.
pb Reply or e-mail; don't vaguely moderate.
Something like operator renew[] would be useful. I often still use malloc()/free() because I get to use realloc() with those. Still, if I've got an array of class instances, I'm S.O.L. Granted, operator renew[] would be inefficient and it would require copy constructors on everything, but C++ generally assumes that the programmer has enough sense to come in out of the rain. There are other "caveat user" things in the language already: Take for example pure virtual functions, which a naïve programmer is perfectly free to call in a base class constructor. This would just be another one of those (though you might say there are too many booby-traps already
Certainly one could approach this by overloading operator new[] and operator delete[] and writing an operator_renew() function template using placement new
"Christianity neither is, nor ever was a part of the common law." --
What do you feel are the "Best Practices" for C++ developers to adopt?
--
Be insightful. If you can't be insightful, be informative.
If you can't be informative, use my name
Be insightful. If you can't be insightful, be informative.
If you can't be informative, use my name
Was it worth it? How do you think this helped? How did it change the language? Do you see Java's continued failure at standardization as a potential flaw, or one that will be eventually brought into some kind of standardization process?
(supposedly one of the reasons Sun is so reluctant is because the C++ standardization process took so long.)
Considering that all things evolve and that, eventually, C++ will make room for a higher generation language, what features do you consider as critical to a next generation, post C++ language? Is there any language existing today that comes close to what you envision it to be?
Coincidentally, I was just reading your book, _The C++ Programming Language_, 30 minutes ago - let me take a moment to say that I'm very impressed by it. On to the question:
h tm">this piece by Tim Sweeney</A> and <A HREF="http://slashdot.org/articles/00/01/25/150238 .shtml">its coverage on slashdot</A>. Tim is the lead coder for the Unreal game engine.
Recently I've seen a couple different articles calling for the 'next' programming language, something to go beyond C++. Specifically, there's <A HREF="http://www.gamespy.com/articles/devweek_b.s
In the article, he discribe's his thoughts on what new programming languages should focus on, which seems to boil down to higher levels of abstraction. One example he gives is having two arrays, A and B, and being able to add them directly (C = A + B;) rather than using a loop to do so with each individual element.
Having just read part of your book, I see that you noted that you agree with C's very low level primitive data types, which seems to be the opposite view; yet the addition of classes seems to be a move toward more complex data types.
My question is, do you think a more high-level/abstract language would be useful, or do you think that we should stick to fairly low level but complex languages like C and C++?
And, on a slightly relatated note, do you think that future languages should mimic the C/C++ grammar, or do you think a more intuititive one is possible?
-- Imagine how much more advanced our technology would be if we had eight fingers per hand.
Flooder, spammer, whatever.
It was semi-funny the first time I saw it, but that was a long, long time ago.
what's a good c++ library, in your opinion? ACE? GTK--? Libstd++? Almost as interesting, what are examples of poorly-designed libraries, and why?
(And why these interfaces of all abstract MF's?)
Do you believe that implementing Design by Contract, invariants, and other features present in Eiffel in C++ would be a good idea? or at least a really cool one?
Esperandi
The average SlashBot is totally incapable of grasping the difference between a high-level language and a low-level language. They'll never understand why C is efficient, or why an operating system kernel does not store numbers as string representations of base 10 integers. All they see is the surface, and damned little of that.
During the design phase, it's difficult to forsee all the issues that will occur in the final implementations (and when the language is put to use).
What were the biggest misfeatures of C++ (things which added little useful functionality but which make compiler implementation/use/efficiency more nightmarish?)
On the other hand, what restrictions or concessions turned out to have surprising wins in the same categories?
Do you feel that backwards-compatability with C spoiled C++? I often hear peoples laments of C++ for including these (to them) outdated features. This I believe is also why many like Java, which is more like C++ would of been without the C compatability. Do you have any regrets for sacrificing clarity for compatability?
You are more than the sum of what you consume.
Desire is not an occupation.
While it isn't clear that it has a great effect on the user, each has a very different flavor. Smalltalk sends a "message", with typed arguments, to the "object" for the object to disambiguate what to do next. C++ creates a "generic function" which indexes the appropriate function based on that function's typed arguments (name mangling).
1) Is that a fair distinction?
2) If so, do you think the differences are important?
3) If so, why did you go the route you did with C++?
I understand that you had tried to make the most sensible generalizations to C language while working on a large project. Obviously, the OO extensions have proved to be the most useful, and C++ has been seen as the prominent OO language for many years.
In one of your interviews, you had stated that you had a much more "generalized" language in your mind, that is, when compared to the ISO C++ standard and the previous implementations. I wonder what you would deem the ultimate generalization of C as a mathematician.
Thanks,
--exa--
I heard from a grad student at my college that the language of C++ was invented on a bet that you couldn't do it. I was wondering if this was true, and what else inspired you to invent this language.
+++
...These aren't the droids you're looking for....Move along....
I've been playing around with OpenC++, C++ with a metaobject protocol and I find opening up the compiler in controlled ways like this to be very powerful - and more than just an academic toy. It would allow me to extend C++ in interesting ways to include Delegation (useful for the "Decorator" pattern) and multi-dispatch (useful for the "Visitor" pattern) - along with other interesting extensions (before/after methods, persistance, etc.). I know you considered and rejected both of these features in C++ (if I remember from "Design and Evolution of C++" you rejected Delegation because users found it confusing and you rejected multi-dispatch because it required too complex a linker[1]). I am not questioning your rejection of these features, but I would be interested in your option of a metaobject protocol for C++, which would allow me to add features like these to C++ so it is a closer to my designs. Did you consider a metaobject protocol for C++, and if you did why did you rejected it (too immature? too hard to maintain code? not useful enough to justify the complexity to the language?)
-Scott
nonya_cpp_question@yahoo.com
[1] I should mention my version of Multi-Dispatch doesn't solve the linker problem, it requires you call a function at the start of a program to initialize some tables of pointers to member functions.
Most likely, he's some stupid kid who failed his C++ class at the community college, and now he's pissed off because system programming languages weren't designed for the benefit of illiterate inbred cretins like himself.
There's always a flood of morons sloshing around loose on Slashdot. Ignore them.
(BTW, I'm an inch or two out of my depth talking about system programming, but is C++ really all that unsuitable? For best efficiency you might choose not to use some features, but there's a lot of yummy OOPsy goodness in there waiting for times when you can afford to use it. God invented profilers for a reason
on recent ANSI committee developments, such as the deprecation of C-style casting (in favor of static_cast<>(), which in my understanding has such a long name, along with things like reinterpret_cast<>() so people would know to avoid using it)?
Will the ANSI committee leave C++ the way we knew it (obviously stuff like exceptions was a bit of a fiasco and all...)? I think at this point C++ is so popular and has such an established user base that users will be alienated by major fundamental changes to the language that start to break their old programs, or majorly affect fundamental style issues.
That girls don't like C++. So what programming language is most likely to get you some?
I'm trying to teach myself to set people on fire with my mind... Is it hot in here?
I hate C++ because it gives me only headaches at work. The c++ compilers of different commercial unices are not 100% compatible especially when using namespaces and STL. Throw in some orbix and third party libraries and the whole place is a mess.
Have you any insights on this matter ?
Thanks
Why was the decision made not have have references visible as parameters in the calling context of a function call?
Sounds like one for MTV's Celebrity Deathmatch. Lets throw Bill Gates in there, too. I'm sure that given the design goals of C++ (Higher salaries for programmers) Bjarne can't be too happy with Visual C++...
I'm trying to teach myself to set people on fire with my mind... Is it hot in here?
..'cause I thought it was funny *today*. Humor relativity at work, it would seem.
Perhaps thats not the point.
This is a call for questions, can one post relevent jokes here?
Suppose Bill Gates was interviewed. Would every Bill Gates/Microsoft is Evil joke be acceptable? When the next famous person gets interview can I post any joke about them?
Why was this even posted up to 5 anyways? How about the moderaters moderate up the questions, and not old jokes.
The surprise isn't how often we make bad choices; the surprise is how seldom they defeat us.
What is your opinion on this fake interview?
Use Adsense for Charity
Mr. Stroustrup:
In the summer of 1996, I was enrolled at a summer camp run by the IAAY/CTY (Dickinson College, Carlisle, PA). One of the kids on my floor was Nick Stroustup. He was pretty cool-- had a Weird Al CD, a laptop (a pretty bitchin' one for the time, might I add!), and an intellect and curiosity about him that blew me the hell away.
Anyway, I remember him wearing a ragged old T-Shirt that had the Bell Labs logo on it, plus something about the C++ standardization effort. I asked him where he got it (hey, it was a cool shirt), and he said his dad worked on the C++ language. He said he was from New Jersey, also.
How is Nick doing? Does he do any programming? Is he even interested in computers (he seemed so interested in *everything* at the camp that it was hard to pin down any exact likes and dislikes)?
Mankind has always dreamed of destroying the sun.
Modern C++ compilers have great power via `template metaprogramming'. Using partial template specialisation we can practically write our own compilers that build on the C++ compiler. See for example the blitz++ linear algebra library or my own compile-time primality tester. Unfortunately these techniques are very unwieldy even though they can have have a great payoff for high performance computing. How do you see template metaprogramming evolving in the future and how could C++ be modified to accomodate it better?
-- SIGFPE
C++ is, in my opinion, a superb language for programming in the large. It is my first choice for any programming project of substantial size, and I shudder at the thought of working on a 100k+ line project in anything else. I particularly appreciate how the strong typing facilities can be used to express and statically check many of a program's semantics.
However, when writing something smaller, I am drawn (like many people) to languages with facilities for terser, higher-level data structures and algorithms. Standard ML, Python, and even Perl make it easier to work with tuples, strings, lists, or higher-order functions. These languages sometimes permit faster prototyping or experimentation. It is easy to be put off by the sheer amount of verbiage required to write well-engineered C++ code (private undefined copy constructors, redundant include guards, the occasional ribbon cable, etc. ).
How can we bridge the gap between productivity in the large and productivity in the small?
(Note: I do not mean to imply that C++ is never suitable in the small; rather that there are many classes of problems for which different langages seem to me more productive, at least up to a certain program size).
You said, in "The Design and Evolution of C++" (p. 207), "Within C++, there is a much smaller and cleaner language struggling to get out."
Do you still beleive this? If so, is it likely that such a language shall be created within the forseeable future?
Steven E. Ehrbar
...
What is your take on the move towards more and more code embedded in chips and how do you think C++ may need to evolve to meet that trend?
-- Win2k: "It's not so much that it's only 65,000 bugs, it's just that they stopped at 65,535 to prevent an overflow."
What do you think of template meta programming? Do you consider it a boon, enabling clever programmers to do outrageously cool things like the Blitz project? Or is any benefit derived from it's use washed away by the obscure, nearly unreadable code it takes to implement it?
Davo -- Free speech, free software, AND free beer.
For the programs I develop at my job, I'm often quite worried about storage requirements and about execution time. I find C to be comfortably close to the bare metal, that I have a fairly good idea of what the machine code is going to be like, and how much space my structures will consume. While I use C++ for some applications, I shy away from it in this particular context because I'm not confident about how much overhead is involved in things like method pointer tables or vector operations. For my compute bound, memory-limited programs, a 10% increase in either run time or memory consumption would be difficult to justify. This is almost an implementation question, actually: are these considerations relevent with modern C++ compilers.
I've considered visual coding for this. You could create objects from templates, put them in precedures, etc. You would use only pieces of text to refer to the algorithms themselves. It can give you more control over the object hierarchy.
I've also thought of the possibility of having the abstraction go both ways. You could have an object be able to tell what other objects are encapsulated with it.
You could also have something along the lines of eval that lets lets objects spawn other objects dynamicly.
What do you think of these ideas are there any that you are working on? How do you feel that design patterns fit into this?
I was introduced to the C++ language in 1989 on the BIX online service by you and Greg Comeau whereupon the both of you set out to demonstrate (and finally convinced me) that this OO stuff wasn't just a fad and that C++ was a language that could efficiently implement it. This was during the time when Computer Language magazine had there "Language of the Month" feature article so languages had a tendency to come and go quickly back then.
As I recall, the two major goals that you stressed were a) to build a language that could get a handle on these huge projects that C was having difficulties with and b) to provide a balance of features and efficiency so that a developer should have to pay for features he doesn't use.
From my own experience using C++ in an extreme variety of projects (including very cramped embedded systems and large, multi-platform enterprise systems), there's no doubt that the great progress has been made on the first goal and that the second might have been fully achieved.
The biggest disappointment to me, however, has been the lack of ability to fully replace plain-old-C in system level development which is an area that stands to gain the most from the language's abstraction features and your stated goals of the language. I understand that early on, it would have been impossible to define standard ABI's since implementation techniques for things such as virtual method and inheritence resolution were very experimental. Now that a full decade has gone by and a surprisingly strong standard has been produced, these differences in implementations are more contrived than based on architectural considerations.
Presently the Open Source movement is growing wildly in popularity in commercial and non-commercial segments of the industry. Unfortunately, C++ cannot be used to provide linkable API's without either downgrading to severaly limiting C-based linkage or forcing everyone to use the same compiler that wants to call your library because of non-standard representations of structures and calling conventions.
Do you think that standardized application binary interfaces should be a priority time now? If so, what should be the mechanism used to define these interfaces (defacto vs. formal standards, etc), who should do it, and what can be done to encourage this development?
Beyond this issue, what are your personal priorities and hopes for the C++ language now?
. . . and the STL probably does it with placement new/delete and writing their own allocator. In fat, I seem to recall that placement new and placement delete were added at least partially to keep Stepanov happy . . .
I guess the implications may well be weirder than I think they are, but it still seems kinda constricting. One question is this: Is it guaranteed that a pointer to item zero in a vector<foo> is in fact a pointer to a contiguous block of memory holding an array of foo? People still have to interact with old C libraries, and people can (and do) derive classes from old prehistoric structs. If I've got a vector of foo, and some function expects a pointer to an array of a struct from which foo is derived (with no additional data members -- I wasn't born yesterday
"Christianity neither is, nor ever was a part of the common law." --
In your FAQ, you seem to have the attitude that C++ completely surpasses C in every way and there is no reason to use C at all anymore for anything.
Is there anything fundamentally wrong with C that you do not like, or simply that you prefer C++'s architecture/design better?
It seems C is perfectly suited for many applications where C++ would offer no significant advantage.
Most important question nobody seems to be asking is why did he feel the need to screw with a excellent language like C to produce this bastardization call C++?
<tune=rawhide> ...
trolling, trolling, trolling
</tune>
I read at +2. If your post doesn't reach that level I will not see or respond to it.
Why I Still Refuse to Use C++, by ZicoKnows@hotmail.com (picture)
It is impereteefe-a thet I geefe-a yuoo zee fullooeeng inffurmeshun, vheech Dr. Bjerne-a Struoostroop vunts cunceeled frum zee poobleec. Let me-a preffece-a my deescoossiun by qooeeckly reesserteeng a femeelier zeeme-a ooff my prefeeuoos letters: I ixpereeenced qooeete-a un ipeephuny vhee I furst reeleezed thet beffure-a I knoo unytheeng ebuoot Dr. Struoostroop, I ves oonce-a un oonluuker et a foo ooff hees mess demunstreshuns, veethuoot pussesseeng ifee zee sleeghtest inseeght intu zee menteleety ooff hees cruneees oor zee netoore-a ooff hees unecdutes. Lest soommer, I ettempted vhet I knoo vuoold be-a a hupeless tesk. I treeed tu cunfeence-a Dr. Struoostroop thet elmust ifery deescoossiun ooff unercheesm ignures zee creeticel impurtunce-a ooff hees rebeed oobeeter deecta. Es I ixpected, Dr. Struoostroop ves utterly uncunfeenced. Vhetefer ungooeesh ooff spureet it mey cust, I em veelling tu poot tu rest crefee und grooesume-a buns muts sooch es Dr. Struoostroop's. Yuoo mey nut understund thees noo, und I dun't foolt yuoo fur thet, boot yuoo dun't need a preschuul deepluma tu understund thet unsteble-a huuleegunism und soobferseefe-a cyneecism ere-a a metched peur. Feeulence-a is a crootch fur zee deprefeety thet deeshunest ill-bred-types ere-a cepeble-a ooff. Soorpreesingly, zee cuoorts und oooor ilected ooffffeeciels ere-a vey eheed ooff Dr. Struoostroop in imbreceeng thees seemple-a fect.
Frum a poobleec-puleecy perspecteefe-a, tudey, ve-a meeght hefe-a let heem up zee unte-a cunseederebly. Tumurroo, ve-a vun't. Insteed, ve-a veell creeticize-a zee oobfeeuoos incungrooeeties presented by Dr. Struoostroop und hees leckeys. In my feeoo, cumments leeke-a thet dun't seet vell veet fexeteeuoos phlegmeteec preessy-types. I unmeestekeebly hupe-a thet Dr. Struoostroop's ductreenes vere-a intended es a juke-a, elthuoogh zeey're-a nut fery foonny iff zeey vere-a. Dr. Struoostroop's henchmee ere-a nut, techneecelly, feele-a deesrespectffool joonkeees, boot rezeer sheefftless meendless used-cer selesmee. I beleeefe-a thet zeere-a is a smell -- yet nut inturely inseegnifficunt -- deefffference-a.
Dr. Struoostroop is boordened veet a deed veeeght ooff zee must impetoouoos cuncepshuns und prejoodeeces. Zeere-a is nu incunseestency here-a; he-a esserts thet it is bluckeesh tu qooesshun hees ideels. Thet essershun is nut oonly untrooe-a, boot a cunsceeuoos leee-a. Zee vurst keends ooff selff-seteesffied beeg-lebur busses zeere-a ere-a cun gu reeght eheed und cunfeect me-a fur seyeeng thet I myselff recummend thet ve-a preserfe-a zee peece-a, boot Heestury, ecteeng es zee guddess ooff a heegher troot und a heegher joosteece-a, veell oone-a dey smeelingly teer up thees ferdeect, ecqooeetting me-a ooff ell gooeelt und bleme-a. Bettereeng zee vurld is epperently zee lest item oon Dr. Struoostroop's "tu du" leest. Regerdless ooff vhet Dr. Struoostroop seems tu theenk, I teke-a sereeuoosly zee feeoo thet hees seemeengly-igeleeteriun idees leed oonly tu resoolts thet ere-a but puleeticelly-incurrect und unffeur. Let me-a leefe-a yuoo veet oone-a lest thuooght: Dr. Bjerne-a Struoostroop ooves us un epulugy fur threeteneeng tu prumute-a, fuster, und insteetoote-a cunneebelism.
Thunk yuoo fur yuoor teeme-a.
Cheers,
ZicoKnows@hotmail.com, still confusing Sweden and Denmark after all these years
Bjarne:
First, let me take this opportunity to thank you for offering the Slashdot community this chance to interview you. It is highly appreciated!
As I'm sure you're well aware, computer security has risen to the forefront of risks involved with online business(even beyond "nonexistent paying customers"!). From the external risks of network protocol weaknesses to the internal failure of insufficient buffer overflow prevention mechanisms, the number of "weakest links" available to fall against a determined attacker can be quite staggering.
In fact, an attacker is often not necessary to make code fall flat on its face--as many computer users can attest to, software written under several software paradigms falls apart in the face of extended but ultimately normal usage.
My question for you is, as a well respected language designer and programmer, what can we as a community do to deal with these sibling demons of instability and insecurity? Should we adopt languages such as Ada, which place breathtaking amounts of protections into the compile-time phase? Do we move towards the model of simplicity advocated by Schneier, well aware of the exponential increase in unpredictable interactions? Should we worry about the prevalence of interpreted languages as a vector for in-band attacks? What should we be doing that we aren't?
In short, Bjarne...Where To, Fearless Leader?
Yours Truly,
Dan Kaminsky
DoxPara Research
http://www.doxpara.com
were you smoking when you invented C++, and where can I get some? Also, I heard you im plemented mulitple inhertiance just to show some people that you could do it? Who we're these people (assuming they we're the TCH-induced faeries and leprachauns)?
"There is no spoon"-Neo, The Matrix
"SPOOOOOOOOON!"-The Tick, The Tick
Is there any other languages you use eventually? What languages, and why?
Do you think that articles by Jon Katz are retarding America's youth?
I'm hemos., aka Jeff. Bates.. I help run this site, along with Rob. Malda.. I handle books, and generally posting storie
It's kinda scary when you people start out talking sense on a technical subject, and then suddenly start emitting marketingspeak.
If I may drift off on a bit of a tangent, [A-Z]+COM is groovy and all in principle at the very least, but isn't there generally some overhead involved in "marshalling" or whatever they do, and doesn't there have to be some extra infrastructure, often at the OS level? (These are sincere questions: I don't grok that stuff, and I'm interested).
The one feature amuses me most about C++ is Templates. Is the Turing completeness of the template language intended or did it just come into existance by adding needed features?
(For those interested: Template Metaprograms (by Todd Veldhuizen))
Yet Another Debian User
Two questions:
C++ does not have built-in support for multithreading. The unfortunate thing about this is that there are some threading features that can only be implemented by a compiler. In particular, I'll point to monitors - they can very neatly abstract away semaphores by implicitly placing a semaphore on methods. Nifty features like wait conditions can be a very useful tool. As multithreaded software becomes more common, will C++ be extended to include monitors as part of the language?
Could you comment on the proper use of constructors, destructors, and operator overloading?
1. There are many programs which are not famous, ;-) in C++ which causes programs to
or that nobody knows/cares in which language
were written. Among the famous programs that
everybody knows their language, ALL of the C-
based are rock solid and highly stable (for
example: kernels of UNIX and Linux, Apache)
while ALL of the C++ based crash a lot, have
huge memory leaks, security holes, freeze, etc.
(for example: Netscape Communicator, kernels of
Windows). Is there anything inherent (multiple
inheritance
be so unstable and buggy?
2. After reading the famous interview, I started
to appreciate and admire you. Finally, I
understood everything, and thought you were a
genious and a real hero. So thought many of my
friends.
Then, I was very disappointed to read in your
FAQ that this interview was not real. Who did
ask you to claim it? Why did you agree? Were
you afraid of being flamed?
Thanks,
Eli Marmor
marmor@elmar.co.il
Surely polymorphism should be the default in an OO language rather than the other way round?
---
Silence is consent.
Templates are missing a few features, such as defining a class my_class, where my_class requires X to satisfy certain requirements such as implementing certain member functions or operators. Current compilers prevent using an inappropriate X under most circumstances, but it would be nice to have explicit requirements for templates, to better inform the programmer what classes can be used with my_class. Are there any plans to enhance C++ to better support templates? In particular, I'd like to see a better way to implement template metaprograms.
Much of Slashdot's audience uses the GNU set of tools (including the the GNU C++ implementation).
What areas need to be improved in this set of tools to make them more effective in constructing large systems?
What importance do you see the CORBA standard playing in the C++ future?
Are you involved with CORBA and C++ designs and development to any degree?
What compiler(s) do you use?
What do you think about concurency in general and the "one keyword approach" SCOOP proposal as described in Object Oriented Software Construction 2 (Bertand Meyer, Prentice Hall)?
Should C++ implementations be required to provide support for range, type and overflow checks?
Actually, I also read Sweeney's article and I'm reading an Eiffel book right now because of it :-) (Introduction to Eiffel, R. Switzer). It's good to know there's a GNU implementation (http://smalleiffel.loria.fr/) because if the language ever takes off in a big way, the free software community won't have to catch up to anyone.
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Read the rest of this comment...
Assuming that C/C++ is going to remain the One True Systems Programming Language for a long time, I have a question that is purely opinion-based but cries out for your personal opinion as the designer of C++. What scripting language do you feel most closely matches C++ in spirit and implementation? Do you use any of them yourself, to hack together prototypes over larger bodies of code? Do you feel that any of them are advancing the practice of programming in general?
;-)), but you would certainly be a better judge than I!
I noticed in Kernighan & Pike's latest book ("The Practice Of Programming" I believe it is... I gave a copy to a coworker whom I enjoyed sharing a project with) that they give several examples in Perl and Awk, in addition to C, C++, and Java. (I'm going to ignore Java for the time being; I have written plenty of Java code but I feel more confident that C/C++ will run where I want and need it to, plus it's easier to integrate with existing libraries IMHO). What are your feelings on this trend, as evidenced in my application arena by such projects as the mod_perl API to Apache and the AOLserver Tcl API? It may be unnecessary for me to note that Perl seems to be closest to C++ in the way it allows great flexibility (and lets you "blow your whole leg off"
I looked through your FAQ and didn't find anything resmbling this question; the folks at Reliable Software convinced me that the STL offers most if not all of the functionality of Perl to a C++-only programmer, but in my experience it wasn't really an apples-to-apples comparison (nothing beats Perl for text processing, for example). Nonetheless I'm sure that you have some insight as to how well a pure-C++ vs. scripting-and-systems-programming approach scales in large projects.
Anyways, that's all. OOP seems to make my life easier, but user-centered design and rapid prototyping (or just rapid programming) tools like Perl are equally important to getting things out the door. I wondered what you thought of this phenomenon and which tools you select for your work.
Remember that what's inside of you doesn't matter because nobody can see it.
IMO Borland 3.0 is still one of the best compilers out there. It doesn't have a whole lot of proprietary commands, it has very readable help files, and it's fast. Newer compilers do stupid things like automatically initializing ints to 0, making it extremely hard to port to other compilers (you get a compiler error if you try to use clrscr() on microsoft, but your program is totally screwed if you accidentally use the initialize-to-0 "feature" of msvc 6 and try to run it on msvc 5.)
--
The shareholder is always right.
Why do you think there programming holy wars? By that i mean some people only do top-down C and they make fun of C++ guys who do everything in objects and so forth. Myself prefer pascal, but at work I use C++ all day and have no issue. But once i tell someone i prefer pascal to C or C++ they make fun of me.
...agreeing to this intreview?
I ask because the vast majority of questions I've seen are of the "What do you think of language _______?" and "Is C++ really a hoax?"
Both of these questions and a few others are answered in the FAQ.
Don't you have better things to do than waste your time responding to uninformed drivel from a bunch of narrowminded programmer wannabes whose knowledge of software development is limited to what their professor says and what they read on Slashdot?
It's a nifty one.
Some people feel that C++ is rather complex and hard to learn, and that a lot of wisdom is needed not to misuse/abuse its features and to avoid its pitfalls. In view of that, what is in your opinion the best way to teach C++? rmstar
For example, why is there not keyword to specify a class can only be newed and not constructed by embedding? Without one there is no enforcable method which allows a class to be derived while enforcing allocation.
Second, why didn't C++ provide a template equivenlent of "..."? The solution to type safe templates without allowing a general argument array requires specifying a massive list of templates for all possible sets of arguments, which is quite a pain.
Last, why isn't there a method of adding non-virtual methods to a class outside of its definition?
Thanks,
--Karl
On the GCC mailing lists often (but not as often as, say, two years ago) questions about C++ mention your "3rd edition" as if it were the authorative text on C++. However, my fellow C++ guru's sometimes have to point out that the final ANSI C++ standard deviates from your text.
Will you be writing a 4th edition soon to help out all these people who don't want to buy the standard and still have an up to date book ?
Thanks in advance,
Toon "If you can't do it in Fortran it isn't worth doing" Moene
toon@moene.indiv.nluug.nl
Reading the C++ newsgroup, you FAQ and an interview with A. Stepanov, I had the following successive realizations:
What I call meta-template is the ability to templatize the contraints put on template parameters. I envision this with the added ability to add "categorizing" template argument, where the programmer can specify the relation of categories (inheritance) and conversion. Example of simple categories: const, volatile, sorted. Then think about the relation between const and non-const and apply to other categories.
So my question is: what do you think is the "next level" of generic programming? Do you see such an evolution as I described, or something else?
Pierre
Are you happy with the way your baby has gone and developed since you gave it birth in the world.
Which features of C++ do you wish you hadn't added?
"Though it may take a thousand years, we shall be FREE."
The 1980's had plenty of anti-OO discourse. It took a long time for OO to be accepted, especially C++.
After twenty years, it has become clear that while OO is not a panacea, it IS effective, it does work, and does increase productivity (by a small amount).
-Stu
Unlike Ada or Java, C++ currently has no facilities that allow a programmer or software engineer to ensure that a fault (e.g. a pointer error) in one component does not cause errors in another component (the facilities that C++ has are advisory).
The traditional answer has been to use better overall software engineering and design. But that does not work in a world in which components come from various different sources with different standards and coding conventions.
Java has many problems, but it does have a commitment to runtime safety and fault isolation. And Java's promise really works out in practice: we can combine dozens of independently developed components and trace any software faults to specific components reliably. We'd like to have the safety and decomposability of Java with the efficiency and control of C++, but given the choice, safety and decomposability usually win out for day-to-day applications for us.
So, what does the future hold for C++ runtime safety and fault isolation? Will future C++ standards mandate more facilities than exist right now? If not, how do you think C++ can survive in a world where software is composed of hundreds of independently developed components?
GNU C++ has the dinky (IMHO) feature in that it lets you nest function declarations ala Pascal thus ..
void grandaddy_function(void) {
int eger;
eger = 2;
void daddy_function(void) {
void sprog_function(void) {
int eger;
eger = 5;
printf("eger == %d\n", eger);
}
}
printf("eger == %d\n", eger);
}
Will print out
eger == 5
eger == 2
I know the rationale for not including this feature in 'C' (overly complex to implement) but not for non-inclusion in 'C++' (apart from religous issues due to Pascal aversion, which I'm sure no one with any claim to intellectual respectablilty addles their mind with). It is a useful abstraticion sometimes, and avoids the overhead of having to create an entire object just to inherit one or two small methods..but
that's my humble POV.
What is yours?
/usr/games/fortune > ~/.signature
BZZT -- doesn't parse because neither increment returns a valid lvalue. But, drawing on the obscure unary plus operator, we can get:
+C+++ + ++C
Which, I think, is the maximum amount of plusses we can hope to get. Let's name a language after it!
Smalltalk was the biggest advancement in programming over the last 20 years. It brought us the GUI, the IDE, the mouse, the symbolic debugger, the class browser, and platform-independence back in 1980.
Given the choice between slow development & fast execution vs. fast development & slow execution, most businesses would choose the latter (as soon as it becomes feasible to have "slow execution" on the hardware of the day).
Smalltalk grew in popularity in the 1990's and has only begun to shrink since 1996 and the introduction of Java. It was more than an amusing tool - major production systems at banks, telcos, and utilties are running to this day on Smalltalk.
-Stu
This thread doesn't have enough good trolls. MORE TROLLS! Increase the noise to signal ratio!Blerg. Eat kitty. thank you
I read somewhere that C++ cannot understand dates past 01/01/2032. If this is true, how are you/we going to fix it? I think that most Windows programs and the OS itself is written in C++, so is this THE bug that we need to work on for the next 31 years? Or have I been misinformed?
Why not to include a bigger 'operating system abstraction' in the C++ standard library? This is the way to get into the true 'component software development process'. Currently if I want to get some C++ library that do need networking it HAS to relly on another library that do networking and that surelly will depend on a specified OS... I cannot find first order components for C++; they are all second or third order; and we know what this kind of things imply... plataform dependecy. Why not to include, let say, POSIX for example into the C++ standard library? I know, C++ is intended to run on the smaller computer ever build, but it was also C and the 'file' abstraction that days was also a big step. I think it is time to expand the standard library; we need to relly on a bigger 'operating system abstraction' to let the component stuff emerge; as I see it's happenning in the Java world.
Why do these keywords make the members for the class that they apply to completly inaccessable rather then simply unchangeable?
If the language could have been set up to allow other parts of a program to look at them but not change them (much like a const), then why wasnt it?
They guy who invented DOS said he regreted it hiw whole life. Do you regret having invented C++?
That was the title of an op-ed posted at DDJ a couple years ago.
CPAN is a collection of free, downloadable modules that can be use'd in your Perl programs. It's a wonderful resource and the true strength of Perl. Code gets written once and used and tested by many. Over time the modules just get better tested and more robust. Everybody wins.
Why doesn't an equivalent CCAN (Comprehensive C++ Archive Network) exist if C++ truly is reusable?
iirc, this is why the"export" keyword was added to the language. however, last i checked, no compilers (at least no compiler that i used or had been told about) supported this keyword.
If I don't put anything here, will anyone recognize me anymore?
Now that C++ is standardized, when, if ever, do you think the first standard-compliant compilers will be available?
Will we ever see the day where C++ is as portable as C?
What is going to happen to code that breaks with standard-compliant compilers? (I suspect, for example, most Windows code is written expecting a failed new to return null instead of throw an exception. A standard-compliant compliler would be a very unwelcome thing in this particular example.)
if speed is everything and native assembly is faster than C, why don't we all still write in native assembly?
Speed isn't everything, but it's an important thing. With C vs. assembly code, the payoff in maintainability and whatnot far outweighs whatever small loss in speed there is -- and you can always tuck in some inline assembler when it's absolutely necessary. C has turned out to be very close to what many programmers consider an ideal compromise for many purposes, and a lot of programmers are pleased with the slightly different compromise offered by C++. Smalltalk, like LISP, appeals mostly to people who tend to get enraptured by the intellectual beauty of a language without stopping to ask what it may cost them at runtime. Now don't get me wrong; I happen to be a very loud and untiring advocate of Scheme/SICP for CS education. All the bits'n'bytesy ballbusting with C/C++ is of profound importance when you're writing production code, but for beginning students (IMHO) it just tends to obscure the general concepts that they really need to be mastering first. For instruction, you've got an entirely different goal, and so the optimal solution is different. My understanding is that Java is making a lot of progress in education: It's just a much cleaner OOP language than C++. It lets you concentrate on OOP without losing sleep over memory allocation and whatnot.
All of the above is IMHO and YMMV and IANAL, obviously
Anyhow . . . C didn't only become popular because it was (largely) source portable, either. It's just a really damn pleasant language to program in. People like it. The relative source-portability merely did not prevent it from growing.
The C++ ARM is a real pleasure. Thank you.
What languages, language features, aspects of comptuer languages, or programming tools do you find most interesting these days? Why? Why not?
[MD]r\. Stroustrup:
It's been alternately suggested that template metaprograms are either a monstrously idiotic waste of time, or else an awe-inspiringly cool hack. Personally, I refuse to recognize any distinction between those two states of being. Do you agree that they are, in fact, synonymous, and that people who mutter and roll their eyes about "wasting time" are the only people whose time is truly being wasted?
apologies for the brevity of this comment ... i don't have any reference books on hand?
why are c++ templates so awkward? what can be done about it?
i can write code in maybe a dozen languages, and i still can't get templates to work properly most of the time. modula-3's generics are much nicer.
OpenSource programmers can write code in whatever language they want. Consequently, they write a lot of C, Perl, and Python. But with some notable exceptions, they don't write C++.
Contrast that with the lanuages programmers use at work, which are primarily C++ and Java.
It can't be entirely explained by the size of the programs written either. And as your FAQ says in the section C is better than C++ for small projects, right?, you believe that any C program can be better written in C++.
So why the disparity then?
Lightweight, embeddable languages have been getting a lot of attention recently, especially for their use in computer games like Quake & Unreal. What's your opinion on the current state of scripting languages and how they complement C++? Would you like to see an interpreted or bytecode-compiled version of C++?
Two related questions:
Since Mr. Stroustrup has lived in Scandanavia, England, and the US, he has surely noticed a few differences. But I would like to suggest that working in a research institution like Bell Labs is not the same thing as working in real American business.
The reason I ask is because I worked on a large C++ project at a Fortune 100 corporation that lasted for several years. It incorporated virtually all the bad features of American business: fast-talking consultants, clueless managers, greedy contractors and cowering employees predicting disaster. We wrote thousands of lines of C++ code, and then threw them out and wrote more. Architecture, specifications, planning? Who needs 'em with a deadline to be met?
One of the things I noticed about US C++ programmers, particularly contracters, is that they were ruthlessly competitive. The idea of using someone else's classes was completely foreign to them. Any time anyone gets an assignemnt, the first thing to do is discard all prior concepts and classes, and write his own. This means that everyone is striving to impose his own will on the project, and incidentally billing for huge hours spent designing and writing classes that only he would use. Eventually, the money dries up and employees are left to maintain a montrous mismash. I'm sure we used every C++ technique ever heard of--we've got multiple inheritance from templatized classes, we've got objects with global scope singing and dancing before main is called, we've got our very own string class that does much more than the STL implementation--but no one would say this is good.
It would seem that the competitve American ethos is not so great when it comes to using languages that require cooperation, coordination, and subordination. Not everyone on a project can be the master class designer. But when it's every man for himself, watch out!
By the way, when the project was winding down the phoney IEEE interview was circulated. Everyone found it very funny, especially the contractors who took $25M off of us.
With the advanced compilers and computers of today, do we really need to keep using C++? The cost of running a garbage collector is no longer an issue, and eliminating memory management would fix many bugs and crashes. Many newer languages have much clearer syntax, module management, and standard base classes.
Why should a development team pick C++ as the language for its next project? Has the time come for newer languages?
I quote your FAQ:
This single FAQ entry seems to imply that Free Software sucks, that they are old, and only 'floating around', and that GNU/Linux would'nt be a decent platform for programming ...
It seems like C/C++ is being touted as the next step after VHDL/Verilog for hardware design. I believe the most significant reason is to enable hardware-software codesign.
Do you believe hardware-software codesign is necessary today? If not, when will it become a necessity? Is C++ adequate to fulfill the hardware-software codesign role, or should a new language be developed for the task?
Wow, didn't know posts could get higher than a 5... Myself, I think there should be no limits, I wanna see posts that go down to -5.
Hi, I wanted to start by saying I consider you to be a god, secondly, I just bought C++PL SE at B&N. It is very well done. Now I just have to do decide what to do with the third edition. Ok, now, What are your feelings about C99? I've seen some replies to this extent from you on comp.std.c++ but nothing that truly addresses it. Do you see it being integrated into the C++ standard in 2 years when it can be updated? Do you think it would fit in elegantly? Do you think C99 is now a viable alternative to C++? I personally never use C89, but there are features in C99 that do seem attractive. Any input would be appreciated. Thank you for your time.
Templates have these advantages:
- compile-time type safety
- performance (no dynamic binding - function calls can often be expanded inline, avoiding a function call altogether)
OO has these advantages:- simpler programming - you can get some extremely long compiler errors when working with templates
- less code bloat
- it seems unfortunate for so much code to be in header files instead of
.cpp files (circular #include's can be fun)
The craziness over template-orientation seems counter-productive to me. Templates are a great feature of C++ and they are the only reasonable way to solve some problems in C++. However, many now seem to think they should be used to solve every problem. I agree that compile-time type safety is a Good Thing, but are we making an intelligent decision given that:- dynamic_cast allows safe downward casting in an inheritance hierarchy
- Moore's law is still going strong : most people writing application software really do not need to obsessively count CPU cycles any more - choosing the right algorithms is more important than an O(1) improvement. Was it Knuth who said "premature optimization is the root of all evil."?
CPU cycles are becoming more and more plentiful whereas talented designers and programmers are not. Template-orientation seems to make the wrong trade-off. I know that TO and OO can be used together in one program, but they are very different ways of achieving re-use. When should one be favoured over the other?How will C++ and Java fare on Explicitly Parallel Instruction Computing processors, such as the Itanium? Will the emphasis on compiler optimization of instruction scheduling widen the performance gap?
How do you like Java?
What are your views on the success and the future of AI?
:wq
Methodology is the study of methods. The sentence "when other methodologies are more appropriate" therefore makes no sense. The proper word to use here would be "methods". This error seems to be common and rarely corrected so I thought I'd point it out.
Working in a university has allowed me to observe many different programming systems and standards. With the introduction of namespaces, strings, etc. I've witnessed many professors lose control over software design in their classes, etc. due to new standards. We've been forced to redesign our project submission systems within the department, while different systems seem to require changes, giving less portability, etc. Most every advanced programming class' listserv is ablaze with 20 postings a day or more. When the standards were changed and we began to read C++ 3rd. edition, many of us were stunned to see these changes, especially namespaces, and did not agree with them until months later, once we understood your purposes in creating them. My question is this : Do you feel that recent standards have hurt implementation of the C++ language, or was it a necessary step in the evolution of the programming language?
What do you think about John Ousterhout's ideas presented in this article?_ Do you feel his critique of the OO pradigm is correct? Don't you feel object-oriented programs are extremely difficult to reuse parts of? (for example, it is a most unpleasant task to deal simultaneously with two libraries assuming different type hierarchies).
Recently, the subject of C++ bindings for SQL have come up as an issue of discusion on the library reflector. Not having C++ bindings for SQL is a huge mistake--what are the future plans for this?
also CORBA...
The number of one-language zealots on this site is pathetic.
"The language I use works for everything I do, therefore it works for everything."
"The Linux kernel and most of its utilities are written in C, therefore OOP is a failure."
"I don't understand C++. The syntax and concepts are confusing. Therefore, C++ sucks. (The convoluted and easily-botched syntax of Perl is fine, though.)"
"I know about this project that was written in C++. It was mismanaged and went way over budget and past the deadline. Therefore, C++ is a bad language."
"I'm a complete moron who couldn't read the FAQ before posting. Is that fake interview real?"
"I shouldn't have to deal with memory management and pointers in a language that allows for low-level systems programming."
"Not all compilers fully support all of the C++ specification. This proves that C++ sucks."
Did I leave any out?
Mr. Stroustrup,
I can't help but think C++ has suffered terribly from the loose standards when it comes to object formats, library formats, template schemes, etc.
I realize it was required for its initial acceptance in the industry, but over the last 5 years it has proven to be a huge hindrance to the cross-platform tools industry.
Is it time for C++ to finally cut the ties with C?
How did you come to live in New Jersey and do you ever wish ATT Reasearch was some place else (perhaps some place closer to a larger city)?
_joshua_
.... way overkill. Keep it simple! Having member funtions that are insonsistent with other STL ontainers is weak....Please--if you have to do it all over again, if you could do it all over again, what would you change about the standard library, both in STL (allocator??) and in iostreams (callbacks that can be called from istream, with a basic_ios* for instance), in numerics, etc etc etc.
Are you mad at how they butchered C++ with JAVA? Specifically in how it gives you about a quarter of the power you have with C++.
MOO
Go play in traffic ya troll.
C++ has given features, like virtual base object initialization, that get added to code behind the programmer's back in the form of short code segments. The C++ definition defines the end functionality of these segments, but doesn't define a standard way to define them.
I am defining my own language as a school project; do you think a standard way to define code segments into keywords would be a good way to get OOP flexibility and extensibility? (as in:
keyword baseclass::virtual
[method=appendToBeginning, where=constructor]
(long *theVar, ~~~~) {
}
Where is my mind?
mfspr r3, pc / lvxl v0, 0, r3 / li r0, 16 / stvxl v0, r3, r0
Check out Project Upper/Mute, an all-around awesome compiler fra
It somehow irratates me that it seems to be impossible to hide everything other than the interface in .h files.
Is there any possible way where the public and the private declarations of a class can be stored in separate files like in the newer Wirth languages? If C++ had opaque types it would be the perfect language for me...
I look forward to any successor languages and tools, as I'm painfully aware that our choice of language greatly impacts the techniques and results we are capable of framing.
I have a number of years experience of becoming comfortable with the core features of C++ (and some more esoteric bits). I've avoided common use of templates/exceptions because of portability and implementation fears. I think my first question has sort of been alluded to already, but I'm going to restate it in my words in case I'm misinterpreting others questions:
Do you feel this is a significant enough technique that it would be considered for future languages (C++ derived or not), or is there a good way to accomplish this in C++ now?
Keep up the good work.
-- There is no truth. There is only Perception. To Percieve is to Exist.
How do you feel about C++'s development into a template for a universal syntax for other languages? Is it appropriate to continue using C++ as a guide for other languages? Java, JavaScript, Perl, and many other languages have parts or are comprised almost entirely from C++ syntax. Should this trend continue? Thanks, Travis forkspoon@hotmail.com
Modern computer languages seem to have smaller lexicons and more abstraction - making them easier to learn. In the future, a voice controlled editor and an advanced language could allow computer programs to be written in limited natural english*.
In other words, a computer program could be written to be understood by any English* speaker, with hopefully decreased training time and improved teamwork.
Do you foresee any possible use for a "natural" programming language?
*English is my first choice since I speak it; other people may differ.
However, used improperly, C++ can make code extremely hard to read. While you can certainly make code hard to read in any language, C++ provides many more tools which can be used to shoot yourself in the foot. I think that this is the source of most complaints about C++'s complexity.
I recently had it argued to me that C++'s biggest weakness is that in the hands of those who doesn't yet understand why to use specific features, it easier to write bad code. I've seen the horrors that a template, exception, or operator overloading used in the wrong place can be. The world is full of programmers who don't necessarily understand why certain features aren't always appropriate. While I'd prefer that we work to improve the quality of programmers, and make sure that anyone coding C++ be taught that critical why, I don't see it happening. not going to happen. So this argument against C++ remains compelling to me. (Fortunately it's not compelling enough to stop me from coding happily in C++.) What are your thoughts on the matter? Do you feel this is a weakness of C++? Is this issue not nearly as serious as I think it appear?
Search 2010 Gen Con events
It seems to me that a lot of the programmers who prefer C++ do so mainly because C++ is what they were exposed to in school, rather than other programming languages and other systems of OO programming. The reason I've learned C++ (rather than simply C) is because my university decided that C++ would be a good language to teach students in the process of teaching computer science. This is an interesting choice, to say the least. Besides all the difficulty of the strict memory management required by C, many introductory computer science students struggle with C++'s implementation of templates and operator overloading - two programming models which seem to complicate the language a lot without adding much in the way of new functionality or useful structure.
Where do you see C++ in relation to education and it's role as a student of computer science's first programming language?
I'm not a smorgasbord.
Stroustrup works at Bell Labs Computing Sciences Research Center in Murray Hill, NJ. Other past and present inhabitants of CSRC include Dennis Ritchie, Brian Kernighan, Ken Thompson, Rob Pike, Al Aho (also Sethi and Ullman) and pretty much the rest of the pantheon. Stroustrup is actually not one of the most revered people there, scary though that may seem.
Bell Labs Computing Sciences Research
Bell Labs Index
Seeing as how most of the other slashdot.org posters have covered most of the questions about C++ I have a few that deals more the general state of programming. Also I apologize to the slashdot moderators for more than one question but I feel like these might be important questions.
1. What do you think about the OpenSource movement?
2. Assuming the answer to #1 was favorable, have you ever considered helping out with OpenSource C++ compilers? Hehe you know just for fun? :)
3. What do you think about Linux? Have you ever thought "Linux (or *nix for that matter) could be so much better (ie. secure, faster,etc) if it was written with C++?"
4. Do you think that source code is a valid example of free speech and therefore qualify to be fully protected under the First Amendment?
5. What do you think about UCITA? DMCA?
6. What, if anything, would you wish the United States government would do (or not do) to insure the prosperity we are seeing with this digital revolution?
7. Pres. Kennedy once said "Ask not what your country can do for you but what you can do for your country." From a programmers stand point do you have any thoughts on what we programmers can do? (Besides get high paying jobs so they can tax us a bit more)
Well that's about all the questions I have. I hope I haven't gone too deep but I would like to see how you feel about these things.
To the moderators: I realize that I might have included some 'corny' questions or just ones not worthy amonst ones that I certainly hope are. I give you permission to "line-item veto" those questions which you do not feel should be past on.
Thanks for your time
I didn't wish to post as Anon but didn't get my password in time
Kernel Corndog
In the name of God, WHY? For the love of all that we hold sacred and holy, WHY?!?
One of the the features that C++ can be said to lack, as a high-level language, is a garbage collector. Or rather, it's not so much that no collector exists (the Hans Boehm conservative C/C++ garbage collector is one, after all) but the fact that it isn't well integrated in the C/C++ API.
Do you regret this? Do you think someday we'll have a decent programming language with a garbage collector (i.e. one which is well integrated in the language and not just an add-on)? Java might have been just that only its eficiency (notably that of the GC) was terrible: do you think that was a necessity or just a consequence of the wrong decisions being made?
Was there no way to avoid having private members (data and methods) of a class in the main definition of a class?
One of the ideas of OO is information hiding and encapsulation of implementation details.
Private data members declared in a class definition used by external objects runs counter to these OO concepts. Other objects are supposed to be "blind" to the inner workings of the object and yet see private methods and data members.
IMHO it is also a major hassle in the earlier stages of a new project or new additions to a project, when changes in the inner workings of classes are frequent.
I realize that part of the problem is the need to know the size of the object for memory allocation purposes.
Did you think of this contradiction when designing C++ and were there any attempts at solving it?
Do you want to see anything added to the standard C++ library that is not already there? (For example, a standard set of design patterns.)
Along the same lines, do you think sockets and graphics should be standardized as part of a language?
Most programmers that I know prefer Java, the programming language, over C++. What they dislike about Java is the VM and bytecodes slowing everything down. Hence my question
The problem I see so far is that on the Java side there is the problem of making exceptions faster, which are notorious for slowing down C++ code. And Java has to deal with garbage collection, which you say in your FAQ can be added to C++. Yet, despite its obvious benefits, nobody seem to do.
{~/cc_exer}g++ nested_func2.cc ...)'
.)
nested_func2.cc: In function `void grandaddy_function()':
nested_func2.cc:5: parse error before `{'
nested_func2.cc: At top level:
nested_func2.cc:11: parse error before `}'
nested_func2.cc:12: `eger' was not declared in this scope
nested_func2.cc:12: ANSI C++ forbids declaration `printf' with no type
nested_func2.cc:12: `int printf' redeclared as different kind of symbol
/usr/include/stdio.h:250: previous declaration of `int printf(const char *,
nested_func2.cc:12: initializer list being treated as compound expression
nested_func2.cc:13: parse error before `}'
{Mon Feb 21 14:30:03 llewelly@brownie 65 1064}
{~/cc_exer}cat nested_func2.cc
#include
void grandaddy_function(void) {
int eger;
eger = 2;
void daddy_function(void) {
void sprog_function(void) {
int eger;
eger = 5;
printf("eger == %d\n", eger);
}
}
printf("eger == %d\n", eger);
}
In other words, GNU GCC does not support nested functions in C++ mode;
the are only supported in C mode.
You should also run
$info gcc
and type 'gNested Functions' and read the caveats about using gcc's
nested functions; they are not true closures, and very error
prone. (Think about what could happen if you took the address of
sprog_function() and passed it outside of grandaddy_function(). If
you still do not see why, ask me for more details, at llewelly at
198 dot dsl dot xmission dot com
I do not know whether c++ *should* support true closures; I can
think of arguments for and against; but I personally do *not* want
the error prone 'nested functions' extension provided by gcc.
1) x moderates post down
2) y moderates post back up
3) x posts to story, erasing moderation
does this work?
I find C++ to be an excellent language for the work I do. I really think you did a heck of a job creating it. I have a lot of respect for you. I was wondering if you have ever tested you IQ, and if so what is it?
Jason
I think we all deserve an explanation for this one. :)
I know it sounds cliche and contrived, but OO is just a different paradigm. Most of the process of OO analysis involves identifying objects. Instead of breaking the program down into chunks that seem easy to implement, you have to imagine that you have a complete system and determine the logical parts that comprise it. Design patterns are a great asset here, because they describe components that are frequently encountered in OO designs and therefore easy to identify.
It's hard for me to explain how to think about OO without sounding contrived - it's something I didn't really understand for a long time myself, until a few lightbulbs started going on in my head, and it was like a revelation. Fundamentally, it's simply a method for modelling your problem more accurately by way of a greater level of abstraction. Unfortunately, only a fraction of the programmers out there really know how to do proper OO design. It's really NOT taught very well at all. None of the University classes I've taken have done a very good job. It wasn't until I read Design Patterns and Object Oriented Software Construction and started to use patterns in practice that I really started to realize how powerful and elegant OO is. I first learned how to program using OO 6-7 years ago, and had been using it in various projects for a good 5+ years before I really started to "get" it. All that time I had thought I was doing OO programming. I was really just encapsulating some of my data and functions in objects, and creating inheritance hierarchies to reuse code (that is NOT what inheritance is for!)while the design was really still procedural.
Maybe this is why you haven't been able to see a use for OO outside of databases. A lot of books I've read describe classes as being structures which hold data and have methods to act upon that data. You COULD describe them that way and technically be right, but logically it makes no sense at all. Objects (classes) are a lot more than that. It isn't the objects you build that make up your system, it's how you put them together. The relationship between objects in your system is far more important than what any single object actually is. I also frequently hear the mantra that OO is designed to allow you to build "reusable software", and that's ALSO very misleading. The key idea isn't that you use your classes in many different places in several different contexts (that's only going to be true for things like frameworks or utility classes). The reuse comes from the fact that a well-designed OO system is changeable - you should be able to make changes to your program without evoking wide-spread modifications.
I would highly recommend, if you haven't already, read the book Design Patterns: Elements of Reusable Object Oriented Software, and take everything the authors say to heart. Especially the first part of the book (before the actual catalog of patterns). I have heard other posters on Slashdot comment that this book literally changed their life, and I would have to concur.
PS, I hope this message doesn't sound overly condescending. It's just that I used to think OO was useless, just like many posters in this thread. But I can't help but think that you must not be seeing what I am if you're having trouble modelling everyday problems using OO. Feel free to dispute any of the points I've raised or tell me if I'm full of crap. I've been thinking about writing an essay debunking some of the myths and misconceptions about OO and clarifying what *I* think it's all about, and I could use some critical feedback.
What style do you use for placement of braces, indenting, declaration, etc...
In your FAQ, you say that you are working on "fundamental ways of improving the tools and techniques we use to build large real-world systems."
That's been on your FAQ for at least 3 years now. What can you tell us about this work? What have you found?
You describe C++ as a multi-paradigm language and this is certainly well supported by Coplien's recent book. I do not see Java as a significant progression in terms of computer languages, so what do you see as the next paradigm shift/evolutionary step for computer languages?
Is a truly open virtual platform the next step, or is there an area of syntactic sugar that we have yet to discover and explore?
There is folly and foolishness on the one side, and daring and calculation on the other. - Admiral Pellew, Hornblower
Although OO won't shield bad or ignorant programmers from their own blunders, it does beat procedural programming hands-down conceptually. The opportunities it offers for improving program correctness, robustness, extendibility, reusability, portability, and ease-of-use are enumerated at length in _Object Oriented Software Construction_ by Bertrand Meyer. Grab a copy, you'll learn a lot!
You're always at someone's mercy. The standard library implementation. Your lazy coworker whose code you always have to double-check because they're a putz. The OS. Your own errors.
And the fact of the matter is, your friend is right. It won't be until JDK 1.3 that a Java implementation has a first-class garbage collector, one that truly begins to exploit the qualities of a well-behaved memory pool.
-
Just because it works, doesn't mean it isn't broken.
Text based languages are simple to design, implement and port. However there are some compelling advantages to be gained from a binary based model. Possible gains include better presentation, source control and templateling.
Do you forsee a move away from text based languages?
Henry Fnord
"Is it true you treat women like objects?"
(And I will avoid the comments about references to private parts...)
"Trademarks are the heraldry of the new feudalism."
You are one of those who "reinvented" a language. And you made a fundamental move by giving macro-assembler C style the true aspects of a language. In one way you were not alone. Somehow your move was made in a time when several languages tried to turn "objective" or "procedural". It was a great move that gave programming languages a property of high flexibility.
Than there was a big gap. And suddenly we had Java. However there was nothing fundamentally new on it. Theoretically I mean.
What do you think about this? Have we reached a theoretical limit in the technological bounds of modern computing? Have "theoretical" programmists lost their "inspiration". Or have we reached "Finis Terra" of the programming sciences?
prononce your family name. Our C++ teacher said : "here how it's written, make your own idea how to prononce it ". Hi this is Bjarne Stroustrup and I pronouce Stroustrup : Stroustrup.
Embrace and Extend. It's what condemn Microsoft for doing. Embrace a standard, then extend it so no one else can use it without you.
Yet this is precisely what glibc is doing. It's taking a language and library that is firmly standardized, then adding its own extensions, so that developers end up being locked into the GNU toolset. I tried to compile a program that other day on Solaris. It failed miserably because it depended upon GNU extensions to the "standard" C library. Sure I can load up glibc to run it, but why should I when I've got a perfectly capable and standardized libc? GNU libc tries to be everything including the kitchen sink (sound familiar?).
GNU would do everyone a lot better if they kept their extensions separate from the standard.
A Government Is a Body of People, Usually Notably Ungoverned
What do you think of the Mozilla C++ Portability Guidelines? My personal view is that the guidelines can be summed up in one sentence, "Program in the dark ages of C++". Unfortunately there still seams to be a need for it. Because so many major C++ projects still go by similar guidelines, Mozilla and AbiSource come to mind, I fear that my Aspell project will never get used by them and in general does not used nearly as much as it could.
Do you think that that the portibility guidelines are still needed?
What is your opinion on this alleged "speed penalty", and do you think future versions of the language and/or compiler technology will be able to reduce or eliminate it?
...Open Source isn't the only answer -- but it's almost always a better value than the alternatives...
The result was a language with C++'s semantics (at that time) and a much cleaner syntax. Which, of course, went nowhere. Do you have any comments on SPECS itself or any other attempts to improve what might be called the "human factors" aspects of the C++ language?
Babar
If you want to invent a new language again, how will it be different from C++ ?
In your book _The Design and Evolution of C++_ you ocassionaly talk about what would happen if you designed a language that wasn't backwards compatible with C. You mentioned how it would be an expression-oriented language like Algol68, and how it might have things like multi-methods.
You also went on to say it'd be nice clean language that no one would use (perhaps it would have met a fate similar to Dylan's). Just for fun, what else would your dream language have? Would it have the same semantics of C++, just with notational ease?
We prefix "0x" and "O" respectively for hex and octal literals, but there is none to designate binary.
i.e. 0x10 hex = 020 oct = 16 dec
Why can't we use "0z" for a binary number?
i.e. 0z10000
Cheers
From the headquarters of the C++-Haters Association...
Seriously. Like many of the posters so far, I program in C++ every day. Unlike many of those, I _really_ hate it. It's probably a question of cultural differences: I was raised on Lisp, and, even though I'm not really religious about it, I still find C++ to be, all in all, an enormous kluge.
I really do wish I could move to another language, but unfortunately, the Lab standardised on C/C++/Fortran some ten years before I got hired, and I don't really have a say about it.
So the point of the matter is: what can you, Bjarne, do for me, Kaufmann? Can you at least post a memo saying something like: "To the Mgmt. and J. Clueless PHB: C++ is _not_ a god-send. Not _all_ programming should be done in C++. Alternative language research _should_ be encouraged. Sincerely, - The Bell Labs gang"
Thanks for the time,
-- Rafael Kaufmann, CPPHA member
(Note to moderators: not a flame, not a troll.)
To the editors: your English is as bad as your Perl. Please go back to grade school.
Given the rise of such quirky languages like Perl and Python, which both use weaker typing, automatically garbage collect and provide associative arrays, would you add or remove any features from C++? Would you provide for more robust string handling?
Some time ago, object oriented programming was the next "big thing" (or "paradigm" if you prefer) of the future. Now it is obviously the "big thing" of the present. What do you think is coming next? A lot of people (especially here at CMU) seem to think that it will be type safety--do you agree?
It seems that the overall trend in the evolution of programming languages is to look at the usage patterns and idioms of the previously existing ones, and implement these (thus standardizing them) in a new more abstract language. Or, in short, putting keywords on concepts (for instance, a C++ pure virtual class is now an 'interface' in Java).
However, this is done in detriment of finer grained control, and forcing things into abstractions in which they don't belong. Not every inheritance tree can be reduced to single inheritance and interfaces (you sometimes need multiple inheritance), not everything has to be a class (you sometimes need functions and basic types), not every flow can be modeled with if() and while() (you sometimes need goto), etc...
As such, you can find yourself writing very ugly code into a normally "clean" language just because reality says otherwise.
On the other hand, C++ tried to cover a very large area in that regard, but that is often what people don't like in it : too many features, or, too much freedom.
As the level of abstraction in programming language goes higher, both problems can only get worse. So I have a two questions :
Java, after the hype (Score:6, Interesting)
...
Moderation Totals:Interesting=6, Total=6.
Though I wouldn't want to start .advocacy, Java, though cleaner of syntax than C++, is still sufficiently heavy to require "heavy lifting" to be written well. When it comes to use in universities however, more elegant languages like Java are preferred over more baroque languages like C++ just because it has less language constructs to teach / shoot yourself in the foot with. The touted advantages of C++ - efficiency etc - are not the prime concern of universities, nor should they be.
eLisp's hardware-agnostic design made it a total failure? How Perl's has killed it? Or Python's?
Speaking of Smalltalk, were you aware that the most popular Java IDE at the moment is written entirely in Smalltalk?
As others in this thread have already stated, and as has been stated since time began, ad nauseum, raw number-crunching isn't everything it's cracked up to be. Remember that class where they told you the right algorithm will beat the socks off of the wrong algorithm implemented cleverly?
Well, this is exactly the same thing. You can spend all day bit twiddling, or you can fix the problem in a better way.
-
Just because it works, doesn't mean it isn't broken.
Do you feel that although C++ is a great language, people have forgotten about C? I refer to the fact that, as a college student, I have had C++ rammed down my throat since day 1. Luckily, I did a bunch of C programming while in high school, so I know stuff like printf and malloc. Most of the people I'm graduating with don't know any of the original C syntax. Teachers no longer accept things that are not written in an object oriented manner. I feel that it has sort of diminished the idea of 'hacking' or 'kludging' code...which was one of the main reasons I became a programmer in the first place.
What do we do when a major C++ compiler vendor refuses to migrate to the international standard?
The first language extension, covariant returns, proposed to the standardization committee and accepted in 1992, remains to be implemented in VC++6.
The scoping of variables declared in for loops also remains incorrect.
This causes major headaches for software developers who must compile on VC++6. They are useful features, and we wish to use them. Yet, a rogue compiler vendor causes us grief.
I'm not sure it is in Microsoft's best interest to conform to the standard. These longstanding bugs show no sign of being fixed.
How long before Microsoft starts adding new keywords to their C++ compiler? How do we programmers in the trenches cope with this?
--
--
Marc A. Lepage
Software Developer
The lack of automatic garbage collection in C++ turns it into a memory leak nightmare. Why did you neglect to specify this as a feature of the language?
Unless your definition of "fad" includes languages that have been around, AFAIK, nearly as long as computers..
Daniel
Hurry up and jump on the individualist bandwagon!
When designing C++, why didn't you make less things implementation dependent, undefined, and optional? As it is, developers often have to code to the lowest common denominator in any case, or deal with code that is very difficult to port. (for example, the sizes of the basic datatypes are implemntation dependent, while the values of many expressions are undefined)
MACHINE
ASSEMBLER
FORTRAN
PASCAL(arguably) and other same-generation imperative.
C
C++
Each has been more or less a descendant to the previous "best of breed", and added features that were required for the next level of programming style.
What do you see as the next logical set of features that will demand a new language?
Kevin Bealer (kbealier@stny.lrun.com)
Hi Bjarne! First, let me say that you are a god. Neglecting all other comments and complaints, C++ is the most powerful programming languages ever written. I read the Design & Evolution of C++ and found it to be wonderful. My question: What is the point of C++ namespaces? It seems to me that they add a layer of complexity without providing much value. In what circumstances do namespaces add value or solve a problem? Kind Regards, Kyle Lussier iWorker, Inc. www.iWorker.com
if(bar) {
foo();
}
OR
if(bar)
{
foo();
}
OR
if(bar)
{
foo();
}
I think the (left shift/extractor) op is used for output because it has very low precedence so the does not get in the way of evaluation of most expressions placed between the s.
What do you see as the future processes for a world-class C++ team responsible for large scale SE projects? The classical waterfall and other processes seem to be unworkable in internet-time (which everything seems to be nowadays). What replaces it? How will the requirements, development, testing, and support be provided for MLOC+ size code in C++?
Chris Cunningham
From your FAQ, it appears you have strong opinions on the relative merits of C vs. C++ for most applications. I quote, in particular:
Not in my opinion. I never saw a project for which C was better than C++ for any reason but the lack of a good C++ compiler.
Do you have any idea why C++ was rejected as the implementation language by the most experienced C programmers, those folks now at lucent.com (Dennis Ritchie, Rob Pike, et al), for their most visible projects, Plan 9 and Inferno?
Surely, these people had access to a good C++ compiler.
If I may have a follow up, but closely related, question. Was the division of the Bell Labs Research staff between Lucent and AT&T related to a division of opinions concerning C and C++?
-Jordan Henderson
if the person who moderated down then posted to the story, his moderation would be erased, thus you wouldn't see it in the Moderation Totals.
the same theory could explain how there have been posts moded down to -5(except this would be very tricky and unlikely)
While I find the flexibility and power of C++ to make it the best overall tool for my programming, I often find that when I get something wrong, the error is almost impossible to find.
What could be done to reduce the incidence of errors and improve the debuggability of C++ code, either through changes to the language, restricting the developer's freedoms, or by improvement of available tools.
Context: I have moved to Linux development from NT, and *really* miss BoundsChecker!
1) MACHINE, 2) ASSEMBLER, 3) FORTRAN, 4) PASCAL (arguably) and other same-generation imperatives. 5) C 6) C++
Each has been more or less a descendant to the previous "best of breed", and added features that were required for the next level of programming style. C++ is the current champion, and will almost certainly "father" the next general-purpose system programming language.
I think it is interesting that each of the "best-of-breed" languages kept all the critical advances of the previous (C++ kept C's efficiency), and that almost every left-by-the-wayside language tried to /change/ the idiom rather than /extend/ it.
1. Will languages keep getting more baroque indefinitely?
2. What do you see as the next logical set of features that will demand a new language? What limitation of C++ most needs to be generalized/extended in your point of view?
Kevin Bealer (kbealier@stny.lrun.com)
(in following text: dynamic = recognized in runtime and also generic (to certain extend))
working with C++ I usually get the feeling of being tied up - in a sense that it is not dynamic enough. For lack of better explanation let me give example of more dynamic languages: smalltalk, perl. of course, those are interpreted languages (and that's the main reason they are so dynamic).
In C++ I have basically no meta-information - which would allow me to do something with class (any class).
The templates seem to address this problem, but templates are just a fancy code generator (everything's still done at compile time, so while it's more generic it's not really dynamic).
Is corba solution?
Any comments on this?
erik
...all excited, don't know why...
Visually, it's plausible as the insertion operator. Operators should look like what they do. With arithmetic operators, we've learned them already; with C boolean and bitwise operators, well, heh heh heh. Never mind
FWIW.
Hello. I was wondering if you saw the popularity of C++ coming. Did you think it would be such a success, or did you figure people would think it's just a pathetic attempt to make C better? (not that it is). Thanks.
there are other paradigms...one that has been convincingly applied is to use a robust high performance platform based on an open standard (like Apache), and use easy to understand extension languages to extend the platform through a known interface.
How is this a problem? The idea with iterators is that that you don't need to know about the containers to write algorithms that use them; you just need to know about the iterators. If you find yourself wanting to get at the container from the iterator, something is probably wrong with your algorithm, or understanding of the STL.
iteratorsThe string class was implemented before the STL proper. This main explain part of the problem. I wish the string class had been completely rewritten with the STL in mind, instead of just retrofitted. But, this would have broken backwards-compatibility. The string class is my least favorite part of the C++ Standard Library.
The idea is that things that could be very inefficient won't compile using the obvious approach, like trying to do random access style arithmetic on non-random access iterators. Of course, you could write your own one-line + operator that used advance.
I agree with you on the string class, but not on the other two. I'm glad that operator+ doesn't work on non-random access iterators. But, you're not happy about it. This is obviously one area where you can't please everyone.
--
Steve Molitor
smolitor@erac.com
"Emacs is the Computer"
Stephen Molitor steve_molitor@yahoo.com
He was of course talking about glib. As opposed to glibc.
I have seen the future, and it is inconvenient.
Uh, yeah, right.
Hardware agnosticism is fine if the language doesn't have to talk to the hardware, or if it's willing to talk to the hardware through an abstraction layer written in a hardware-aware language (e.g. C, C++, asm, etc.)
I'm intrigued by the Java IDE thing though. Which one is it?
What do you think of Objective C?
Its not a technology issue - its a marketing issue. Eiffel is not only poorly marketed, but there aren't any major open source Eiffel-based projects that would spur developers to learn more about it. For at least another three years, C is king, as much as it chaps me to admit it.
The original question was based on the faulty presupposition that a programming paradigm can, in fact, be a panacea. Sorry, ain't gonna happen.
Who besides obvious hypemongers ever said that OOP, OOA/D, and their ilk were the magic programming elixirs for all software ailments? Certainly not Stroustrup.
Most folks who have been writing software for more than a few years realize that there are no easy answers, no quick all-serving fixes, no silver bullets. Every paradigm is a tool in the programmer's kit. Each is effective at solving a certain class of problems. Pick the right tool for the job, and you're on easy street. Make the mistake of attacking every problem with a hammer, and you apt to do a lot of cursing.
Regarding what paradigms are "challenging" OO, I don't think that there are any challengers, not because OO is the king of the hill, but because the whole concept of one paradigm being the "best" doesn't make much sense. For some problems, OO is the best tool in the kit; for others, it isn't. Most non-trivial problems are best solved by using a number of paradigms, anyway. I sure wouldn't settle for just one.
Look, folks, there isn't ever going to be a one-tool kit that solves all problems. Quit knocking C++ because it isn't this mythical beast.
Easy, automatic testing for Perl.
My question:
Do you foresee any major or minor additions to the Standard C++
library in five years? Minor additions might include hash_map,
hash_set; major additions could include automatic garbage collection,
serialization, meta-programming thingies like reflection.
Thanks
Stephen Molitor steve_molitor@yahoo.com
The most compelling argument against the use of C++ is the Fragile Base Class problem. With all C++ implementations I know of, you cannot change a library class to add a method or member variable without causing all code that links with it to crash (or at least radically misbehave). With C structs and functions, this is far easier to avoid.
However, this could be an incentive to go the Open Source route, as if you have to recompile anyway to avoid crashing, providing source as opposed to binary librarues is encouraged. What do you think?
[Java's spec is] considerably smaller than C++'s language spec, yet it contains almost all of the useful features of C++, and many features that I wish C++ had.
True, there's a lot to be said for minimalism. Look at how long C has lasted. But could you name a few of the features Java has that C++ would benefit from? I'm not aware of . . . any. Java "interfaces" are just abstract base classes by another name; I don't see any need to add a "feature" to the language for that. Name collisions due to multiple inheritance can happen with member functions as well as data members, so it's hardly a cure for that problem. (Mind you, once you do define it as a feature unto itself, that has a positive sort of propagandistic effect on the user; I'm willing to bet that far more Java programmers use multiple inheritance via interfaces than C++ programmers do via abstract base classes -- and not because it's any easier in Java, but because that way of looking at things has been brought to their attention. When I first heard of that Java feature, it blew my mind, and then I realized I could do it in C++. I've been doing it ever since).
One thing Java is notably missing is protected access: A protected member is visible to subclasses, but not to the outside world. This can be very cool, if you want to keep your implementation safe while allowing some extra hooks into it for a subclass to use. Protected virtual functions kick ass: They let a base class define certain parts of its implementation that a subclass can replace or modify, without the subclasser having to rewrite anything but the one part he wants to change. Of course this all depends on good programming, but doesn't everything?
object-slicing,
What's that?
operator overloading,
It's true that idiots can (and do
On the plus side, operator overloading can make for much cleaner and more readable code, and it also allows you to provide interfaces common to both class instances and built-in types -- thereby making it possible to write templates that work on . . . Oh. Sorry. Well, if you had templates, you'd see the advantage of that, believe me.
platform dependent datatype sizes
That's not a feature of C++ so much as a feature of the problem domains in which C++ was intended to be used. C++ is all about combining OOP facilities with C's ability to get right up close to the machine. If that's not what you need, why then don't use it
the need to use forward declarations ad nauseum
Personally, I sort of enjoy having a header file where all the interfaces are laid out without any implementation clutter. It's right there. It's documentation that the programmer is forced to keep up to date. Of course, all that header-file-crunching does take a year and a day at compile time. I'll concede that.
non-final non-virtual methods (and by default!)
Yeah, "final" is cool. C++ might benefit from a "final" concept.
On the off chance that you'll read these comments I wanted to say thanks for C++, if it wasn't for you I'd probably be programming in C.
Thanks for making the standardisation process open, and thanks for personally checking every 'feature' that made it into the language specification actually needed to be there.
Thanks for signing my copy of D&E at SD'99, and for chatting to me at SD'98 and SD'99, your talks were great, (pity you wouldn't comment on open source software when I asked you at the roundtable talk...).
I guess if I had a question if would be "What do believe is the greatest weakness of the open source software development model?".
So the idea of private/protected is to minimize the amount of info an "external" programmer is depending on, and to use "get and set" functions instead. Ok, so what if you remove the variables at a later date anyway? The functions then have nothing worthwhile to return. For purely internal values that "external" programmers do not /should not require access to, then yes, private is a good use. But if that value is needed outside the class, but shouldnt be changed outside the class, then why not allow for an access specifier that exposes the member to other classes, but does not allow other classes to change it? The only awkwardness is that a function declared under such a specifier would be conceptually strange. END COMMUNICATION
Is this redundancy a bug or a feature? And, why?
What prompted the standard to include the 'default copy operator' and 'default copy constructor' to be implied by the language. Beyond a few trivial data structures, this behavior is clearly wrong a vast majority of the time, prompting people to go out of their way defining these functions as private, just so they aren't accidentally used. Even then making the member functions private isn't always going to work. I could possibly see this behavior kept for structs, but classes are usualy never as trivial. Finally, a third method was probably overlooked that can be correct in a lot of cases: some kind of attribute could be applied to a class such that the code does a 'for each element in class, use its operator= to copy it'. This could elminate some amount of coding in classes where this is safe, as you would not need to maintain functions which copy every element over, and might miss one if the structure is modified at some later date.
I wish you could have posted earlier, I would really like to hear Bjarne's answer to these questions.
BD
Doh! Lash myself with a wet noodle...
A Government Is a Body of People, Usually Notably Ungoverned
Sorry about the marketing. I happen to think conventions *like* COM (I said *like*) are a sensible way to get interop, and besides make sense for writing loosely-enough coupled Component Software [http://www.amazon.com/exec/obidos/ASIN/0201178885 ] (as opposed to Object Oriented Software, which often has scary implementation inheritance couplings and dependencies).
RE: your questions,
Object references between objects in the same context/apartment are direct pointers. Object references crossing contexts/apartments/processes/machines address some kind of proxy-channel-stub structure. The client (object holding the object pointer) usually does not trouble itself with whether it is directly addressing a real object or a proxy, e.g. mostly transparent remoting.
When the client calls a method on an object in the same context, it is a direct C++ virtual function call; when it calls an object in anothe apartment, process, or machine, the proxy marshals the arguments, the marshall buffer is moved to the other address space, and unmarshaled; the object is called, its return values are marshalled, that result is moved to the client's address space and unmarshalled.
(An "apartment" is an object environment within a process, with certain concurrency and thread affinity guarantees, that provides a convenient programming model in a multithreaded application. For example, concurrent calls to objects in a particular single-threaded apartment are serialized. A "context" is an object environment within an apartment, within which groups of objects live. COM+ uses contexts to provide automatic services on behalf of objects, such as automatic security checks and automatic transactions.)
So: near calls are as cheap as C++ calls, and more distant calls can have overhead proportional to the marshaling, copying, and/or RPC overhead.
Some parts of COM involving remote activation and security are privileged, and there's lots of standard code for building proxies and stubs (marshalers and unmarshalers) and so forth from interface descriptions, but you can certainly use your own COM-like conventions for binary interop independent of any OS.
Repeat: you can have binary interop between languages and language implementations without much pain if you keep the kinds of coupling as simple as possible. For example,
1. the only thing you can do with an object is call methods on it (no touching its data members directly);
2. methods can only pass and return objects by reference (pointers, not whole structures);
3. all interoperable implementations produce the same vtable layout from the same interface description.
See also the section "C++ and Portability" in the first chapter, "COM as a Better C++" of Don Box's book _Essential COM_.
The frustrating thing is that it seems impossible to 'show them the light'. Maybe really understanding OO requires somebody to find that type of thinking for themselves, as it can't be taught?
This means that it is not practical to use C++ fully in any project ...
;-)
Well, what are you trying to do? Are you trying to make sure you use every last feature of a given system, or are you simply trying to get the job done?
C++ is very complex. So are Unix, and Common LISP, and X11, and countless other systems. However, you don't have to use all of a system's features in order to use that system. Use what you need to get your job done to satisfaction.
Larry Wall (the creator of Perl) has said, "A Perl script is 'correct' if it gets the job done before your boss fires you." There is a lesson there: Don't get so caught up on the tools that you forget that the tools are there to help you do your job. The same applies to C++.
This has been a public service message from DragonHawk.
dragonhawk@iname.microsoft.com
I do not like Microsoft. Remove them from my email address.
The STL is awesome, but it seems like there's a lot chopped from it - hashed containers, the copy_if algorithm, etc.. Could you discuss the issues involved in choosing what did or didn't make it in the standard? Is there any chance of it growing in the future to incorporate new stuff?
re: header file with the interface, seperate from the implementation.
yes, I agree totally, but C++ DOES NOT hide all the implementation; it exposes not just public methods and data members, but the entire layout of the object, both public and private members. private members (data & methods) are implementation specific and should not be visible to the programmer of the client. In a perfect world, anyway. Not going to change in C++ anytime soon.
OpenSource programmers can write code in whatever language they want. Consequently, they write a lot of C, Perl, and Python. But with some notable exceptions, they don't write C++.
;-)
I'm not entirely sure your assertion (that C++ is significantly less used for OSS then other languages) is correct. KDE comes to mind.
But, for the purpose of discussion, let us accept it as given.
Contrast that with the lanuages programmers use at work, which are primarily C++ and Java.
You've got a number of factors here.
The biggest concern for software maintenance is what system is already in use. If you've got a program written in language XYZ, then you continue to use XYZ. Look at the large number of COBOL programs still in use today for proof of this.
If you're (re)implementing from scratch, the biggest concern is: What is available to use? For many systems, the answer is C, because C is still far more universal and "settled" then C++ is. This doesn't mean C++ is bad, it just means C has been around longer.
Follow that up with: Who is making the decisions?
For a corporate project, it is the managers. Managers look at studies, benchmarks, and marketing info (lots of that), and decide which language is "the best". Unfortunately, many managers assume "newest" equals "best". This leads to Java, C++ and such being used, not because they are or are not better then alternatives, but because they are currently popular and getting attention. This leads to a network effect where more "new" software is written for C++, giving the impression that C++ is even better.
Note that I'm not asserting that C/C++/Java/whatever is better then C/C++/Java/whatever. I'm simply saying that quality is not the only consideration to PHBs.
Now, look at your typical OSS project. It is coordinated by a few people, maybe just one. They are going to pick the language they are most familiar with. This means C is chosen a lot, simply because it has been around longer, so they know it better.
As far as Perl and Python go, they are predominately scripting languages, and generally don't target the same problem space as C++. (Yes, I know that is an over-generalization, but as such things go, it isn't that far off).
Just my 1/4 of a byte.
dragonhawk@iname.microsoft.com
I do not like Microsoft. Remove them from my email address.
I think the troll in question is actually kind of funny, so I don't think the moderation is inappropriate, but I want to make sure all involved realize that the above comment was posted by "Hemos.", not "Hemos". Not the period (.) at the end of the poster's handle.
dragonhawk@iname.microsoft.com
I do not like Microsoft. Remove them from my email address.
Hello Bjarne, Do you think there will ever be significant additions to C++? How about well defined sized integeres such as: int32, int64, uint32, uint64 or templatized? Additions to the standard library? hash-tables, hash_map, Big-dynamically growing integers?
Standardized name mangling is not sufficient nor desirable.
:-(
You've obviously never tried to get two different C++ libraries to play nice together. I, for one, would really love it if things were standardized such that these problems went away.
Now, perhaps standardized name mangling isn't feasible. That may be. It would also be unfortunate, as it means C++ is effectively useless when it comes to creating reusable software on current shared library implementations.
dragonhawk@iname.microsoft.com
I do not like Microsoft. Remove them from my email address.
However, I have watched with great dismay the direction in which the language and its libraries are going, with the addition of internationalization to the streams library. As an embedded systems programmer, the fat now associated with I18N makes the streams library completely unusable in my environment. IMHO, I18N belongs in the GUI layer, not the streams layer.
That said, I'd like to ask why more useful (to systems programmers) constructs like guaranteed size types (int16, unsigned int32, etc.), XINU structures (bigendian on littleendian and vis-versa), and forced structure layouts (the _packed attribute) were not added, while all this facet crap was added. I thought you designed C++ as a systems language!
www.eFax.com are spammers
Maybe it is a little funny, but it is still a troll.
Your question is answered here.
dragonhawk@iname.microsoft.com
I do not like Microsoft. Remove them from my email address.
Just as was with C++, we are probaly seeing these techniques now, for instance design patterns. However, what would a language designed for design patterns look like? I think that patterns wouldn't be the only advance in hyper-OOP. There could be features such as multi-directional hierarchy, child to parent and between siblings. Heck, it shouldn 't even always be a tree, what about rings!? There could also be an eval like function to allow objects to create new abstractions or entirely new objects.
But unlike C and OO, C++ can't impliment any of these because it is too rigid and focuses too much on memory allocation. This why languages like Smalltalk, Java, and Python are, quite simply, more foward thinking than C++. Seeing as you obviously disagree with this, what do you think a next generation language would look like?
Hello??? Where do you see this? It's not because my question has ``garbage collection'' in it as well as another question in the FAQ that they are identical — or, in fact, any more than remotely similar.
Bjarne, what is your view of the future? Now I know that sounds cheesy, so I'll narrow things down:
Where do you feel, for example (and to tie in a certain major project of yours without giving its name), languages will be in the near future? Do you see postmodernism as a viable design, and that the "C++ of the Future" will be more natural, rather than organized?
But besides languages, you also have an interest in OSes and Distributed Systems, so what are your takes on the subjects, and where their future lies? Do you feel the Distributed OS (DOS, heh) is the future of architecture and OSes? Where do you feel the future of such architectures and OSes are? Since you're at Bell-Labs (or were, or are with AT&T Labs but not with Lucent, or whatever), I'd imagine you've encountered Plan9. Do you feel Plan9 is the Unix of the distributed age, or do you feel no true succesor to Unix, for the distributed-era, has come?
Thanks.
Sorry, I may be synthesizing the answer by using information from other sources, which the FAQ only makes connections to in my mind.
One of Stroustrup's design goals for C++ was to be able achieve efficiency near or the same as that of C if you wanted to. ("C with classes") Built-in garbage collection would, of course, make that impossible. Likewise, his opinions about Java are that it isn't done yet, and is generally following a design he thinks is wrong.
I missed your second question ("Do you think someday..."), though. I apologize for that.
dragonhawk@iname.microsoft.com
I do not like Microsoft. Remove them from my email address.
peterrenshaw ~ Another Scrappy Startup
How do you think the relationship between linux and C++ is? Just guessing ;), if Linux will become the predominant OS, do you think the use of C++ will go down?
So why do you think, each time one reports some news from Denmark the IT center of Europe, Slashdot tends to ignore it, eh? I suspect a conspiracy
;-)
If Google really cared they would fix Android Chrome to reflow text, instead of discriminating
With the popularity and features of Java constantly growing, where do you see C++ holding its ground and fiting in 5 years from now?
Java "interfaces" are just abstract base classes by another name; I don't see any need to add a "feature" to the language for that. Name collisions due to multiple inheritance can happen with member functions as well as data members, so it's hardly a cure for that problem.
::.
:)
:) write incomprehensible code in any language, but it takes virtually no brains at all to avoid inappropriate operator overloads.
The problem Java's interfaces are meant to solve is the case where you inherit from multiple baseclasses that have different implementations for a particular method.
eg: class Cat and Dog both have a "noise()" method. The Cat version says "meow" and the Dog version says "woof". If I create a subclass of both Cat and Dog, what does it do when I say "catdog.noise()"?
Different languages have different approaches to this. In Java, since you can only multply inherit from interfaces, which are "pure abstract classes", you would only ever have at most one inherited imlementation for each method. Other languges (Sather, and I think Eiffel) have a method renaming system. In C++ you're not allowed to say catdog.noise() because it's ambiguous. You have to use
One thing Java is notably missing is protected access
What are you talking about? Java has protected access. It has private, protected, public and "default" (sometimes called "package" or "friendly"). The difference between Java's protected and C++'s is that in Java, protected means that other classes in the same package can access it as well as subclasses. (Think of java packages as a group of "mutual friends" in C++, except that in Java "private" actually keeps even your friends out...)
What's that? [object-slicing]
Object slicing is what happens when you pass an object by value in C++, and the receiver is expecting a baseclass. The object gets "sliced" down to the baseclass, which can often have rather nasty side-effects.
platform dependent datatype sizes
That's not a feature of C++ so much as a feature of the problem domains in which C++ was intended to be used. C++ is all about combining OOP facilities with C's ability to get right up close to the machine. If that's not what you need, why then don't use it
I generally don't use C++, actually. C++ is too high-level for systems programming, and too low-level for application programming. It's like having a shopping cart with a souped-up V8 installed. Sounds kind of cool, but it'll rip your arms off if you try to actually use it to shop, and its handling on the road is less than spectacular...
In any case, the platform dependent datatypes are not an area where C++ gains any significant efficiency. In fact, it probably loses efficiency here, because good programmers end up assuming the worst case about each datatype (eg: an int is only guaranteed to be able to hold 16 bits of information). Virtually every C and C++ library I've every seen, everyone goes and makes their own typedefs that are at least somewhat more predictable than the normal builtin types.
It's true that idiots can (and do
I have to admit this is one of those things where I can go either way. Operator overloading can be very cool if used properly, but I've seen it misused so many times that it hurts. It also leads to difficulties in determining whether code is exception safe. Hmmm, "a = b + c" looks safe. Whoops, b and c are different sized matrices, and the + operator throws an exception when you try to add mismatched matrices together in this library!
the need to use forward declarations ad nauseum
Personally, I sort of enjoy having a header file where all the interfaces are laid out without any implementation clutter. It's right there. It's documentation that the programmer is forced to keep up to date. Of course, all that header-file-crunching does take a year and a day at compile time. I'll concede that.
First, C++ header files contain way more implementation than they should have. Data layout, private members, and even the actual code for inline methods are all right there in the headers.
Second, having separate files for interface and implementation doen't imply the need for forward declarations. Take a look at Modula-3 for an example of real separation of interface and implementation, but without forward's. (Modula-3 probably would've done better if it was a bit more object-centric and a bit less module-centric, and if it didn't have obnoxious all-caps keywords...)
Hav you ever had two classes that call inline methods of eachother? Sorting that out is a huge pain in the @$$.
>But then, C++ is the only language (to my
>knowledge) that allows you to use safe arrays
>where you want them, and faster...
Well, Standard ML of New Jersey has both safe (default) and unsafe arrays, for one. I'm sure many other languages with safe arrays often include optional unsafe ones, as array bounds checking can be a huge performance hit for lots of code.
In addition, with a strong type system it's possible far more often to eliminate runtime checks through code/type analysis. Safety doesn't necessary have to cost you something (as Java/Perl proponents might sometimes have you believe)...
A few things I've noticed throughout this discussion is almost ignorance of newer languages and language ideas.. Do not forget that the average software engineering development takes 18 YEARS to be put into widespread use.
OO has been with us since 1980. Its only in the mid-90's that its become big. Similarily, the new language ideas that have been developed relatively recently (functional programming--haskell, sml-nj, ocaml) will be the languages of the future in another 10 years.
In these languages..Here I will refer to SML-NJ, as I am most familiar with its type system, they are strongly typed. Polymorphic; lists are TRULY polymorphic, Unlike templates, there's no code duplication. They are also extremely strongly typed. In actuality they have an order of magnitude more typing information than C++ has, except that I don't care because the compiler itself intelligently infers all of that typing information fully automatically. Functions are truly first-order values. They may be 'created' at runtime (via partial application or closures), stored, passed around, and anything else.
SML is also much more understandable and more consise. It also has a module system that's extremely careful. You cannot even compile a program that violates the module system. As a language, the specification is well under 100 pages of carefully formalized mathematics.. (Though a careful analysis of SML shows that there are 'dusty corners' in the specification. My research right now deals with specifying a language so explicitly that an automated theorem proving system can prove the 'correctness' of the language specification. If anyone's interested in the tools I'm using, www.twelf.org.)
As far as consiceness and modularity: Remember the law of software engineering, half the number of lines of code means 5x easier to analyse, debug, and maintain.
As for the other languages, haskell has an even more versatile type system than SML-NJ has, I think its powerful enough to handle most of the typing characteristics of OO programming. OCaml is another language in this group.
While its still true that none of these languages are ready for prime time yet, I suspect that derivatives from them (like ML-2000) may be the language of the future; the languages that everyone will be calling the pancea in 10 years.
Given that it will probably be at least a decade or two until the next 'big thing' comes out, what things currently in the pipeline do you think will be big? Will it be the strongly typed functional languages? Will it be the a Java-style IDE where people don't think of a program as a set of linear text files but rather as a collection of objects and methods?
Another way of asking the same question, what abstractions do you feel will be the ones exploited in the future? Will the IDE abstract away the textual or linear representations of the code? Will typing, interfaces, and modularity be used to abstract away the objects implementing an interface? Will we finally have a good application programming language which completely abstracts away the ideas of bits, bytes, pointers?
Or, should I shut up because I've been around 'academic' language designers too much, who don't know how to make a language that the majority would accept?
Sorry about the marketing. I happen to think conventions *like* COM (I said *like*) are a sensible way to get interop
I ain't denyin' it. The COM part wasn't what I meant about "marketing". I just meant the use of "author" as a verb, which really grates on my nerves. (I'm not so crazy about "interop" either, but never mind
When the client calls a method on an object in the same context, it is a direct C++ virtual function call;
Groovy. I feel better now.
. . . when it calls an object in another apartment, process, or machine, the proxy marshals the arguments, the marshall buffer is moved to the other address space, and unmarshaled; the object is called, its return values are marshalled, that result is moved to the client's address space and unmarshalled.
I might guess that including "apartment" in that list might have something to do with synchrony and what not, like foo's stuff evaporating before bar gets the chance to look at it? I'm not sure I'm fully grokking the "apartment" thing. At any rate, there's certainly no way around the marshalling deal when talking to a remote machine; that's just the nature of the animal you're dealing with.
the only thing you can do with an object is call methods on it (no touching its data members directly);
That's the part I like most
methods can only pass and return objects by reference (pointers, not whole structures);
They generally ought to anyway.
all interoperable implementations produce the same vtable layout from the same interface description.
Again, that sounds like good practice in any case.
Thanks for the info.
I am a college student who is currently learning C++. One of the biggest faults that our professor has pointed out is that C++ wastes memory by making copies of variables, etc... when it passes it to a method to be used by an object. I have to agree that it does seem terribly inefficient. I am just curious, why did you implement the language to do this? Are there any apparant advantages?
The problem Java's interfaces are meant to solve is the case where you inherit from multiple baseclasses that have different implementations for a particular method.
Duh. I didn't think it all the way through. Still, what about interfaces with like-named functions that have different meanings, like, oh, this is a shitty example, but what about cat::noise( ) conflicting with signal::noise( ). Maybe I'm grasping at straws
What are you talking about? Java has protected access.
My bad. I thought I'd heard that it didn't. Never mind.
Object slicing is what happens when you pass an object by value in C++, and the receiver is expecting a baseclass. The object gets "sliced" down to the baseclass, which can often have rather nasty side-effects.
Hmm, offhand I'd think that the expected class's copy constructor (if any; in the absence of a reasonable conversion, I'd expect it not to compile) would be called, which could be undesirable depending on the implementation of the classes concerned. But if you pass objects by value, you really get what you deserve. That's what const references are for.
Operator overloading can be very cool if used properly, but I've seen it misused so many times that it hurts.
I've only seen one bad case, that being the Raima library. Uggghhhh, brrrr, horrible. It's very old C++ code, though, from back when operator overloading had novelty value. You just have to have some discipline and not treat operator overloads any different from any other standard interface with commonly understood semantics. I really don't think the iostream library helped either, overloading << and >>. It was the first example of operator overloading that anybody ever saw, and it was a marginal example at best.
Whoops, b and c are different sized matrices, and the + operator throws an exception when you try to add mismatched matrices together in this library!
Well, leaving aside the fact that I personally would assert that instead of throwing an exception, how is that different from throwing an exception (or an assert) in a matrix::add( ) function?
In any case, the platform dependent datatypes are not an area where C++ gains any significant efficiency.
Hmmm . . . I don't know what Java loses or doesn't lose by enforcing a particular endianness on ints and whatnot, but in any case I wasn't thinking so much about efficiency so much as simply a lack of abstraction in general. FWIW (if anything
First, C++ header files contain way more implementation than they should have. Data layout, private members, and even the actual code for inline methods are all right there in the headers.
Granted, though some people (horrible MFC comes to mind) do put inline function bodies in separate files that are also included. This is a problem inherited from the practice of using C linkers, and bending over backwards to stay within their capabilities (along with name-mangling and God knows what-all else).
Second, having separate files for interface and implementation doen't imply the need for forward declarations. Take a look at Modula-3 for an example of real separation of interface and implementation, but without forward's.
True.
Modula-3 probably would've done better if it . . . didn't have obnoxious all-caps keywords
All-caps?! Ugh, ugh. Was that another Nick Weurth masterpiece?
Hav you ever had two classes that call inline methods of eachother?
I don't recall running into that particular problem, but I can see where I'd hate life for a while if that happened
Wall's talking about job security, that's all.
What we need here, to make this planet a better place to live, is a worldwide bloodbath in which all the Perl hackers are, well, hacked to bits with machetes. Rivers of blood in the streets! Yes! Man, that'd be cool.
That pretty much sums up the lower half of the /. denizens... :)
#define X(x,y) x##y
#define X(x,y) x##y
Peter Cordes ; e-mail: X(peter@cordes ,
Huh? Go visit some real intellects instead. Visit Dennis Ritchie at: http://cm.bell-labs.com/cm/cs/who/dmr/ Visit Brian Kernighan at: http://cm.bell-labs.com/cm/cs/who/bwk/ Reality check, Robbie Boy.
radsoft.net
Think of it rather like this: The typename is a "direct object" of operator new, by analogy with English grammar:
// dflt constructor // char * constructor
:)
int *foo = new int;
bar *baz = new bar;
bar *baz = new bar( "urg" );
Or take for example creating a temporary, in which case it's appropriate to think of the constructor as a function which returns an instance of the class (and, in fact, that is precisely what it is):
int func( bar &baz );
int examplefunc()
{
// bar() is a call to the constructor of bar
int i = func( bar() );
int j = func( bar( "kermit the frog" ) );
}
Constructors have no explicitly declared return type because they can and must have only one return type, which happens to be the name of the function anyway. Since they must always invariably return *this, the return statement isn't explicit either. The absence of a return type is similar to declaring cast operator overload functions:
class foo2 {
operator int();
};
operator int() can and must return only int, so having an explictly declared return type would gain nothing while adding a potential for careless errors. operator int() still has an explicit return statement because while it must return int, nobody said anything about which int, unlike constructors where a specific instance of the type must be "returned" (though bear in mind that the mechanism for "returning" class instances from constructors is not the same under the covers as the return mechanism with normal functions, because with the normal deal the only way to return an object "by value" is with a copy constructor, which would of course recurse infinitely
Of course, you could say that in the case of operator int() the return type is being declared without a name rather than vice-versa. That might be an even better way of looking at it (in fact, I'm suddenly realizing that it's by far the best way to look at it) and it also very closely parallels the logic behind constructor names.
One of the most difficult problems in large-scale programming is knowing when to delete an object and reclaim its memory. Java and many other languages have garbage collection to automate this job, albeit at the expense of efficiency. I know you do not believe that garbage collection should be a part of the core language, but couldn't it at least be a compiler option or something (if possible)? I think that would make C++ far more attractive for many applications.
"C++ : C
. . . don't come crying to me, you smirking prick.
By the way, "irregardless" [sic] is not a word in the English language, although the use of it does happen to be one of the most reliable indicators of cretinism known to modern science. For corroboration, "irregardless" is almost invariably accompanied by morbid inflammation of buzzwords, like for example the following burst of MIS-droid gibberish: "a long term development solution that is truely fault tolerant in mission critical situations". Listen, pal, anybody who talks like that is in desperate need of a quick trip to a brain transplant specialist.
For mine, Java is good simply because it's standard library is so useful.
The C++ STL is great but it would be alot better if it was expanded to include at least a GUI API!!
Please have this question answered!!!!
The type T2 in the case below need not and should not be fixed when the class template is instantiated. You might want to call the functions that use it three different times, with three different T2 types. That's the only reason to bother parameterizing the type in the first place.
What would be gained here is defining the callback type once, out in the open. As the language presently stands, this code can be written, but it would be ugly, as we see in the example.
template<class T>
class container {
template<class T2>
typedef bool (* callback)( const T &r, const userdata &ud );
// for each contained item, call the callback and pass it a
// reference to the current item and a reference to userdata
// This is nice but illegal.
template<class T3>
void traverse( const T3 &userdata, callback<T3> cb );
// This is why it would be *really* nice to have the typedef;
// we may want it more than once.
template<class T3>
void traverse_reverse( const T3 &userdata, callback<T3> cb );
// This legal code is what I'd like to avoid
template<class T3>
void traverse_ugly( const T3 &userdata,
bool (* callback)( const T &, const T3 & ) );
};
The question really is, "is this ugly enough to make it worth anybody's while to add a feature to the language?" I suspect that the answer is "no", since it'd be merely a convenience which would add no functionality.
"Christianity neither is, nor ever was a part of the common law." --
Why was bounded polymoprhism not included in C++? For those who don't know, C++ has a template feature that allows declaration of generic classes (e.g. template list { void add(T t); }). Bounded polymophism allows the declaration of templates that would restrict the template parameter to be a derivative of a certain class. (So T would have to be derived from some parent. The language can then restrict what add(T t) does with t to valid operations on instances of that parent.)
What the fuck are you jabbering about anyway? Putting arguments on the stack? Member function calls in C++ differ from non-member function calls (and plain old C function calls back in 1974) only in that a "this" pointer goes on the stack along with the rest. (With virtual functions, some pointer-snapping happens to choose which code gets called, but that's nothing to do with making copies of arguments).
Not only does C++ do absolutely nothing even remotely unique or unusual in this regard, but it also provides facilities for passing literally anything as a pointer (references are syntactic sugar on pointers), which is pretty damned cheap: 32 bits on most operating systems. Which happens to be the size of an integer in most cases. A pointer to an integer therefore uses up exactly the same space as the integer itself, you pathetic halfwit. Or are you yammering about promotion of integral types? No, that's nonsensical, too.
You seem to be under the impression that data can be pushed around without ever using any storage. This is because you do not have a brain.
Finally, "terribly inefficient" is total bullshit in any case. You sould like the Cobol morons thirty years ago saving two bytes by keeping only the last two digits of years (which was cretinous to begin with, because they were storing ints as strings! Those two bytes could have been used as a short int and kept the code stable for the next sixty-five thousand five hundred and some-odd years. IDIOTS.)
In short, you're a hopeless babbling imbecile with a brain the size of a walnut. Your professor is not competent to pump gas in Guatemala. In a just world, both of you would be shot to improve the breed.
Fuck off and die, retard.
Hope this helps.
In addition though, an additional problem, and one that is not solved directly by a common binary interface, is the so-called "Fragile Base Class" problem. ie If I add virtual methods to a class, then (for all implementation I am aware of) it forces a change in the virtual lookup mechanism (ie the vtable in most implementations) all derived classes must be recompiled to remain compatible. (There are obviously similar problems with changing anscestors etc)
This creates massive binary compatibility problems, as if you ship C++ code in a shared library, then you are effectively restricted to each application being tied one and only one version of the lib.
The reason I am interested in these topics is tied to the fact that (a) I (more-or-less) like C++ (b) I use BeOS which is tied to C++
BeOS has problems with fragile base classes, but the ABI is more of a problem. How do I link my perl/python/C/Eiffel/SmallTalk/Sather/Pascal/Basic (all of which have potential users on BeOS) to the strictly C++ API? The options are to generate wrappers (either as C functions to call the C++, or by generating some form of ORB), or to rely on the fact that BeOS is using GNUpro, and build some support for hacking into the underlying structure of the GNUpro binaries.
The C wrapper sux, bcs you just end up reducing C++ down to C, which is hardly the point. Relying on the binary structure is nicer, but not at the expense of compatibility.
Is there a solution? Or is C++ just not cut out for use in such an environment?
Read more of this story at Slashdot.Read more of this story at Slashdot.Read more of this story at Slashdot.
The following code would be legal if foo( ) and foo2( ) were function templates, and they only did stuff to bar and quux which involved members that had the same name and type in each. For instance, if bar and quux both had argle() members, and all foo( ) and foo2( ) did was call b.argle() and q.argle() respectively. The same applies to class templates, but they take longer to type
int foo( bar &b );
int foo2( quux &q );
class bar {
class baz {
main()
{
baz z;
// legal:
foo( baz );
// bzzt, won't compile:
foo2( baz );
}
Template repositories are crap. When will C++ compiler implementors learn that? (Are you listening Sun Micro?) Fold all the template symbols into each .o and have the intellegent linker throw away all the duplicate, weakly linked, symbols. That's the only way you can coexist with modern course code control systems like ClearCase. Template repos and their constant source of annoyances bugs are no end of pain for large scale C++ systems. They give C++ templates a really bad name. I truly hope that g++ will become THE OFFICIAL C++ COMPILER because they are the only ones that know what they're doing.
It is hard to debug code that use STL containers because the debugger (human or machine) has to be intimately familiar with some C++ library vendors particular implementation of STL: with dinkumware's STL being the worst to SGI's implementation being the best.
Text based C programs were easily ported anywhere because the stdio library was the same everywhere. Why did no one ever attempt to define a stdgui.h to do for the GUI what stdio did for the command line? Java sucks since Sun has decided to play God and toy with who can do what and how. Perhaps, we need an OSS movement to create a standard GUI library for C/C++. Start by identifying a set of basic GUI calls common to all (or at least most) GUI OSes. Then get it approved by ANSI/ISO to ensure universally compliant implementations down the line and presto! Write once, run anywhere can finally become a reality. Even on the FoobarOS!
I have read what Bjarne said about CORBA - he hates it. Bjarne, do you care to elaborate about your feelings about CORBA? Do you have a better RPC/messaging scheme?
Please make this part of the C++ standard - every vendor is completely clueless in this matter - please have ISO mandate a definitive standard for more aspects of C++!!!
I wish linking was deferred to the latest possible stage in C++ to avoid this fragile base class problem in C++. I think the world needs a C++ Virtual Machine with different loaders for each platform. Knuth's MMIX may be the key to this.
I'm C++ biggest fan, but I realize that C++ desperately needs its own virtual machine with completely predictable behavior and standard sizes for basic variable types (int, long, etc). Having ANY standard is better than having a loose standard or no standard. The ISO C++ standard is far TOO LOOSE to be useful in the real world. We need to completely define the C++ runtine environment to allow C++ to survive in this new age of programming on multiple platforms. People no longer wish to rebuild their code on every freaking platform on earth - they just want to run it - as is.
PLEASE standardize C++ name mangling, virtual table layouts, pointer to member function construction, template object formats, contructor and destructor calling conventions, basic data type sizes, etc, etc, etc. C++ needs MORE RIGID STANDARDS. What we have now are C++-like systems that have more things NOT IN COMMON than IN COMMON with each other. This is not freedom - this is choas. Any code that hopes to be ported to more than 2 platforms must have magicians as programmers. This is just silly.
Does it have something to do with the brittle base class problem of C++, or the lack of standards in C++ implemtations? As it now stands RogueWave is the only successful C++ 3rd party library shop. ObjectSpace to a lesser extent. But BOTH VENDORS HAVE ABANDONNED C++ in FAVOR OF JAVAS. That's pretty damning stuff indeed! Because there are no universal standards in C++ implementations between platforms these vendors must provide source code for the C++ libraries. As result, the industry suffers greatly. Meanwhile the VB/COM/JavaBean industries flourish. Bjarne, care to comment on this dillema?
The Sun C++ 5.0 compiler produces WORSE CODE than 4.2 and has a ton of new bugs and memory leaks. Has C++ become impossible to implement? Do we need a universal C++ virtual machine? Or should everyone just drop proprietary compilers in favor of g++?
Look at how long C has lasted. But could you name a few of the features Java has that C++ would benefit from?
A few more great Java features:
* Custom class loaders. The gateway for classes to enter the system, it makes things possible like the ability to just unload a whole group of classes from the system and re-load them again. Or you can do your own class instrumenting (in the Purify sense) to add debugging code to classes loaded. Or you can have seperate threads loading classes from seperate sources, for instance to do a side-by-side comparison of different versions of a program within the same VM sharing the same set of data.
* Refelction. You can use this to dynamically discover class features and methods, and call them as well. A bit more freindly and well defined feature this leads to are "beans", simply classes with a well-defined naming pattern such that you can use a standard reflection based package to find what properties a class might have at runtime, and get accessor/modification methods for those properties.
"There is more worth loving than we have strength to love." - Brian Jay Stanley
I think most people recognize you as the man that ushered Object Orientation into the mainstream.
Java came along, and tried to simplify tasks that caused program errors (especially memory deallocation and memory overwrites). Some people complain about the loss of control and flexibility, but I have twice seen a group of average programmers produce software much more quickly than I've seen similarly-abled programmers produce C and C++ software; I believe most of it's due to lack of program errors caused by memory overwrites.
Since there are many tasks that Java does not accel at (Systems-level programming, high performance, etc.), C++ is still compelling for many many tasks.
However, given the 10-year cycle of in vogue languages, we're going to need another one in another 5 years or so. Will you be the guy to create it? What will be the important features? What are the good features of C++ and Java (or other languages) that would be retained? What lessons learned in other areas will be important? What about articles like this one by Tim Sweeny of Epic Games on the Next Generation?
I too am often tempted to use obscene language to describe an obscene computer language.
C++ may not be the worst computer language ever invented, but it ranks near the bottom. I cringe when I think of the harm that is being done to the computer industry by programmers who think it is a good language.
See http://www.elj.com/cppcv3/ for an in-depth critique of C++.
1.Write a C++ program incorporating the following nested loop:
for ( i = 1; i = 5 ; i++)
{
for ( j = 1; j = 5; j++)
cout '*';
cout endl;
}
What is the output of the program?
2.Modify the program so that the output looks like the following:
******
*****
****
***
**
*
3.For EC make the following with a single asterisk in nested for loops
*
***
*****
*******
*********
*******
*****
***
*
--
grappler
Vidi, Vici, Veni
1. The basic type int has a different size on different platforms. Wouldn't it make sense to have types int8, int16, int32, int64, ... additionally defined in the language?
2. The initialization sequence of static objects in different source files is undefined. It would be great if IDE's like M$ Visual C++ would allow changing this sequence. Or could the language be refined to handle this? (E.g.: Modula-2 had an initialization block for each source file. It was assured that all imported modules were initialized first, then the file's initialization block and then all modules using the exported functions.)
3. Why were nested functions not considered? They were useful in Pascal.
4. Lots of C library functions return char* or const char* or have char* as an argument. Usually the documentation is not clear if the string has to be freed by the caller or what the minimal size of a char* argument must be. Wouldn't it make sense to provide an additional set of (overloaded) functions using the standard string class, especially sprintf()?
5. All compiler implementations I know of report errors using line numbers. This makes it unnecessarily hard to locate errors in complex expressions. Why don't compilers report columns additionally or file positions instead?
(Thanks for reading this stupid sig!)
When you decided to create C++, you did it because you saw a requirement for a new language and fulfilled that requirement. With advances in technogy over the past 20 years since designing C++, can you see the need now for a new language and why?
~Pev
In Java you can make an inner class access its container class as if in C++ we could write :
class A {
int a_id;
class C {
public:
void print() {
cout "I belong to " a_id;
}
C() {}
};
public:
C c[4];
A() {}
};
In C++ we have to pass a pointer to A in the C constructor since A behaves just like a namespace for C. This makes cumbersome the use of C and C arrays (it should work for vectors). I would like to know if such feature has been considered in C++ and why it has not been included.
Knowing how many millions of man-hours have been wasted trying to write useable code in that excreble excuse for a language you concocted?
C++ is to C as Lung Cancer is to Lung.
...that multiple inheritance is a bug, and it's used by people who just don't understand how to lay out a class heirarchy cleanly.
-jcr
The only title of honor that a tyrant can grant is "Enemy of the State."
EPOC, the 32-bit OS for Psion PDA's, and soon for several mobile phones (such as Nokia) was written in C++, at least that's what their white papers claim (see www.symbian.com). Also the system API's are in C++. btw these PDA's also contain a JVM and can be programmed either in C++ or Java.
As a developer, I would like to ask why the C++ standards community did not, and still has not considered standardizing the format of the compiler's object code, as was done with C. Were there technical, design or philosopy reasons why this was not put forward? In my experience, it is sometimes one of the biggest drawbacks to suggesting C++ as a development base. Many other programmers and/or clients feel the object code compatibility gives them more flexability and extensibility for cheaper. Thank You.
I'd like to know what Bjarne Stroustrup has to say about Tim Sweeney's article that was posted on /. a while back and in particular what he thinks about what Tim Sweeney refers to as 'frameworks', where a group of classes can have some extra properties added by someone without access to the original source.
What was the reason to create a programming language which is more complicated (and thus harder to learn and use) than its predecessor ? Scripting languages show that there is a strong urge for more simple things. In C++, you essentially must be a C++ compiler to understand what the code really does. IMHO, this is a move in the wrong direction. Why did you chose that direction ? Or was this no issue when the language was designed ?
--
Dipl. Inf. (FH) Aaron "Optimizer" Digulla
"(to) optimize: Make a program faster by improving the algorithms rather than by buying a faster machine."
I found out this has actually to do with the fact that some if not many compilers have the option to attach source code to the executable turned on by default. This option is needed by the debugger, which I believe is a valuable asset, because it can be used to trace the code, just like an interpreter! When you're finished debugging just turn it off and get an executable as small as any C or maybe even smaller!
Personally I find this C vs. C++ discussion invalid because C++ simply comes after C and is almost completely downwards compatible with it and I don't believe some people are willing to start flames just in sake of those few incompatibilities. I think it has more to do with the fact that some people don't like seeing 'their' favorite language C being 'mutilated', which I simply call the natural evolution of programming languages. Also (as Bjarne Stroustrup also mentioned) the fact that C++ is so populair, can attribute to the fact some people can't stand it.
Just my two eurocent (for what it's worth
(n|t)
Much of the complexity of C++ comes from trying to extract maximum speed from the language. My question is: due you consider the extra complexity is really worth it for MOST applications? Are the headaches of using and debugging C++ code there really worth 4-6 months of moores law? If not what other language would you use?
Hell, there are IDE's written in Java itself out there (bit sluggy, though).
Ex ClearCase guy.
[re: '.' vs. -> for referencing struct or class members] In C++, however, the programmer must specify for every access the detail of `how' this is done. That is the access mechanism to the member is made visible to the programmer, which is an implementation detail. Thus the distinction between `.' and `->' compromises implementation hiding, and very seriously the benefit of encapsulation.
The difference between an instance and the address of that instance is not an "implementation" detail. There is a reason why pointers must be dereferenced in order to access what they point to: Pointers are a data type in and of themselves, with properties of their own and interface of their own. Hiding the fact that foo *p is a pointer would lead to unreadable code, because important information would be lost. References are provided to handle certain cases.
If you want Java, use Java. That's what it's there fore. It's a good language, but it has very different limitations from C++. Make an informed choice.
Nested classes are contrary to good object-oriented design, and the free spirit of object-oriented decomposition, where classes should be loosely coupled, to support software reusability.
Well, uhh . . . that's gibberish. Nested classes are for cases where classes need not and should not be "loosely" coupled. These cases exist. Any experienced OO programmer has seen them: Sometimes a class is complicated enough that the implementation should be further decomposed. Nested classes also keep namespaces tidy. Throw in templates and you've got a tremendously useful feature.
This guy is throwing theory at a practical language. I could go through his entire critique and probably refute 90% of it without much effort. C++ is the way it is because it's useful that way. A "perfect" language that doesn't meet the practical needs of programmers will not thrive. An imperfect language which does meet the practical needs of programmers will very often thrive. C isn't perfect either: The declaration syntax is a mess. Nevertheless, the popularity of C is due to the usability and power of the language. Ditto C++.
(This is the pro-C++ guy again, still regretting his bad manners)
Custom class loaders.
It's cool (I've always been sort of entranced by Java's habit of putting each class (is that quite correct?) in its own
Refelction.
Reflection is just plain groovy. I'm told by a Java-centric friend (IOW: I can't vouch for this and I don't claim to
Thanks for the info. I hadn't known about custom class loaders, and I forgot (duhh) reflection completely. My bad.
Finally, a third method was probably overlooked that can be correct in a lot of cases: some kind of attribute could be applied to a class such that the code does a 'for each element in class, use its operator= to copy it'.
According to r.12.8 of the C++ Reference Manual, the default copy constructor and assignment operator do exactly that.
In the compilers I've used (MSVC & GCC), exception specifications are not that well supported, and I've had people on the GCC list say that they're going away anyway. I feel that this is a useful feature, especially if the compiler gave warnings about violations of the specifications. What does the future of exception specifications look like?
First and foremost, I fucked up with the classes in the example code. It should have been like so:
class bar {
class baz : public bar {
. . . I realize that somebody who knows the language would deduce that after a few moments of wondering what the fuck was wrong with me, but I shoulda gotten it right the first time.
Second: After posting the above last night, I was thinking about a project I'm working on, and damn if I didn't immediately think of a case where I might want to have a template where one of the parameters was limited to descendants of a given class. I'm not certain that that's actually what I need, but it still makes sense to me the next morning (win32 GUI class library with templated MDI parent class, which takes an MDI child type as a parameter: I might (or maybe might not?) want to limit the MDI child type to mine, or descendants of it). By the way, I think you could fake it to some extent by deriving a template from a normal class, which used pointers to the base class from which you want to force T to inherit from. In other words:
class bar {
};
class bar2 : public bar {
};
class baz {
};
class foo {
public:
foo( bar &b ) { }
};
template<class T>
class bogo : public foo {
public:
bogo( T &p ) : foo( p ) { }
};
int main()
{
bar2 b;
bogo< bar > bb( b );
return 0;
}
. . . it's a crude and annoying workaround, but it could probably be refined somewhat.
C++ implements very static types -- something which has been loosened a bit by the introduction of RTTI.
On the other hand, part of Java's success (I hate myself for bringing the J-word into the question ;-) must come from the need of interchanging code as well as data on the internet -- something which requires the very opposite: dynamic types, or at least, dynamically loadable types.
The question:
Could it be possible to have dynamic types as "first class" types in an extended C++, or would that interfere too much with the basic design principles? What would be needed of the runtime environment?
Another question: I've seen you often quoted that Java was not the language you would have designed, were C-compatibility not an issue. So which parts of C would you be most glad to see disappear from C++, if compatibility was not an issue? Would the basic types be objects with primitive "member functions", i.e. would the language be what is called purely object oriented?
BTW please don't take this as a flame, but the MAX macro impl you've shown is incorrect and dangerous. Example: MAX(getc(),getc()).
Your BEGIN_SYNCHRONIZED/END_SYNCHRONIZED construct could be replaced like so:
{ Synchronized sync(x);Where the constructor of class Synchronized performed the stuff in BEGIN_SYNCHRONIZED and the destructor of class Synchronized performed the stuff in END_SYNCHRONIZED. Note that you would be able to remove your try-catch stuff, because whenever there was an exception thrown inside the critical section, the desctructor of the sync object would be called. Note that the BEGIN_SYNCHRONIZED/END_SYNCHRONIZED macros can also lead to inadvertant errors if the x passed to the BEGIN is different from the x passed to the END.
I will agree that there are certain cases where macros are actually useful -- take the assert macro, for instance. But as your examples have shown so well, in most cases where people use macros, there is some other language feature in C++ that they can use. And not only that, but the other language feature is safer and less error-prone.
GNU and Linux -- Oh no, Mr. Bill!
Lets face it, parametric polymorphism was implemented terribly through C++'s templates. How would you design a language that would take full advantage of this concept? You should be able to interact with objects as if they were built in variables, like using the autoincriment funtion. Along the same lines, what improvements would you make to the STL? We've been using the same container paridigms for a while, there must be something new.
My question of you is, having designed a template/generic framework for C++, what advice do you have for the people at JavaSoft who are currently designing one for Java?
GNU and Linux -- Oh no, Mr. Bill!
stub juror parents
bust juror parents
jobs traps nurture
jobs strap nurture
rant jobs ruptures
burp sorter jaunts
burp resort jaunts
just born raptures
just burn prorates
jobs rater upturns
job arrest upturns
trap juror subnets
bus juror patterns
ban jurors sputter
burp jaunt resorts
unjust bra reports
just burns prorate
just urban porters
run or jet subparts
up run job starters
sun rub jet parrots
run jet bus parrots
run pro jut breasts
puns jabs torturer
Couldn't the act of choosing (filtering?) 10 questions be considered censorship?
Why not let Bjarne choose which additional questions he wants to answer right here on SlashDot.
May be his posts could show up with a different color?
Hi Mr. Stroustrup, let me start by saying you are my CS idol, more so than any other CS person I know of. Ok, second, I've read some of your posts on comp.std.c++ about C99 but I'm still not clear, so I'll ask. What do you see as C99's future? Do you see it as a viable alternative to C++? Do you foresee C99 being integrated into the C++ standard in two years to retain compatibility with C? Do you think C++ should now start splitting away from its C heritage? Also on a completely unrelated subject, what kind of changes (if any) _are_ being planned for the new C++ standard in two years? I look foward to reading your opinions/input. Thank you for your time!
The standardization of iostreams with templates have made them huge, bloated, slow to link and completely useless! You can't forward declare them either - you have tosuck in the God-awful template header now everywhere. We have more useful things to do than wait for long compiles. And before you say it - I hate precompiled headers - I don't wish to track down comiler implementation bugs related to pre-compiled headers more than one time in my life, thank you very much.
You must be one of these guys that uses C++ just like a crappy superset of C. You really don't see the big picture in terms of reducing errors due to the fact that you write significantly less code through judious use of polymorphism and inheritance. If you think the only thing C++ adds is the '.', then you should use Java
One advantage of open classes is that they provide a way for the class user to introduce useful methods not thought of by the original class designer while retaining a uniform notation for accessing the functionality (a.new_method() versus new_function(a)).
Do you think open classes are a good idea? Were they discussed at all during the standardization effort? If you were to design C++ all over again, would you consider them? Why or why not?
Now, however, as opposed to back then, you are quite an important figure in programming languages and the computing field as a whole. You advocate using C *only* if a platform does not provide a working C++ compiler.
Have you considered making another language with all all the features of C++, without the backwards compatibility to C? While there would be more of a learning curve, you certainly have the importance to be taken very seriously, and a tighter language could possibly result.
Jack Valenti and the MPAA are to technology as the Boston strangler is to the woman home alone
Because they make simple things easy. Hello World is two lines of code in C and C++:
#include <stdio.h>
int main(){ printf("Hello, world!\n"); return 0; }
Languages that make simple things easy will appeal to beginners. Beginners eventually become experts. Then you have a situation where all the experts are using a langauge not because it's a good language, but because it made simple things easy.
Popularity, then, is almost independent of quality.
The most appropriate language for a job is the one that makes that job easy.
--
Patrick Doyle
Patrick Doyle
I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
I think that sometimes C++ is odd when you have classes not belonging to the same hierarchy but with some common functions, and for instance you want to make a list of classes that perform a common function.
In Java you can use interfases to solve that, in Smalltalk, as it isn't strong type, you have no problem at all, but in C++ you must use some sort of multiple inheritance or a new hierarchy of wrapper classes with the common funcions.
I found that the GCC compiler implement a extension called signatures that are like Java interfases and are very usefull in those scenarios. What do you think about signatures
or adding something like that to the standard C++??
I dunno about you, but I always thought stroustrup() would make a really cool name for a string parsing function.
/* Oustrup the source string */
int stroustrup(const char *src, char *dst);
please
When one of these new languages shows signs of becoming the "Next Big Thing", I'll consider having a look at it. And there's the rub : a language for development of large software systems needs a critical mass of users, which it has trouble getting when it has very few users. It's a serious problem even when the new language is much better designed than the status quo. I'd like just as much as anyone for a new language to come along and kick C++'s ass and become an industry standard, but I'm not holding my breath.
(Note: I didn't say C++ was industry standard.)
Sometimes one finds himself absorbed by framework of C++ way of thinking and techniques , in such a way to put the actual goals of writing a piece of software into the second place. This makes it of foremost importance to "to use all the features of the language" or rather "serve the C++ language ideas", instead of reaching the goal in a more practical way .
A very good example is all of us programmers trying to "TEMPLATIZE" everything, even when there is not much need (Yes, I know it feels good, and I do it too)
What do you think of this state of "getting burried in the language features, and wandering away from practical goals".
Thanks,
Huseyin Serkan YILDIZ
The Java lacks of C++ feature is frustrating for a lot of pepole, in my own opinion. On the other side, now the new Smalltalks (as Squeak ) can offer a better environment of Java (and even C++)? What do you think?
Giovanni Giorgi
-- Giovanni Daitan Giorgi http://gioorgi.com http://www.siforge.org
One problem I can see, though, is that if each of the blocks can have > 1 T instance in it, what happens when you start erasing? Oh. Never mind: You just keep track and reuse 'em. Placement new, placement delete. No problem. Uhh, wait a minute . . . you'd have to be writing your own allocator, or something very much like it. One way or another, you've got to be keeping track of the gaps in those blocks. That'll be a pain in the ass. Why not just allocate each T instance separately with new? In that case, it's an option that's available with the normal std::vector; that's usually how I use them. If I need to worry about keeping something sorted, I generally use std::map anyhow. I get the feeling I'm missing at least part of your point here, but I'm enjoying it anyway
Now, the problem that is left over, is the problem of taking a pointer to *(vec.begin()) and passing it to a C function that expects an array of T. That ain't gonna work.
Additionally, this vector impl may be a lifesaver if the space taken up by the objects you wish to put in the vector comes perilously close to exhausing your virtual memory.
Errr . . . how so?
(btw -- re: your other post in this subthread: Didn't I mention something about copy constructors? I don't see a need for the move thing, unless you could gain serious efficiency with it. Anything you're storing in a std:: container needs a copy constructor anyway, right? Requiring a copy constructor is nothing new.
---------------
Disclaimer: AFAIK, IIRC, YMMV, IANALL (I Am Not A Language Lawyer), u.s.w.
"Christianity neither is, nor ever was a part of the common law." --
In the literature I have, there's this little information-gap:
1. protected inheritance - what is it good for? (I used it a couple of times, for specific reasons, but what is the 'official' intention of this scheme?)
In the decisions made for designing the language features, I wonder whether the following has been considered:
2. pure abstract propperties - why is it that only method-propperties can be pure virtual, why not make data propperties pure virtual as well? I know cases where this would be suitable, and where templates are no option.
Bizar technology?
Actually, this document is getting a little long in the tooth. In fact, we are beginning to make significantly greater use of templates. See, e.g., nsCOMPtr. It turns out templates largely work on a great many platforms. The initial versions of the portability guidelines were written by people with a decided anti-C++ bias, and some of the items were more influenced by anecdote than by test. I am the new owner of this document. I hope to bring it up to date, though that requires writing a lot of sample code and running it through the grinder of 18 or so compilers. Not necessarily something bug-count sensitive management will want me working on.