Circular path with webring links Hotline Webring < Previous Next >

Nuthole

Burning like a monkey

Nuthole Slumber

Holy smokes, it’s been almost a month since I last posted! Well, hey, I’ve been busy, traveling, sick, etc. And I missed the bus. And my dog ate my homework.

Fukt

Today’s funny Swedish word is fukt. This means “moisture”.

Musings on an Interview With Alex Stepanov

I stumbled across this interesting interview with one of the creators of the STL for C++. Now, I haven’t used STL extensively, in fact mostly I’ve just seen it as a headache when porting other people’s software onto barely-supported platforms. And I am no big fan of C++ in general. But, there is some interesting stuff here.


Stepanov seems fairly skeptical of OO, and is mainly a proponent of C++. He created the STL as a tool for doing what he calls Generic Programming; As an example, he offers the example of implementing a simple max function in C++ using Generic Programming, and claims this can’t be done in Java:


My approach works, theirs does not work. Try to implement
a simple thing in the object oriented way, say, max. I do not
know how it can be done. Using generic programming I can write:

<tt>template &lt;class StrictWeakOrdered&gt;
inline StrictWeakOrdered&amp; max(StrictWeakOrdered&amp; x,
StrictWeakOrdered&amp; y) {
return x &lt; y ? y : x;
}

and
template &lt;class StrictWeakOrdered&gt;
inline const StrictWeakOrdered&amp; max(const StrictWeakOrdered&amp; x,
const StrictWeakOrdered&amp; y) {
return x &lt; y ? y : x;
}</tt>

(you do need both & and const &). And then I define what strict
weak ordered means. Try doing it in Java. You can’t write a generic max()
in Java that takes two arguments of some type and has a return value of
that same type. Inheritance and interfaces don’t help.

This is the sort of thing that I’ve always disliked about Java. Interestingly enough, this is pretty easily implemented in Objective-C. I also love his answer to the question, “What do you think of Java?”:

I spent several months programming in Java. Contrary to its authors prediction, it did not grow on me. I did not find any new insights – for the first time in my life programming in a new language did not bring me new insights. It keeps all the stuff that I never use in C++ – inheritance, virtuals – OO gook – and removes the stuff that I find useful. It might be successful – after all, MS DOS was – and it might be a profitable thing for all your readers to learn Java, but it has no intellectual value whatsoever. Look at their implementation of hash tables. Look at the sorting routines that come with their “cool” sorting applet. Try to use AWT. The best way to judge a language is to look at the code written by its proponents. “Radix enim omnium malorum est cupiditas” – and Java is clearly an example of a money oriented programming (MOP). As the chief proponent of Java at SGI told me: “Alex, you have to go where the money is.” But I do not particularly want to go where the money is – it usually does not smell nice there.

He also has some choice words about OO in general:


STL is not object oriented. I think that object orientedness is almost as much of a hoax as Artificial Intelligence. I have yet to see an interesting piece of code that comes from these OO people. In a sense, I am unfair to AI: I learned a lot of stuff from the MIT AI Lab crowd, they have done some really fundamental work: Bill Gosper’s Hakmem is one of the best things for a programmer to read. AI might not have had a serious foundation, but it produced Gosper and Stallman (Emacs), Moses (Macsyma) and Sussman (Scheme, together with Guy Steele). I find OOP technically unsound. It attempts to decompose the world in terms of interfaces that vary on a single type. To deal with the real problems you need multisorted algebras – families of interfaces that span multiple types. I find OOP philosophically unsound. It claims that everything is an object. Even if it is true it is not very interesting – saying that everything is an object is saying nothing at all. I find OOP methodologically wrong. It starts with classes. It is as if mathematicians 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 programming: you have to start with interesting algorithms. Only when you understand them well, can you come up with an interface that will let them work.

The thing that strikes me reading this is that in spite of Stepanov’s hostility toward OO, I think that his concepts are really orthogonal to OO concepts, and that perhaps these ideas could be combined. In fact, I think that the problems he has with OO are based on a mixture of misunderstanding its uses, and exposure to inadequate OO languages. Let’s take those one at a time:


I find OOP technically unsound. It attempts to decompose the world in terms of interfaces that vary on a single type. To deal with the real problems you need multisorted algebras – families of interfaces that span multiple types.

Well, that’s not so hard to handle. Regular polymorphism as seen in all the various OO languages gets you part of the way; If you’re using Objective-C, the use of protocols gets you all the way! I don’t remember off the top of my head, but I believe this is handled quite well in Smalltalk and somewhat in Java as well.


I find OOP philosophically unsound. It claims that everything is an object. Even if it is true it is not very interesting – saying that everything is an object is saying nothing at all.

It seems that exposure to languages that are not “OO-complete” has blinded Stepanov to the possibilities of the technology. OK, turning data structures with associated specialized functions into objects amounts to little more than syntactic sugar. But the interesting things start to happen when language elements such as method names and implementations, chunks of code, and class definitions themselves are also represented as objects. C++ and Java offer very little in this way, compared to Smalltalk and Objective-C.


I find OOP methodologically wrong. It starts with classes. It is as if mathematicians 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 programming: you have to start with interesting algorithms. Only when you understand them well, can you come up with an interface that will let them work.

I think this demonstrates that Stepanov has never had the opportunity to be knee-deep in an OO design project. “Starting with classes” is fundamentally unlike “starting with axioms”. A different analogy could be that classes correspond to proofs, and axioms correspond to complete applications. In any case, OO technology is generally used in a top-down approach for building applications that someone might want to use, so in a sense, yes, you are defining an outcome (the “axiom” you’re shooting for) before you work on the pieces (or “proofs”). But then, OO programming isn’t mathematics, and I think it’s not very helpful to frame it that way.


I may be going out on a limb here, but I think that for most OO programmers, the algorithms we were taught in school have little use in real-world applications. Certainly there are specialized algorithms for all kinds of specific uses (in finance, graphics, encryption, compression, etc), but IMHO most OO technology these days is used for moving and reorganizing data, and presenting it to the user. When you do need to massage data with any advanced algorithm, you’re generally dealing with data that is fairly homogenous (as far as type is concerned) and often packed into a structure you’ve designed specifically to optimize the algorithm in question; So what’s the point of genericizing algorithms?

The Evil of iTunes

OK, I don’t really think iTunes is evil. In fact, I think it’s a pretty darn great application for its original purpose: Organizing and playing mp3 files.

What this site points out however is that the iTunes Music Store, Apple’s marvelously successful online music store, unfortunately does little or nothing to improve the situation of the artists who are screwed every which way by the giant record labels (a situation described surprisingly well years ago by Courtney Love).

There It Is

I finished reading Dude, Where’s My Country a couple of days ago. It’s a very quick read, and pretty much follows the mold of Michael Moore’s other books
, but there’s some interesting new content in there, including:


  • The concept of Dead Peasants Insurance. This was a new one to me, and if you haven’t heard of this before, prepare to be disgusted: Large corporations including Disney, Dow Chemical, and Walmart routinely purchase life insurance insurance policies for their employees – wherein the company is the beneficiary! So if you work for one of these companies and have no life insurance of your own, and you have the misfortune of dying, your widow and children will be left penniless while your erstwhile employer rakes in hundreds of thousands of dollars! I understand that this kind of thing is legal (so far), but man, that is sleazy.

  • Moore claims that numerous polls show that Americans are, on average, more progressive on most issues than commonly believed. My standpoint is to initially assume that he’s accurately citing poll data (based on the principal of "innocent until proven guilty"), so I’m not going to bother looking up this poll data. However, I’m really curious about whether people I know (family, friends, etc) might not also actually be more “leftist” than they consider themselves to be! More on this later.

The Political Compass

I’ve been wondering about Michael Moore’s assertion that Americans tend to be more progressive than is commonly acknowledged. I figured it could be instructive to find some online tests, the kind of thing where you are asked a bunch of questions and then are shown where on the political spectrum you actually lie.

Here are some of the tests I found:


  • Where do you stand on the liberal-conservative spectrum: A quick test that answers the stated question

  • The Political Quiz Show: This test is nearly a decade old, but the questions on it are still pretty useful in today’s political context.

  • World’s Smallest Political Quiz: This very short test test seems to be hosted by a libertarian organization. Perhaps its questions and results are skewed to move everyone that direction, who knows?

  • Political Compass: This seems to be the most well-thought-out of the bunch. Rather than smashing everyone onto a one-dimensional left/right line, your answers place you on a square grid, where left and right correspond to the economic ideals of the left and right (controlled economy vs free enterprise), and up and down correspond to authoritarian vs libertartian social policies. Using this notation, George W. Bush appears in the upper right, Saddam Hussein in the upper left, with Nelson Mandela and the Dalai Lama keeping me company in the lower left.

Take some tests, you may be surprised at the results! And feel free to post your results in the comments here if you like. All these tests easily labeled me as the wacko commie liberal I am, so no surprises there.

Call Me “Crusty”

After nearly a year of visiting my doctor to try to find out what mysterious condition was causing bizarre patches of flaky skin on choice locations throughout my body, I was able to finally visit a dermatologist who looked at me for a few seconds and said, "No question, you’ve got psoriasis." Bleah. Well, at least I now have a diagnosis and a treatment plan; Prior to this, my regular doctor was just making it up as she went along, prescribing a random array of creams and ointments to see if any of them did anything.


Anyway, if you notice my hair is all flaky and it looks like there’s been an isolated snowstorm on my shoulders, now you know it’s not just run-of-the-mill dandruff or bad grooming (although that can’t ever be ruled out either), I’ve actually got a diagnosed medical condition, bub. I just hope I can get it under control before I drown in a sea of skin flakes.

Nuthole Evolution

Thanks to the plethora of plugins available on the blosxom website, I’ve added more new features to this site. The most interesting is the ability for you to add comments! Now anyone and everyone can comment on the stories posted here. Feel free to let me know what you think!