Live data from Hacker News

C++: The Documentary

herbsutter.com

121–130 of 334 posts

Re: C++: The Documentary

#121
post #6

Earlier quoted context omitted.

I have the utmost respect for Casey, but his disdain for Stroustrup is unfounded. The fact of the matter is C++ occupied a niche in the right place and at the right time, and it grew from there. Many mistakes have been made, but Stroustrup is in no way personally responsible for all of them and I don't think Stroustrup is a bad programmer (something I've heard Casey say in some of his videos). You can argue that the…

Strangely, I've never seen any nice code from Casey despite all of the mud slinging he's done over the years. Maybe it exists somewhere but I watched a lot of Handmade Hero when it was starting off and the code was a mess. It feels as though he just attracted an audience of junior developers who take everything he says as gospel, as is often the case with social media programmers. Lord knows I've argued with some of…

I'm confused. I looked at the Handmade Hero videos and I had no trouble following - it was simple straightforward procedural code. As I understand it, his code does "exist somewhere". Bink 2 from RAD Game Tools, which seems to ship with practically all games. He also developed the Walk System that shipped in "The Witness" (2016). You can see his blog posts and video lecture about that. I see that he and a Jay Stelly from Valve simplified the GJK algorithm, and he talks about how to implement it. I know he has his Performance-Aware Programming series, where he talks about the technical details of hardware and how they relate to code performance. Here, I even found a tweet listing all the things he'd written till that point: https://xcancel.com/cmuratori/status/1412839131063873536>. Perhaps you didn't look hard enough?

Can someone give me links to Bjarne Stroustrup's code? I tried searching but I'm having a hard time finding anything. I would like to verify some of the claims being made in the other comments (it's hard to tell if someone's code is better or worse relative to another person's without having access to the code and comparing important metrics and all that.)

Re: C++: The Documentary

#123

My only problem with C++ is that it’s too verbose. my eyes need to parse huuge chunks of things when I just want some convenient syntax for it. otherwise the idioms are pretty universal for most programming languages nowadays.

C++ is quite amenable to making things less verbose. For example: Instead of a standard library algorithm taking a pair of iterators, you could have a function taking a container and calling the other function with its start() and end(). And then, with newer versions of the language, you can use a ranges-based function. There are lots of such syntactic hacks, from `using` through typed literals all the way to preproc…

That's just terrible, I love it.

Re: C++: The Documentary

#125

Earlier quoted context omitted.

I fully agree. In my personal project, I ended up using the STL to get off the ground, but in the end I replaced pretty much everything with custom-written code. Once you get rid of the STL, compile times get so much better. With modern c++23 features, templates actually become really convenient to write, and at the core there is a really useful and pleasant to use language. I try to avoid c++ libraries and instead r…

What, you rewrote std::deque? Whew!

Rewriting at least std::vector was a standard way to prep for a Google interview. And std::map if you wanted bonus points or a level up. Also, really interesting to do.

Re: C++: The Documentary

#126
post #12

I‘m out of the loop: we‘ve had Python, Clojure and possibly something else recently. Is that a series by the same people working through several languages? Is it happenstance? Is it a trend, and every programming language is now scrambling to get their own video documentary?

Yes, these are the same people: https://www.cultrepo.com/ Apparently, they are making documentaries about open source software.

That‘s cool, since it establishes a brand. If one was done well, the others probably are, too, so even if it‘s not your language of choice, it will be interesting.

Re: C++: The Documentary

#127

Earlier quoted context omitted.

some of the STL is easy to improve on. For example, std::unordered_map performs poorly due to pointer stability requirements in the standard. Most performance sensitive C++ codebases will use something like abseil's hash maps instead.

Just a heads-up: if you're already using boost, boost::unordered now has open addressing containers (unordered_flat_map and unordered_flat_map) and they are among the fastest.

Seconding this - boost::unordered_flat_map was only added in December 2022 and many people don't know about it yet.

Re: C++: The Documentary

#128
post #15

+90% users in the past 3.5 years huh? That is incredible growth. How is it even measured?

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.

Re: C++: The Documentary

#129

Earlier quoted context omitted.

C+ Standard Template Library is the best designed part of C++ library. It was designed by Alexander Stepanov. https://en.wikipedia.org/wiki/Alexander_Stepanov

So, a few things (aside from the whole nomenclature argument already in another reply) 1. Stepanov's generic programming is a good idea. Every language you've seen with "generics" that's his idea, to the extent "The STL" is generic programming, everybody agreed it's a good idea. 2. But the STL is very old now, so while the idea is good, this is one of the oldest (Stepanov had tried this in other languages before C++)…

AFAIK, std::map is also OK for what it is: an ordered, node-based (tree) map. These are (almost) always slower than hash tables. Of course, std::unordered_map, the std hash table, sucks because of unforced errors. For that, there is boost::unordered_flat_map.

Re: C++: The Documentary

#130

Earlier quoted context omitted.

C+ Standard Template Library is the best designed part of C++ library. It was designed by Alexander Stepanov. https://en.wikipedia.org/wiki/Alexander_Stepanov

It has some very useful principles, but also some super-annoying gaffes and mis-design aspects. One example: Allocators. What a mess! Or the fact that if a map lookup fails, an exception is thrown. I can't count the times I've had some app just bail out on me with an at() exception, because the author neglected to handle it (and the map/unordered map interface did not force them to). That does not detract from Stepan…

The kind of programmer who don't check (or think through so that they can't fail) their map lookups is also the kind of programmer who don't bother with const. What a non-const unchecked map lookup gives you is a default-constructed value that has just been inserted for the only reason that operator[] returns a reference, which must "point" to something. That's bad and can be confusing, but it doesn't crash.

I see that problem much more often than crashes due to unchecked map lookups in production, which are very rare for me. Less than once a year.

Post reply on HN