Bjarne Stroustrup’s GoingNative 2012 Keynote

I just watched Bjarne Stroustrup’s keynote from GoingNative that happened in February of last year. He had a lot of great insight on how to write better code that is easier to read, less error prone, and faster! Now, I still have concerns about the STL. It’s great to see a lot of potentially more portable code being made available via the STL, especially if you look at the concurrency domain. However, the STL is pretty well known to be slower than if you implemented it yourself. In my personal implementation of std::vector, I get a 300% speed increase on my push_back() calls (although I just call it push()). Now, I’m sure the STL version has a hell of a lot more going on than my version, considering how pretty much every STL container shares similar interfaces, iterators all share the same interface, and I’m sure there’s more edge cases and specific scenario’s the STL potentially worries about. There’s also the question everyone needs to ask themselves, do you need that speed increase? Is the STL really the part of your application that slows you down enough that you need to be concerned? I’m sure in most cases it’s not. Hell, even in my case, it probably isn’t, but it is a lot of fun implementing a lot of these data structures. Not to mention that my implementation, while probably not as robust, is a hell of a lot easier to read and compiles a lot faster.

Anyhow, not much content on this post, but I figured I’d share something that I thought was interesting.

EDIT: I guess it would also be worthwhile to mention that my implementations aren’t thread safe, while I believe the STL data structures in C++11 are thread safe, which is probably where a lot of the overhead is coming from.

More Reading