Thursday, September 18, 2003

Flexing the C++ muscles again

I'm sick, and hence feeling too crappy to do real work. Also, I have some rather unpleasant emotional stuff going on right now. As a result, I've been escaping from reality by playing around with KDE programming again. Since the Python bindings for KDE aren't quite ready for prime time (they don't ship with all distributions, and every time I've tried to build them myself, I've run into a compilation error), this means writing in C++. So, I've spent the past two or three days hacking around with C++ code. I'm fairly fluent in the language, but I haven't done this in a while; these days I mostly hack in MultiJava.

My conclusion: I can program anything at least twice as rapidly in (Multi)Java as I can in C++.

KDE and Qt are about as nice a C++ framework as you could ever hope for, and KDevelop is a top-notch IDE. Yet all these nice tools cannot hide the massive anti-productivity orientation of the C++ language. C++ was not designed to make life easy for programmers; it was designed to enable programmers to invest lots of labor in getting the machine to run fast. C++'s most prominent problems are, of course, the lack of garbage collection (and a corresponding lack of type safety). Manual memory management may be appropriate in some domains, but it makes life hell for high-level application programmers. Forget dangling pointers, memory leaks, and segfaults; these are all heinous, to be sure, but the mere fact that you must spend mental energy thinking about the consequences of allocating things in different storage classes is enough to slow you down. Programming in C++ after you've used a garbage collected language is like running through a waist-deep pit of molasses. Without STL auto_ptr, C++ would be totally unbearable, and I'd probably just quit.

Oh, in case you're curious what the program is (pffft, as if the end product of programming ever mattered), it's yet another RSS reader. Yes, it's obviously a vanity project, given that there's a billion of them out there (including one that comes bundled with KDE), and that an entire RSS framework will be shipping in the next stable version of KDE. Like I said, I'm doing it for fun and escapism, not utility.

(If you noticed a contradiction between my bitching about C++ and that last sentence, then you have yet to grasp the fundamental masochism inherent in the programmer's psyche.)

No comments:

Post a Comment