Friday, May 19

C++ STL, crap, but the best crap we've got*

[* I did a 10 year stint of C++, so I figure I'm vaguely qualified to have an opinion.]

The STL, you either hate it a lot or a little.

Sure there are some folks who think it's an adorable little beast, write books about it, attend conferences, think it's elegant, take it out to dinner and so forth, but to them I say "There are 3 types of people, those who like maths and those who don't".

It's efficient. Too efficient for its own good, frankly. Clearly designed by an academic who didn't think easily readable and easily maintainable were necessary design criteria.

As I get older and crankier I want to spend less time fighting the language syntax, dealing with esoteric class libraries and less time waiting for the compiler to finish doing its languid lap around the pool (GCC you are hopelessly slow, may Microsoft or Intel buy Linux and replace you with a decent compiler).

So there are 2 issues. The STL is uglier than those scrawny things were on Friends, and slower to compile than a book index. Templates you see. Fancy, cunning, clever, smart, ingenious, nifty but achingly slow.

I wondered on a job a few years ago whether the amount of time spent waiting for heavily STL and templatised code to compile and link (6-8 hours multiplied by 3 years) was actually less efficient than if we'd been using a non-template based solution.

Another thing to despise about the STL is the wacky "have at you DOS Liberal scumbags" decision to remove the ".h" from the filenames of headers. 20 years of .h/.hpp etc extensions on all files, and then suddenly "Ha! Things are getting too easy! Let's make this unwanted and inexplicable change just to make you thing we're clever."

It's a shame the shaggy-bearded, pot-smoking, tree-hugging hippy C++ community approved the STL as part of the C++ standard.

No comments: