Posts Tagged ‘stl’

Hating that which you don’t understand

Wednesday, January 19th, 2011

A few days ago, I came across an inter­est­ing rant about “Why C++ Tem­plates (and STL) Are Bad”.

As any C++ pro­gram­mer who reads my blog likely knows, I’m quite fond of both tem­plates and the STL — I feel those are largely what trans­forms C++ from a clumsy and out­moded lan­guage that should’ve died 10 years ago, into a mod­ern, expres­sive, high-performance and yes, even ele­gant lan­guage that I enjoy using. (more…)

“Good design”, and why OOP isn’t going to get us there

Sunday, November 7th, 2010
  • in which I prob­a­bly get stran­gled by a horde of angry OOP programmers…

I find OOP tech­ni­cally unsound. It attempts to decom­pose the world in terms of inter­faces that vary on a sin­gle type. To deal with the real prob­lems you need mul­ti­sorted alge­bras — fam­i­lies of inter­faces that span mul­ti­ple types.
I find OOP philo­soph­i­cally unsound. It claims that every­thing is an object. Even if it is true it is not very inter­est­ing — say­ing that every­thing is an object is say­ing noth­ing at all. I find OOP method­olog­i­cally wrong. It starts with classes. It is as if math­e­mati­cians would start with axioms. You do not start with axioms — you start with proofs. Only when you have found a bunch of related proofs, can you come up with axioms. You end with axioms. The same thing is true in pro­gram­ming: you have to start with inter­est­ing algo­rithms. Only when you under­stand them well, can you come up with an inter­face that will let them work.  — Alexan­der Stepanov

This post is an attempt at extract­ing some­thing coher­ent from a series of com­ments I recently left on a Stack­Over­flow ques­tion about “good design” (in what’s quite clearly an object-oriented con­text). The per­son ask­ing the ques­tion has been gra­cious and patient enough to deal with my count­less com­ments repeat­edly point­ing out that he’s doing it wrong, which would prob­a­bly have dri­ven a lot of peo­ple mad.

Many peo­ple have come up with many var­ied crit­i­cisms of the object-oriented pro­gram­ming par­a­digm. My prob­lem with it is not new — in fact it is pretty much exactly what Stepanov pointed out in the inter­view I quoted above (and which is def­i­nitely worth read­ing in its full length). The only real dif­fer­ence is that he is an extremely intel­li­gent math­e­mati­cian, and I’m… not. So I’m not able to express it as con­cisely. But then, on the other hand, maybe my take on it will be eas­ier to swal­low for oth­ers who also aren’t hyper-intelligent math­e­mati­cians. (more…)

STL, language lawyers and pedantry

Monday, August 16th, 2010

Any­one who’s been around a C++ pro­gram­mer for any length of time has prob­a­bly real­ized that we tend to be hor­ri­ble lan­guage lawyers: we only trust the ISO stan­dard describ­ing the lan­guage. We cer­tainly would never assume some­thing to work just because the com­piler hap­pens to gen­er­ate code that works right now. If it’s not in the stan­dard, we can’t count on it.

I’m fine with that. It’s often annoy­ing that we have to be so para­noid, that we so often have to double-check that our code not only com­piles, not only passes our tests, but also avoids the dreaded Unde­fined Behav­ior (where the behav­ior is not con­strained by the stan­dard), but you get used to it. And all in all, being pre­cise and spe­cific when talk­ing to a com­piler is prob­a­bly not a bad habit to get into, regard­less of which lan­guage you pro­gram in.

How­ever, every once in a while, peo­ple try to carry the same level of pedantry over into dis­cus­sions about C++. (more…)

Thesis

Tuesday, July 28th, 2009

Finally, after too many years study­ing at DIKU, I’m about to start on my master’s the­sis. That feels weird.

But I’m still not sure what I want to write about. I’ve got a few ideas, mainly by ask­ing some of the pro­fes­sors I might want as advi­sors if they had any inter­est­ing projects lying around. (more…)