
Bjarne Stroustrup Answers C++ Questions - praveenscience
https://news.codecademy.com/bjarne-stroustrup-interview/
======
cosarara
Question #1 was misunderstood. This is not about _sorting_ a sorted vector, it
is about _processing_ a sorted vector, in general. The example code of the
question sums the values. The example code of the answer does `sort(v.begin(),
v.end());` in run(). It is obvious that sorting something that is already
sorted shouldn't take much effort. Not so that adding all the values together
should be faster if the values are sorted.

~~~
Igelau
The already sorted collection is a classic example for Quicksort's worst-case
scenario -- specifically for implementations where the pivot point is the
first element.

It's not obviously easy either. You won't know if an arbitrary collection is
already sorted unless you check each element.

~~~
greggman2
I noticed that when I wrote a visulization. Plain quicksort on equal values is
by far the slowest.

[http://greggman.github.io/doodles/sort.html](http://greggman.github.io/doodles/sort.html)

~~~
Sohcahtoa82
Interesting things happen on that page when you click on one of the sorts to
see it in a bigger window, then you close it, then click it again. You can end
up with multiple sorts running at the same time.

------
jmkni
Would it not be better to just link to the actual interview? -
[https://news.codecademy.com/bjarne-stroustrup-
interview/](https://news.codecademy.com/bjarne-stroustrup-interview/)

This blog post literally adds nothing.

~~~
ableal
(From that article, thanks)

> port the compiler to an early 640MB Windows machine.

Probably meaning a 640 kB MS-DOS machine - the first C++ 'cfront' tapes were
going out by 1986, if memory serves.

~~~
mistrial9
cfront testing run on MacOS in 1987, from "floppy disk"; confirm

------
MikeTaylor
As far as I am concerned, Stroustrup's greatest contributions to programmer
are these three quotes, all from thre 2nd Edition of The C++ Programming
Language:

"The most important single aspect of software development is to be clear about
what you are trying to build."

"There are no 'cookbook' methods that can replace intelligence, experience and
good taste in design and programming."

"Design and programming are human activities; forget that and all is lost."

So true, so important, and so universally applicable.

~~~
copperx
It's a bit ironic that he could have used that advice on himself, especially
the first quote when designing C++.

~~~
ricc
My impression is he would have wanted to but he was limited by that era's
technology. Quoting from the article:

> If you could go back in time and change one thing about the original
> implementation of C++, what would it be?

> I don’t have a time machine and I shouldn’t try to second-guess 1983-vintage
> Bjarne—he knew the conditions at the time better than I do now, and any
> significant change probably wouldn’t have fitted in the 1MB memory I had to
> work with, and if it had maybe I wouldn’t have been able to port the
> compiler to an early 640MB Windows machine.

------
tsegratis
C++ cannot be greater than C... Because the ++ is post-increment

He created a great language though

\--

And agreed on the linking: every snippet on stackoverflow is effectively gpl

Requiring attribution/license change --- Unless you've already hyperlinked
every author name, stackoverflow, + the page it came from, AND those links are
not nofollow

[https://stackoverflow.blog/2009/06/25/attribution-
required/](https://stackoverflow.blog/2009/06/25/attribution-required/)

""Stack Exchange Inc; user contributions licensed under cc by-sa 4.0 with
attribution required.""

EDIT: see cc by-sa text. It considers itself gpl equivalent

~~~
greggman2
IANAL but I put in my S.O. profile that all my contributions are public domain
/ CC0. I suppose that makes them dual licensed?

~~~
woodrowbarlow
nope, because when you post content on SO, you are transferring ownership of
that content to stack overflow. you don't own it anymore, so you can't license
it.

> All materials displayed or performed on the public Network, including but
> not limited to text, graphics, logos, tools, photographs, images,
> illustrations, software or source code, audio and video, and animations
> (collectively “Network Content”) (other than Network Content posted by
> individual “Subscriber Content”) are the property of Stack Overflow and/or
> third parties and are protected by United States and international copyright
> laws (“Stack Overflow Content”).

[https://stackoverflow.com/legal/terms-of-
service#licensing](https://stackoverflow.com/legal/terms-of-service#licensing)

of course, if your answer replicates content from another source that you link
to in your answer, that other source still owns the content. so perhaps if you
self-publish first and then replicate and link to your original source, you
might be able to side-step this and license the original source as you like.

~~~
wool_gather
No, this is incorrect. Note "(other than Network Content posted by individual
“Subscriber Content”)"; this refers to the stuff that users create and post.
See the "Subscriber Content" heading below.

You _license_ the content you create to them:

> any and all content [...] that you provide to the public Network
> (collectively, “Subscriber Content”) is perpetually and irrevocably licensed
> to Stack Overflow

You still own the copyright to what you've written.

~~~
woodrowbarlow
oh, that's great news! thank you for correcting me.

------
thiagoharry
We would have better questions and answers if the community proposed and voted
for questions knowing that they would be answered by Bjarne Stroustrup. Not
just picking the most voted questions in Stack Overflow.

~~~
criddell
Probably not, unless you really want to hear Stroustrup's opinion on spaces vs
tabs.

------
ben509
If you're going to ask a language designer questions, how about these[1] or
these[2]?

[1]: [https://stackoverflow.com/questions/tagged/language-
design?t...](https://stackoverflow.com/questions/tagged/language-
design?tab=Votes) [2]:
[https://cs.stackexchange.com/questions/tagged/language-
desig...](https://cs.stackexchange.com/questions/tagged/language-
design?tab=Votes)

------
mansoor_
Some of these questions were silly and should have been filtered. Others were
asked before at CppCon and other conferences. Missed opportunity here.

------
gpderetta
> [...] after days of grueling interviewing, it turned out that they had a
> position after all

Not even Bjarne is safe from interview hell.

~~~
Ididntdothis
He wasn’t famous back then. Today would probably be a little different.

------
sonnynomnom
Hi, it's Sonny from Codecademy. Super awesome to see that this made it to the
front page of HN. Here are a few questions that didn't quite make it to the
original Codecademy blog post (written for our learners):

\---

 _What’s your perfect Saturday?_

Have a slow breakfast, do a bit of work – maybe writing. Maybe visit the
grandchildren. Run a few miles. Eat a good dinner out with friends. Settle in
for the evening with a good book.

\---

 _How was the 2019 C++ Standards meeting in Germany?_

It was a rather good meeting. The venue was great and we voted out a
“Committee Draft” for review by the national standards bodies. There is now a
feature freeze.

In February 2020, we’ll have the final vote C++20. It was a lot of work and
there were 220 attendees – a new record.

C++ is going to be great!

\---

 _What are some of the C++20 updates that you are especially excited about?_

\- Modules – to improve code hygiene and significantly speed up compilation.

\- Concepts – to simplify generic programming by allowing precise
specification of a template’s requirements on its arguments.

\- Ranges – to finally be able to write sort(v) rather than sort(v.begin(),
v.end()), to get more general sequences, and more flexibility and better error
messages through the use of concepts.

\- Coroutines – to get simpler and faster generators and pipelines,
simplifying asynchronous programming.

\- Dates – being able to efficiently and elegantly manipulate calendars; e.g.,
weekday{August/1/20/2019}==Thursday.

\- jthreads and stop tokens – threads that joins on scope exit (doing proper
RAII) and a mechanism for terminating them if their result is no longer
needed.

These changes – and many smaller ones supporting them – are major in the sense
that they will fundamentally change the way we program and think about our
designs.

C++20 will be as big an improvement over C++11 as C++11 was over C++98. It
will change the way we think about writing our code. I said “C++11 feels like
a new language.” I will be able to say the same about C++20.

Our code will become smaller, simpler, run faster, and compile faster.

\---

 _What newer languages or language paradigms are exciting to you?_

I don’t easily get excited and the field of languages doesn’t really develop
all that fast when you keep an eye on it.

Most changes are incremental and re-emerge repeatedly in different languages
with minor differences. I think the word “paradigm” is overused and misused.
If it means any more than “my latest bright new idea”, we don’t see a new
paradigm every decade. Maybe object-oriented programming, generic programming,
functional programming, and machine learning. That took 50+ years.

I tend to look for techniques that can be widely used. Over the last decade or
so, my main work has focused on generic programming and compile-time
evaluation. Maybe this will feed into a static reflection mechanism for C++
over the next few years. I like the idea of functional-programming-style
pattern matching and did a bit of research on that in the previous decade.

~~~
blt
This answer makes me excited for C++20 too. I'm not currently using C++ for
any projects; I might have to make one up.

------
cryptofits
Well it's good that he answers C++ stuff, a bit like Walter Bright here (or
wherever) answers questions related to D - but the more important question is
this:

In the face of more competition, e. g. python, Rust, Go etc.., what is the
future of/for C++?

~~~
saalweachter
Stroustrup is the beloved creator of C++, but C++ is decidedly _not_ governed
by a benevolent dictator; a very large and active Committee guides its future:
[https://isocpp.org/std/the-committee](https://isocpp.org/std/the-committee)

~~~
adev_
I have to say that I have a lot of respect for the man.

Many project leaders/creators position themselve "authoritative god" on their
project, and finished often disconnected from their community taking arbitrary
wrong decisions.

Bjarne has been smarter than that, giving the community (a very diversified
community ) the opportunity to drive the language together.

And it worked, C++ survived 40 years, stronger than ever, evolving from a
primitive "C with class" to a modern language present in almost every
electronic device nowadays.

It might not be "perfect", "pure", but it does not matter. It fucking work...
and evolve in the right direction... That's the C++ way.

~~~
saalweachter
In addition to benefiting from _many_ smart people at the helm, instead of
just one, it also benefits from having no real single points of failure. It
has a multitude of cooperative leaders, support from many large and even small
corporations, and many implementations as well as its formal Standard (which
after the long wait for C++0x, has had a number of good, well-adopted
updates).

------
cletus
I'm surprised this isn't closed as "not constructive".

~~~
test1235
or opinion based

------
taneq
How is the top C++ question not "undefined behaviour: what the hell?"

~~~
otabdeveloper4
"Undefined behavior" is a quirk of the C++ ISO standard legalese, not some
property of computing or of the C++ language.

Briefly, the C++ standard defined three classes of stuff that isn't covered by
the standard:

 _Implementation-defined behavior_ \- "behavior, for a well-formed program
construct and correct data, that depends on the implementation and that each
implementation documents".

 _Unspecified behavior_ \- "behavior, for a well-formed program construct and
correct data, that depends on the implementation".

 _Undefined behavior_ \- "behavior for which this document imposes no
requirements".

So 'undefined behavior' is stuff that isn't mandated by the standard and also
may or may not be an error.

Some UB stuff is bugs (like accessing arrays out of bounds), some isn't bugs
but just processor/OS dependent stuff that is out of scope of the C++
standard. (Like what happens when integers overflow.)

In short, the existence of UB is a good thing; having a standard that clearly
states what is part of it and what isn't is vastly better than a standard that
mandates too much or is too vague.

(And it goes without saying that having no standard at all, like is usual for
other programming languages in 2019, is worse in every way.)

~~~
twic
I'd rather have a language with no standard and no UB than one with a standard
and UB.

~~~
jcelerier
since the language has no standard, from the point of view of ISO, using the
whole language itself is UB :-)

~~~
twic
If ISO want to come round and do some programming for me, i will be happy to
discuss it with them!

------
davrosthedalek
Hah, he mixed up milliseconds and microseconds!

