Interviews: Ask Bjarne Stroustrup About Programming and C++
In addition to being the creator of C++, Bjarne Stroustrup is a Managing Director in the technology division of Morgan Stanley, a Visiting Professor in Computer Science at Columbia University, and a Distinguished Research Professor in Computer Science at Texas A&M University. Bjarne has written a number of books and was elected a member of the National Academy of Engineering. He will be doing a live Google + Q & A within the C++ community on August 20th, 2014 at 12:30pm EST, but has agreed to answer your questions first. As usual, ask as many as you'd like, but please, one per post.
Sometimes well-established languages keep adding new features and syntactic constructs until most developers are not even aware of all the possibilities, and use maybe 20% in their usual daily work. The old features and syntax are kept around for compatibility and to keep the old guard content, even if cutting them would lead to faster compilation, more elegant language and less confusion.
This may be part of the reason for the constant introduction of new trendy languages with radically simplified syntax and libraries... Which then follow the same pattern. Few languages are introducing new paradigms, many are trying to be a "better" C++, Java, LISP, JavaScript or Perl.
Do you think this cycle is inevitable, or could it be a good idea to sometimes clean up the syntax and the obscure features in new specification versions, to keep the established languages more competitive?
C++ is one of the most complex, inscrutable computer languages ever created. When I read about C++11, I was surprised that it layered more complexity and inscrutability on top of what was already there (like the weird lambda syntax). I wonder if C++ has become an over-the-top example of how not to do a programming language. Is that by intent, or did it just happen? In future versions of the language, will any cosmetic changes be made to create a more understandable language that doesn't overload a small set of symbols and keywords, so that normal programmers have a chance to figure out the language? The language seems to have reached the point that C++ gurus design it for other C++ gurus, and everyone else ignores it. C++ was once the up and coming language of choice, but it has become so difficult that programmers have considered it damage and routed around it. Are you comfortable with this fate for C++, as a niche language for insiders, or do you want to use your influence to rehabilitate the language so that more programmers will use it?
How do you feel about the evolution of C++ since it was first implemented with Cfront? What began as a pretty straightforward language has been expanded to significant complexity. Has this evolution been positive, or has it been an attempt to make the language apply to too many possible applications?
"To those who are overly cautious, everything is impossible. "
This question is a little US-centric. Let me try to iteravely improve on this...
From your perspective, how is the globalization of commerce and specifically programming affecting you and those you know? Are the new high level scripting tools available to programmers since C++ became popular pushing the profession towards a more "commoditized" state, where people are easily replaceable and where the related skills and specialization eventually offer no better benefits and compensation than other less skilled professions?
The real path to male liberation
What is your favourite programming language that isn't C++ (or C)?
Maybe the premise of this question is wrong... but I seem to recall reading somewhere that you hate C but built C++ on top of it because it was popular. Is that true and if so, do you ever feel bad about the bait and switch?
Copyright (c) 1990 - 2014 Dice. All rights reserved. Use of this comment is subject to certain Terms and Conditions.
Has everyone responsible for the std::vector<bool> tragedy been kicked in the nuts until they are no longer at risk of reproducing?
Copyright (c) 1990 - 2014 Dice. All rights reserved. Use of this comment is subject to certain Terms and Conditions.
What do you regret most in C++ and how would you like to change it?
The general consensus as I understand it is that the <iostream> wing of the C++ standard library is hairy, convoluted, time inefficient, and space inefficient in implementation. What's the better solution? <cstdio>? Is Boost.Format, as shutdown -p now suggested, any good?
One of the recent concerns raised with C++ compared to other popular languages is the breadth of the standard library. I know that the C++ standard committee was looking at adding a C++ transformed version of Cairo to the standard. And of course their is boost. What else do you see coming to address the perceived API shortcomings?
With so many new languages writing a spec and then a standard compiler to conform to the spec, I'm curious how you feel about writing a spec and not a compiler.
How do you think this compares to other efforts? Do you enjoy this aspect or do you occasionally get your hands dirty with a particular compiler source? etc.
What is your opinion of the the "Hour of Code" as promoted by CSEdWeek? Does it trivialize computer science education?
Do you think that one thing holding C++ back is the lack of a standarized binary interface?
Currently if I want to make a module that can be consumed by others (whether than is others using a different language, or a different C++ compiler, or even just to use a pre-built module without sources) I have to export everything as C and use its (de-facto if nothing else) binary standard.
I think an ABI for C++ would increase its "real world" attractiveness considerably with little, if any, overhead. Do you agree, or are there issues around this that make it a significant challenge (apart from vendor adoption of course).
Workforce diversity is a big issue these days. What steps has the c++ working group taken to increase the numbers of female and minority contributors? C++ (perhaps unfairly, due to the popularity) is often criticized in feminist circles for being a patriarchal programming language. Will you be taking steps to address those concerns?
Copyright (c) 1990 - 2014 Dice. All rights reserved. Use of this comment is subject to certain Terms and Conditions.
Do you think AI will start replacing junior programmers in the foreseeable future, similar to car drivers and call center operators?
When will Boost ASIO make in into the standard library? C++ really needs something of this magnitude for networking and asynchronous event handling. I have not heard much on N3360 since it was proposed.
the growth in cynicism and rebellion has not been without cause
How do you feel about the fact that Darl McBride said that SCO owns C++?
Source 1
Source 2
Source 3
Source 4
I'll see your senator, and I'll raise you two judges.
Why doesn't C++ have in language support for memory allocation?
C++ has the new and delete operators, whose low-level operation a class can customize. Could you clarify what you're asking for?
If you don't add it C# and Java with their GC awfulness will continue to eat C++'s lunch.
The problem with tracing garbage collection as implemented in Java, C#, and the like is that it tends to break the Resource Acquisition Is Initialization (RAII) idiom seen in C++, where an object's destructor is responsible for freeing non-memory resources held by the object, and the language supports calling this destructor automatically in many cases. Instead, GC languages have what I call "viral disposability": a conventional name for an explicit destructor method that an object's owner must remember to call, and anything holding a disposable object must also be disposable.
I learned C++ the hard way: by hacking on a million-LOC program. It's taught me to loathe the language. It's big, complex, and incomprehensible. I once spent three days chasing a bug through a twisty little maze of templates, all different. I routinely struggle with the implications of static vs. not, member variables vs. globals vs. statics, functions that are part of a class vs. those that aren't... Getting code to even compile is often an exercise in trying something, running the build process, then trying something else, lather, rinse, repeat. It's left me frustrated enough to want to drive to College Station and scream at the walls.
All of this has left me wishing for the days of C, in which I'm quite fluent.
Nevertheless, the world seems (perhaps overly) enamored of C++, and I'm probably going to have to deal with it. How do I learn to at least tolerate it, if not like it, instead of actively hating it?
Disinfect the GNU General Public Virus!
The comments and questions here look overwhelmingly negative. On the other hand, all of this passion only exists because people are using C++.
I'm a fan of C++ overall, but it seems to me that C++ templates are a bit of a disaster. They're so complex that I doubt that anybody but you and P. J. Plauger *fully* understands them. Also, when they're actually used, they often result in bloated, slow code - as I recently experienced when stepping through some STL string functions. Further, they bring on a lot of portability issues, evidently due to the difficulty that even the compiler folks have had in understanding and implementing them. Therefore, many programmers minimize their use of templates, both in their own code and in their use of templated library code.
Compared to the complexity of C++ templates, the C macro preprocessor provides a rudimentary form of templating via its very simple and powerful paradigm of text substitution. I've had some success implementing a limited form of generic (type independent) programming in C using just the C preprocessor. I've had much less success doing generic programming via C++ templates.
If you had templates to do all over again, what would you do differently? Was all the complexity of C++ templates (e.g. "partial specialization") really necessary to achieve its goals? Were the goals maybe too ambitious?
When is C++ going to natively support multiple return types?
You refer to the struct or tuple hacks. PHP and Python use a tuple hack similar to C++'s to return multiple values. Perhaps what you really want is readable syntax for assignment of multiple variables from a std::tuple. And now my own question for Bjarne: When are we getting that?
C++ is more or less a superset of C (give or take a few minor issues), why has regular C continued to thrive?
Donte Alistair Anderson Roberts - hi son!
Karma: Chameleon
If you could add one feature to C++ (either the language or the standard library) and have it adopted in the C++ standard and supported by all the compilers etc, what would it be and why?
Apple recently introduced a language they call Swift or Objective-C without the C. It is technically a completely different language from Objective-C though. When C++ started out it had the major benefit that it was (mostly) compatible with C which at the time was immensely popular, making it trivial to mix new C++ code with existing C code. Today C is still a popular language but not as widely used as it once was. Assuming that C++ could drop C compatibility, how would you take that opportunity to improve C++?
The linked G+ post says "August 20th, 2014 at 12:30pm EST to 2:30pm EST", but August 20th, 2014 is during Summer Time/Daylight Saving Time ...
So, is is 12:30pm EST, or 12:30pm EDT ??
There are optimizations you can use to improve your experience with C and C++.
// uses less memory // makes code run faster
Just insert these into your header files for both time and space improvements in your compiled code.
#define struct union;
#define while if;
Now how can you say bad things about a language that is so easily improved?
I'll see your senator, and I'll raise you two judges.
Apart from work, do you have any personal programming projects going on? Which type of programming do you like most and is there a particular project that you would like to implement?
In C++ how would you write the most elegant solution that prints numbers from 1 to 100, replacing any number divisible by three with the word "fizz", and any number divisible by five with the word "buzz"?
The last thing C++ needs right now is another complex feature which adds more syntax and fundamentally new operation.
Alter Aeon Multiclass MUD - http://www.alteraeon.com
Hopefully, not for a long time. C++ doesn't need more complexity at the moment. It needs less.
Alter Aeon Multiclass MUD - http://www.alteraeon.com
You speak alot about code rejuvenation and bringing old code to new standards. As you are working on C++14, many compilers do not fully support C++11 yet. In the past, it was even worse. Don't you think that this lack of feature support from compilers is a major problem and the biggest obstacle to code rejuvenation?
Are there any features of the language that you wish hadn't been added or could now be removed?
All those moments will be lost in time, like tears in rain.