Nat! bio photo


Senior Mull.

Twitter RSS


Stroustrup, a barrel of laughs

I had a really good time reading an article by Bjarne Stroustrup (via Slashdot) about upcoming C++ changes. You know that I think C++ is basically a piece of shit. Nevertheless I do use it and actually make part of my income doing C++ coding.


At the end of his article Stroustrup writes up under Pulling it all together how to use some new language features. The divine words of the giver of language - outside of code - are of course in bold face, while my heretical comments are in the italitzed font. Here we go...

template<Container C>
void draw_all(C& c) 
where Usable_as<C::value_type,Shape*>
    for_each(c, mem_fun(&Shape::draw));

There are assembled so many interesting graphic characters and new keywords and new built-in functions to do what amounts to a lesser version of [container makeObjectsPerformSelector:@selector( draw)]. Why does this start to remind me of Perl ?

vector<Shape*> v = {
    new Circle(p1,20),
    new Triangle(p1,p2,p3),
    new Rectangle(p3,30,20)


list<shared_ptr<Shape*>> v2 = {
    new Circle(p1,20),
    new Triangle(p1,p2,p3),
    new Rectangle(p3,30,20)


I certainly enjoy the obvious necessary addition of shared_ptr there on the v2 list in comparsion to vector as to not make it too easy for the minions. Easy but not too easy. There is a line between simple and stupid. And this is clearly quite safely outside of simple.
Then Bjarne closes with these priceless statements. Priceless they are solely, because they are written by the inventor of C++ the most humongous, kludge of a language ever conceived:

I hope that after looking a bit at this example, your reaction will be "How simple!" rather than "How clever! How advanced!"
Well my reaction is neither. How peculiar.

In my opinion, many people are trying too hard to be clever and advanced.
Nah, really ??? Does he mean those implementors and vendors of C++ compilers ? Though I suspect they need to be this clever and advanced, because C++ has got to be the most difficult language on earth to implement.

The real aim of design and programming is to produce the simplest solution that does the job and express it in the clearest possible way.
This is going into my signature. This from the guy who invented templates, name mangling, references, operator overloading and casting beauties such as B* const localThis = const_cast<B* const>(this); It appears to be so obviously not the case with C++, that statements like this sound as unique as a Pope Benedikt's recommendation for a black metal album would.

The aim of the C++0x design is to better support such simple solutions.
Well, maybe so. An aim is hard to contest.

Somehow I wouldn't be to surprised now if I were to read from John McCarthy : Parentheses, Considered Harmful!".