Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm not sure that's descriptive so much as an ideal.

In practice (mentioned this in the blog comments as well) I've found that the C++ world is somewhat divided between what I'll label the Boost and Qt camps.

Boost, as kind of a conceptual child of the STL, has extended more along the axis of exploring what's possible with the language, at times at the cost of pragmatism. The Qt camp, on the other hand, tends to hide most of the heavy use of generic programming in private classes and exposes more simplified APIs, typically with minimal use of templates in public APIs.

I personally, as a former long-time KDE developer, fall firmly in the Qt camp and it shows in the way that I write C++. It's also the style that's been preferred in the two companies where I've been employed as a C++ developer.

Which is modern is mostly a semantic issue. I'd wager that while advanced template programming is more cutting-edge, it's also not in fact the way that very much C++ today is actually written, which is the definition of modern I was working with.



The book that defines the genre ("Modern C++ Design", by Andrei Alexandrescu), is all about template metaprogramming. I'd say that's the end of the semantic debate.

Maybe you could say that I'm in a "camp", but the C++ style that Qt uses is based on the outdated notion that compilers can't keep up with the "modern" features of C++. That style is antiquated.


Current compilers still generate huge binaries for code that makes excessive usage of templates; I've personally had to rip out a lot of heavily templated code in the last year for that reason.

They also still (with the Intel compiler as a notable exception) generate nonsensical error messages when templates are used heavily.

The latter reason is one of many that a lot of C++ programmers don't do well with heavy template usage. One naturally could fault those programmers, and I think that's half-way fair, but in designing reusable APIs, API usability is and should be a concern. The corollary seems is obviously a bad principle when applied to (graphical) interfaces: if the users weren't so dumb it'd be easy to understand. I believe the same holds true, generally, for API design.

Half-way related, I'm personally quite a fan of Designing Qt-style C++ APIs:

http://doc.trolltech.com/qq/qq13-apis.html

As for "modernness" the point still stands; when some people say, "modern music" they mean "avant garde". Others mean "the stuff on the radio". I mean the stuff on the radio; Alexandrescu is the avante garde.


Compilation speed and incomprehensible compiler errors remain an issues for template heavy code but this is the first time I've heard complaints about binary size. Can you educate?

Theoretically the incomprehensible compiler errors will go away in the next couple years as compiler writers integrate C++0x "concepts."


Every specialization of a template creates a new instance of it with new symbols. With heavily nested templating that can add up quite quickly.

The most problematic case at my last company was where there were several hundred specializations (just one-liners) one after another in some of the error handling code. Each of those specialized several more templates. I managed to shave a few dozen MB off of the binary size (and remember, larger binaries == more cache pressure) by replacing the templates with a base class and virtual function.


It's also the style that's been preferred in the two companies where I've been employed as a C++ developer.

I'd be interested to know what industry those companies are in. Do certain fields prefer one style or another?


The first was in the parts of the SAP R/3 kernel that I touched while working in the LinuxLab there (I can't say authoritatively for the entire kernel), the second was at Native Instruments, largest pro-audio software company. Naturally the largest C++ Open Source project, KDE, tends towards Qt-style (being built on Qt). I'm not sure for Mozilla and OpenOffice.

At the latter company we had about 30 developers, on average quite good. There were a couple that were into advanced template techniques, but the usage of such in the code was usually quite limited.

My feeling, though this could probably be better answered by folks that are fans of said template techniques, is that the primary usage of such happens in academia and smaller shops.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: