Posts Tagged ‘c++’

A follow-up rant about Connect

Saturday, August 27th, 2011

So my last blog post got a sur­pris­ing amount of atten­tion, not least from a/the (no clue how many there are of those) Prod­uct Man­ager of Visual Stu­dio, which is pretty neat.

So, here’s a quick fol­lowup, in order to fully exploit my 15 min­utes of fame!

(more…)

What’s wrong with Visual C++ and Microsoft Connect?

Saturday, August 13th, 2011

Using Visual Stu­dio 2010 with Ser­vice Pack 1, try doing the following:

  1. cre­ate a new project of type Win32 Console Application, and under Application Settings in the project wiz­ard, select Console Application and Empty Project.
  2. cre­ate a sin­gle .cpp file
  3. add the code int main() {} to it
  4. hit build. (more…)

C++11’ish approved!

Saturday, August 13th, 2011

Not much to say here, other than that C++11, or pos­si­bly C++12, for­merly known as C++0x, has been approved unan­i­mously by ISO.

Hur­rah!

Appar­ently, it’ll take a few months for all the paper­work and such to catch up, and then the final stan­dard will be pub­lished by ISO (I haven’t been able to find a clear answer to whether or not this might drag the final release all the way out to 2012, but hope­fully, C++0x will be for­ever known as C++11).

STM Status Page

Sunday, June 5th, 2011

As I men­tioned not too long ago, I’ve recently resumed work on the STM library I cre­ated for my Mas­ters Thesis.

It’s still not quite where I want it to be, but I felt that at the very least, it deserved a proper sta­tus page. So here it is. A brand new page on my blog. As I’m still rather busy, I can’t promise that much will hap­pen with the library over the sum­mer, but when some­thing sig­nif­i­cant hap­pens, that page will be the first to know.

Empty statement of intent

Friday, April 15th, 2011

I just want it on record that I intend to actu­ally bring my STM library into a feature-complete, robust and well-documented state, and then release it to the world. (more…)

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…)

Singletons: Solving problems you didn’t know you never had since 1995

Friday, March 12th, 2010

Funny how some sub­jects seem to attract catchy titles like flies. A lot of very clever peo­ple have writ­ten vol­umes about “The Sim­ple­ton Pat­tern”, and “Sin­gle­toni­tis” (bah, dead link, let’s use this instead then).

Many peo­ple are in love with the Sin­gle­ton pat­tern. Oth­ers — a small minor­ity, I sus­pect — con­sider it a mis­take, an anti-pattern, or some­thing that was only ever included in the Design Pat­terns book as a life­line to pro­ce­dural pro­gram­mers who couldn’t really fig­ure out this OOP thing. (more…)

The meaning of RAII — or why you never need to worry about resource management again

Saturday, January 2nd, 2010

I tried really hard to come up with some witty title or pun to weave into the title of this post. I couldn’t. RAII is just a ter­ri­ble name, and it isn’t really clever or funny. Unfor­tu­nately, it is also the sin­gle most impor­tant key to C++. It is not just an idiom but a fun­da­men­tal phi­los­o­phy used to solve almost any prob­lem in the lan­guage. So we can’t really avoid it.

If I had to pin­point one thing that marked the dif­fer­ence between a skilled and an unskilled C++ pro­gram­mer, it would be “do they under­stand RAII”. Many peo­ple don’t, hence this post. (more…)