Live data from Hacker News

C++: The Documentary

herbsutter.com

331–334 of 334 posts

Re: C++: The Documentary

#331
post #324

Earlier quoted context omitted.

> Why, exactly, is the c++ std::sort "wrong"? It's silently an unstable sort, which is surprising, and then to add insult to injury it's also slower. Yeah, I know, the C++ unstable sort is so slow it's slower than Rust's stable sort. YMMV for input types, sizes etc but generally that's what the numbers look like and though it's not universal it's actually quite common. "I bet the C++ is faster" is the wrong instinct,…

It's not so simple that you can just declare what is surprising. Surprise depends on context, and not everyone will have the same context as you. You say you would expect the term 'sort' to mean a stable sort, and I would expect it to always mean in-place sorting, others may expect it to use the absolute fastest way to get something sorted... Different users will have different priorities and therefore expectations.…

> It's not so simple that you can just declare what is surprising.

On the contrary, of course I can tell you that I was surprised and I'm far from alone. The fact you immediately grasped for "real world" comparisons ought to tell you that you're not thinking about this correctly because these are software sorts and so have very different affordances than the real world.

The claim that you wanted control doesn't make sense in the context of C++. There are in place stable sorts - the bubble sort you may have seen in class years ago is one, but C++ doesn't promise one in its standard library. However it does provide an unstable sort, which it just names "sort" and that's what I'm pointing at as a problem.

As to the "absolute fastest" you're in the wrong place if you've used a generic comparison sort expecting the "absolute fastest". For the machine integers it's usually not even the correct category of sort for "absolute fastest". But the C++ standard library is the wrong place to look even if you did need a generic comparison sort, because so much crap C++ exists and maintainers are scared to change anything for fear of what may happen.

Did you know libc++ didn't even have a guaranteed O(N log N) sort until the Joe Biden presidency? The introsort paper was written last century and the C++ standard itself did finally incorporate this basic requirement in 2011, but it took another decade for the Clang team to fix this.

Re: C++: The Documentary

#332
post #324

Earlier quoted context omitted.

It's not so simple that you can just declare what is surprising. Surprise depends on context, and not everyone will have the same context as you. You say you would expect the term 'sort' to mean a stable sort, and I would expect it to always mean in-place sorting, others may expect it to use the absolute fastest way to get something sorted... Different users will have different priorities and therefore expectations.…

> It's not so simple that you can just declare what is surprising. On the contrary, of course I can tell you that I was surprised and I'm far from alone. The fact you immediately grasped for "real world" comparisons ought to tell you that you're not thinking about this correctly because these are software sorts and so have very different affordances than the real world. The claim that you wanted control doesn't make…

Ok, I'll keep it short: I'm far from alone being surprised that a sort allocates temporary memory...

C++ is used by a lot of different people with a lot of different background, and... expectations...

My point is that "sort" is ambiguous and having expectations on ambiguity and arguing that a certain one is better is like arguing little endian being better or worse than bit endian.

Re: C++: The Documentary

#333
post #128

Earlier quoted context omitted.

Herb's blog post links to the SlashData Developer Nation Survey, so presumably that's what the claim is based on. The company has a methodology page here [1], and it looks like the Developer Nation panel [2] is one of the sources used by that company. [0]: https://www.slashdata.co/research/developer-population [1]: https://www.slashdata.co/company/methodology [2]: https://developernation.net/

Has anyone heard of any of these companies before? And I wonder what the number is for other languages. They want my email just to look at their "free report". Sorry that's not good to happen.

Hi, I'm a Principal Market Research Consultant with SlashData. We've been around for more than 15 years, and we work with the largest organisations in tech when it comes our market research on developers (our client page include AWS, Google, Microsoft, LF, Cisco, and so on and so on). Not bragging, but trying to assuage concerns that we are some fly-by-night org that popped up out of nowhere.

The makers of the documentary reached out to us to use our footage in the report and Bjarne has also used our report/blog when talking about the future of C++. In general, our hypothesis about its continued relevance is in line with what the documentary itself reports: developer numbers have grown massively and C++ has a very specific series of use cases that maintain its relevance.

Our methodology page is lengthy, but it can be summarised by the combination of several pieces of distinct information. We have labour statistics from various national governments to provide reference points, we use statistics from areas developers associate with (e.g. StackOverflow or GitHub) and compare against responses from inside the survey, and our own build-up of numbers based on the proportional data from within the survey (region, age, area, development, etc.). We have been doing this for many years. We also acknowledge in our reports that we are confident in all regions, but with greater uncertainty in the Greater China region, as we are a non-Chinese firm, so we have to work with partners in the region which minimises our confidence in the region.

The report lists the numbers for the major leading languages, basically any language that is used in multiple areas of development and has more than 500k users, give or take. It is not a perfect measure approach but it is about giving the most useful information at the highest level. We also exclude things like SQL because they are nor programming languages, unlike most of the other measures.

For the report, we typically have blogs available with similar information, but our free reports are designed for lead generation, which is why emails are asked for.

Re: C++: The Documentary

#334
post #332

Earlier quoted context omitted.

> It's not so simple that you can just declare what is surprising. On the contrary, of course I can tell you that I was surprised and I'm far from alone. The fact you immediately grasped for "real world" comparisons ought to tell you that you're not thinking about this correctly because these are software sorts and so have very different affordances than the real world. The claim that you wanted control doesn't make…

Ok, I'll keep it short: I'm far from alone being surprised that a sort allocates temporary memory... C++ is used by a lot of different people with a lot of different background, and... expectations... My point is that "sort" is ambiguous and having expectations on ambiguity and arguing that a certain one is better is like arguing little endian being better or worse than bit endian.

> Ok, I'll keep it short: I'm far from alone being surprised that a sort allocates temporary memory...

In a sense I'm sure this is true. C++ programmers routinely report being astonished about all sorts of properties of the language they have previously insisted they know well and who could blame them (for the former, at least).

Again, this is not symmetrical. LE and BE are symmetrical, if you have to pick one there isn't a "safe default" that isn't surprising to people who expected the other one†. In contrast sort stability isn't like that, all stable sorts also meet the criteria for an unstable sort. Likewise all the in-place sorts meet the criteria for an allocating sort.

C++ chooses to offer an unstable sort just named "sort". It doesn't offer a stable in place sort at all, but it does offer a stable allocating sort and names that stable_sort

† But what you can do is where it matters you explicitly offer the LE and BE options and silently whichever is native on your target is fast. Users can write whichever they meant and their program works rather than "Oops, by default on this platform it's the opposite byte order, there's a special conversion function to run". Needless to say C++ doesn't do this either.

Post reply on HN