In Medio Stat Virtus

No, I will not write about virtual function call runtime overhead ;-). I want to comment on some blogs instead and point out that the virtue is not in extremes.

Is functional programming back to mainstream? Writes Joel Spolsky about merits of functions: “programming languages with first-class functions let you find more opportunities for abstraction, which means your code is smaller, tighter, more reusable, and more scalable”. Well put, Joel. To conclude his point, Joel refers to Steve Yegge’s blog. Steve is a bit too harsh on OO, but has a point nevertheless. At one point, he even gives a credit to C++ for supporting functions. He immediately straightens the record, though, explicitly stating that he does not claim “C++ is good”. It appears that Steve feels like no respectable contemporary programming expert could utter a such a heresy. Perfect things exist in fairy tales, Steve. We, however, live in an imperfect world. And, as a consequence, C++ is indeed not good. But it’s the best we’ve been able to come up with so far. It is hard (yet worth the effort) to find the right balance between embracing new technologies with moderation while keeping the good old practices and backward compatibility. What we are (finally) witnessing is the thick OO (Objects Only) early morning fog evaporating in the mid-day sunlight. In that sense, Java has already failed with “everything as Object” (except for those few things that are not) and it’s version of “generics”. Moreover, the former is failing on two fronts simultaneously: C++ crowd sees it for what it is – a trendy marketing name for a fancy cast syntax, while Java crowd thinks Sun (pun intended 😉 ) has rudely spoiled their foggy OO party.

And what about our favorite language? It’s been happily promoting multi-paradigm programming for decades now. The C++ future is exactly where it’s been so far – compatibility with the past, promotion of good practices, smart introduction of new concepts and libraries and keeping up with technologies as they become mainstream (which is not exactly at the moment of an idea introduction as Herb Sutter points out). As long as it regards the past, keeps up with times and technology while steering clear of extremes, C++ will do just fine. Respice, adspice, prospice.