[ Content | Sidebar ]

more iPod comments

March 1st, 2005

A few random iPod-inspired thoughts:

  • The first time I imported a CD with iTunes, it reported doing it at a rate of about 5x. But the next time I imported a CD, it reported a rate of under 2x, and stayed there. And it was a real problem: it took all evening just to import a handful of CDs. At first, I cursed Windows and iTunes, but the truth is that I’d been thinking browsing on Linux was sluggish ever since I upgraded to Fedora Core 2. I’d blamed that on either the OS upgrade or on the browser upgrade, but now I had concrete evidence that the problem was more widespread than that. After a bit of thinking about possible causes, I went into the bios and told it never to adjust the CPU’s speed unless I was running on batteries; the problem was solved. (There must be something buggy going on with speedstep, though – the fans don’t come on all that often, even when I’m running at full speed all the time, so why was it so persistently slow?) In retrospect, what probably happened was that I upgraded the bios at the time I upgraded the OS (because early bios versions on this computer had a bug that caused time problems), and my old bios settings must have been lost. So hurray for iTunes – without that speed rating, I’m not sure if I ever would have gotten around to looking at the bios, and my web browsing (and blogging!) would still be horribly slow.
  • The iPod has this feature where it remembers what songs I’ve listened to, and how often. It can use this to do things like give you a random playlist with your favorites more heavily weighted; nice idea. The thing is, though, it seems to periodically forget that I’ve listened to music: when I sync it with my computer, it forgets stuff that I listened to since my last sync but more than a few days ago. Very strange – you’d think this sort of information would be stored on the hard drive and never lost.
  • It also frequently forgets what I’m in the middle of listening to, if I’ve stopped it in the middle of an album. A bit of experimentation suggests that maybe it remembers better if I pause it and let it go to sleep by itself, but it forgets if I hold down the pause button to put it to sleep more forcefully. But why should it forget in either situation? My car’s CD player can remember where I was last listening to a CD, and it doesn’t have a hard drive to store that information. So why can’t the iPod do just as good a job?
  • I still have yet to stump the CD database that iTunes uses.
  • I’m really glad I got the iPod. Jogging is a lot more fun, and I really do like listening to music. I’m finally buying CD’s again: I accumulated hundreds when I was an undergrad, but had bought almost none in the intervening decade, and that’s a shame.

tokyo godfathers; movies

February 26th, 2005

We just watched Tokyo Godfathers; very good. About three homeless people who find an abandoned baby, and try to track down its mother and learn why she abandoned it; good characters, good plot, good visuals, pleasantly bizarre.

Hmm: that wasn’t much of a discussion of the movie, was it? The problem is, I’m really not very good at talking about movies. I could give a plot description, but I’m not sure what the point of doing so would be. I’d rather have something a bit more insightful to say, or at least something a bit more analytical. I don’t claim to be god’s gift to video game criticism, but at least I can blather along about the things for paragraphs; not so with movies. I’ve seen a reasonable number of movies (perhaps not so many in recent years, but then again the movies I’ve seen I’ve seen over and over again, which should mean something); I guess the point is that I spend more time thinking about the design of video games as I play them. And, for that matter, I spend lots of time reading video game web sites, so I’m much more exposed to video game criticism than movie criticism. (What are good movie web sites? Also, what are good music web sites?) So I should think more as I watch movies, and not be afraid to write about them, I guess; with practice, I’ll have more to say.

Fortunately, I should have more movie-watching time soon. For years, we’d basically only been able to watch movies that Miranda could watch. But once she started school, we moved her bed time up (or really, gave her a bed time different from ours at all), giving us time that we could watch TV by ourselves. Unfortunately, at about the same time, we bought our disco duro, and we kind of overdosed on Iron Chef and Good Eats. But recently we’ve moved her bed time still earlier, and a significant portion of the Good Eats episodes are ones we’ve seen recently, so we’re plowing through our backlog of recordings.

(The thing I miss most about Boston: the Brattle. Also, why, in my first paragraph, did I not mention that it was either Japanese or animated? I guess I didn’t want to overemphasize either of those facts, given the brevity of the paragraph: I wasn’t up for a comparison of it with anime, or for that matter non-Japanese animation (The Triplets of Belleville; I guess I didn’t talk about that when I first watched it? Maybe I wasn’t blogging yet).)

refactoring twists and turns

February 25th, 2005

(Warning: really boring post follows. This is what’s been on my mind today, but Jordan will probably wish that I would go back to talking about Java.)

There’s this big monster class that I’ve been dealing with at work almost ever since I got there. About a month or two into my job, I had to try to write unit tests for it, and failed miserably. (Because, after all, it’s a big monster class, exactly the sort of class for which the notion of “unit test” is ridiculous.) I did a bit of refactoring at the time, but for various reasons (I wasn’t very good at refactoring, and I wasn’t in charge of the code), it thoroughly repulsed my efforts at civilizing it. I did get a bee in my bonnet that State might be a useful design pattern to use, though.

A year later, I’m now in charge of the code, and it’s been causing me a fair amount of pain (in the form of seg faults, and sleepless nights about the thought of having to add new functionality, as I’ll have to do over the next few months). It actually was a pair of messy classes; I spent January matching wits with the first one. It certainly fought back – near the beginning, for example, I thought I had a nice bit that made sense conceptually to extract as a separate class, and I found a couple of method that looked like a perfect entry point into that section of code. But after spending a few days trying to get that to work, it just got worse and worse: those two functions called functions that called functions that referred to data that I thought was outside of the class in question, and it was really hard to tangle the code apart. So I had to throw away those days of work, and try again. (The second time was the charm, though.) And, actually, while that code is hugely better now than it was, I still wasn’t able to properly tame and test some of the core algorithms…

So this month I’ve been dealing with the other one of these messy classes. At the start, finding refactorings to do was like shooting fish in a barrel – anybody who can’t find methods to extract from 100-line functions isn’t looking very hard. (Let’s start by having every method fit on a single screen…) So far, I’ve extracted three nice little classes from it: they’re quite coherent, much easier to understand, much better tested, and I of course found several bugs in the process. One of the extracted classes, in particular, was an absolute joy to refactor: I knew that I had extracted a coherent chunk of data and methods, but I was having the hardest time figuring out what it was actually doing. This made adding unit tests a surprising pain; I ended up stopping thinking about what the class should do, and just mechanically writing tests that pinned down the class’s behavior, without worrying about how to interpret that behavior. (Well, almost pinned it down – fortunately, I kept around an end-to-end test as a backup, which saved me at one point in my later refactoring.) And when I got to the refactoring proper, I decided to do it strictly by the book, making really small, mindless little changes, and consciously trying to avoid look to far ahead, never making a jump when I could find baby steps that would get me there instead. And it was beautiful: the badness just melted away, the code almost transformed itself, and at the end of the day, everything made sense, and was clear to anybody reading it. I’m completely sold: tiny refactorings for me from now on.

But a week or so ago, I ran out of obvious classes to extract, so I decided to do the State extraction that I’d had on my brain for the last year and a half. I did it (by tiny steps), but while I liked the code more that way, I was pretty sure that most of my coworkers, when reading the code, would find it less clear. So I didn’t check it in: I wanted to spend more time moving functionality into the new State objects, and hoping that other refactorings would become obvious to me as I did so, so that by the time I checked it in the code would be clearly improved.

A couple of days later (I started a week ago, but most of this past week I was at a conference) I’ve got a lot more functionality moved into the State objects, but it’s still not a clear improvement. As I hoped, though, I am starting to see other refactorings that make sense, that really do improve the code.

The thing is, though, these other refactorings don’t depend in any way on my State extraction: in fact, if I hadn’t had this State bee in my bonnet, I would probably have seen them a week ago. Look at all these methods that take 6 arguments – maybe I could get rid of some of them? Look at these three member variables whose names all start with “uncopied”, with a big comment before them explaining how they’re used together – maybe I could extract those all into a class? And, as I do the extraction, I find what must be a bug in the code, but I’m so deep into refactoring upon refactoring that I have a hard time stepping back, figuring out what’s going on, and writing a test to expose the bug.

So I’ll be throwing away the last three days of programming: starting over, doing the obvious refactorings that I came across today, and probably creating a big parser wrapper class whose State I will only extract after I’ve gotten it into a coherent whole. Sigh.

Which, actually, isn’t so bad. At least I can say that I’ve learned something about programming over the last couple of years: I’ve learned that I should be nervous if I want to go for three days without checking in my code, and that it’s better to throw away that work and start over from scratch than keep on forging into the muck. And I’m sure that I’ll hit the ground running next week: having struggled with the code today, I’ll be able to do the first few refactorings in a flash, and it will only take me a day and a half to recreate the work that I’ve done in the last three days. (But there will probably be another week of work inserted into the middle of that day and a half of recap, as I do more refactoring to get it into shape before doing the State extraction.)

The next post will be a non-programming one, I promise…

a few last Java comments

February 24th, 2005

A few random thoughts about Java (to get out of the way so I can stop boring Jordan):

  • I’m not thrilled with the whole checked/unchecked exception thing. Checked exceptions, to be honest, seem like kind of a pain to me: they make your code more verbose, but I don’t yet have reason to believe that they catch much in the way of problems. I suppose it makes more sense in Java than in C++: in C++, destructors make it easier to handle exceptions safely, and templates would interact really badly with checked exceptions, so maybe as I gain more experience with exceptions in Java, I’ll come to appreciate them more. Or maybe not. I’m kind of tempted to make all the exceptions I define be unchecked, but it’s probably better to stick with more idiomatic techniques, even if they are a bit of a pain.
  • I like the HTML documentation that comes along with the language: it’s great to be able to just look up all the standards classes and their methods whenever I have a question.
  • I’m not convinced that package visibility is a great idea, though I will reluctantly accept that some form of encapsulation breaking is necessary at times, and package visibility is probably about as good an idea as friendship. What is definitely screwed up, though, is making it the default, instead of requiring people to specify it explicitly with a keyword. Also, protected shouldn’t imply package: the two concepts are simply orthogonal.

Anyways, that’s the end of my Java notes; I should get back to actually programming in Java, so I’ll have more things to talk about. I’m also tempted to start using a modern IDE: I’ve been doing a lot of refactoring recently at work, and I feel uncultured never having used an automated refactoring tool. So maybe I’ll give Eclipse a try. The main thing I’m worried about is that an IDE might make me use the mouse more than my hands like; I think Eclipse has pretty good keyboard shortcuts, though.

I was at a Sun conference this week, so now I feel guilty about wanting to use Eclipse instead of NetBeans. But it really did sound like NetBeans’ refactoring support is pretty meager – in particular, it doesn’t even support Extract Method – so Eclipse it probably is. Interesting conference; I spent a lot of time talking and learning about agile methods (well, about extreme programming, really). I should post on that some time.

old-time religion

February 23rd, 2005

There was a good article in The Nation recently about religion and our founding fathers. Normally, I don’t pay much attention to that sort of thing – I’m aware that present-day religious fanatics would like to paint our country as inherently steeped in religion, and that many of the founding fathers could be better described as deists – but I see that I underestimated our founding fathers. In fact, as the aformentioned article tells us, the Treaty of Tripoli, signed in 1797, says

As the Government of the United States…is not in any sense founded on the Christian religion–as it has in itself no character of enmity against the laws, religion, or tranquillity of Musselmen–and as the said States never have entered into any war or act of hostility against any Mehomitan nation, it is declared by the parties that no pretext arising from religious opinions shall ever produce an interruption of the harmony existing between the two countries.

And this was no minority opinion, either: the Senate approved the treaty unanimously, only the third time in the Senate’s history that it did so. (Out of 339 total votes at the time.) How things change.

I actually recently realized that Buddhism has somehow become the only religion that my brain is willing to treat seriously. (Unless you count Taoism as a religion; I certainly have enough translations of the Tao Te Ching around the house…) I’m not sure how long that has been the case, but I was reading a (quite good) book of medieval Japanese stories whose introduction spent some amount of time explaining Buddhism in Japan, and it all seemed perfectly natural to me. Not that I’m about to become a Buddhist myself (though I would like to spend some time studying meditation at a Zen center), but my brain thinks it quite normal to read about Buddhists, whereas that part of my brain is incapable of treating people who believe in, say, monotheistic religions in the same way. Odd…

bruno latour

February 20th, 2005

I’ve been a big fan of Bruno Latour for a long time now. He started off working in sociology of science, with some very insightful observations of scientists in action, of how science is actually produced and how scientific facts become accepted. Which is not quite the way it is presented by many scientists (or epistemologists); a decade ago, Latour made a foray into philosophy with his book We Have Never Been Modern, to talk about this disconnect. For me, that book was both fascinating and frustrating: Latour did a good job at pointing out some of the absurdities that you see in a certain form of mysticism of Science that was depressingly prevalent around the Sokal affair, and he clearly had some good ideas about a better way to approach epistemology, but those ideas hadn’t yet gelled into a coherent picture.

With his latest book, Politics of Nature, however, he’s finally put it all together. His basic complaint is that mythologists of Science buy into a version of the allegory of the Cave, with an eternal world (Nature, in the case of Science) out there that humans can’t perceive directly. But scientists are supposed to have a unique ability to transcend the social world, producing eternal truths about Nature that nobody is permitted to question, that have no analogue anywhere in the social world. And there’s no clear explanation how, if Nature and the world of the Cave (the social world) are so fundamentally different, how scientists manage to have a unique insight into Nature, giving them a special access to eternal truths that the rest of us can’t manage.

Latour’s explanation is that the (quite valuable!) work that actual scientists do is rather more prosaic and complicated than this mythical picture. Scientists don’t go from direct perception of nature to direct perception of unquestionable truths (and, to be sure, nobody claims that they do this: some form of scientific method is always presented as an intermediate step). Latour proposes analyzing this process through the following four steps:

  1. The requirement of perplexity. An investigation must consider the evidence that appears, no matter how surprising or unpleasant it might seem.
  2. The requirement of consultation. Propositions can’t be considered in isolation: they have to be examined by an appropriately constituted jury.
  3. The requirement of hierarchy. You can’t just accept a proposition as true by itself: it has to fit together with other propositions that you wish to consider true.
  4. The requirement of institution. Once a proposition has been appropriately placed in a hierarchy, it should be accepted, rather than constantly challenged.

The requirements of perplexity and institution are most similar to the naive version of nature and scientific laws: the requirement of perplexity is where we see nature making its presence known (if you jump out of a third-story window, you will fall down, whether you like it or not), and the requirement of institution is where scientific laws get accepted as truth. The journey from the first requirement to the fourth, however, is a quite interesting one.

The second requirement, in particular, is more subtle than it might seem. Latour’s juries aren’t made entirely (or even largely) out of humans: this isn’t some sort of simple peer review, where scientists read each other’s papers and decide whether or not they agree with the results. Instead, members of the jury can be nonhumans (and in particular can be propositions, a term which Latour uses in a quite general sense): so some of the most important members of the jury that is consulted with respect to a candidate proposition consist of measurements that are made that support (or don’t!) the proposition in question. In fact, arguably the greatest strength of science, and the reasons why scientists are much better at coming up with durable propositions than the rest of us, is the remarkable ability that scientists have to assemble a huge jury of nonhumans to pass judgment on a candidate proposition.

Another point of Latour’s is that this process isn’t a one-time thing: when one round of perplexity/consultation/hierarchy/institution has concluded, it opens itself to another round of the same process. So, for example, when a scientific theory becomes accepted, it might cause scientists to be perplexed by facts that they hadn’t noticed before. And the newly instituted facts might enable scientists to build new measuring devices, increasing the size of the juries that they can bring to bear in later consultations. So hierarchies of scientific theories grow and grow through repetitions of this cycle. Also, while propositions that are instituted at the end of one cycle usually remain instituted at the end of the next cycle, that’s not always the case: they may end up being refined, having their scope limited, or even being outright rejected at the end of subsequent iterations.

There’s nothing surprising about this analysis, of course; it’s a reasonably level-headed description of how scientists work, with a somewhat idiosyncratic choice of language and focus. (He uses many words in a somewhat specialized fashion; fortunately, he flags these words with asterisks in the text, and provides a glossary at the back, so it’s usually clear enough what he means.) Its real strength, however, is that there’s nothing about this four-stage analysis that is at all specific to science. In fact, he shows how various professions (politicians, economists, moralists, etc.) can fit their work quite naturally into this framework. So it gets us nicely past any sort of mysticism of Nature and Science: if you want to focus on facts that manage to perplex in a certain especially potent fashion, or on facts that are instituted in a particularly durable way, you’re welcome to do so (and it may even be useful to do so), but there’s no particular benefit in turning that into a transcendent distinction.

I’ve actually started looking at all sorts of aspects of my life through this lens. For example, the problems that I have with the school closure process can largely be traced to problems with the board and administration’s perplexity and consultation: they’re picking and choosing between facts, ignoring the ones they don’t like instead of being properly perplexed by them, and they’re not constituting appropriate juries (both human and otherwise) to review their propositions. Another example is in software development: the software development strategies that I prefer these days can be viewed as focusing on increasing the size of various relevant juries (providing automated tests to verify that your code does what it’s supposed to do, bringing in more voices to help you decide which features to add to your software, which not to add, and how best to implement them) and on increasing the rate at which the entire process cycles through, allowing you to institute propositions (i.e. release software) much more quickly, building up a large hierarchy of propositions (working, stable software fulfilling a well-chosen set of feature requests, doing so in a maintainable and extensible fashion).

school closure: not done yet

February 18th, 2005

I was sure that the school board was going to make a final vote on the school closure issue last Wednesday. The school board, however, has managed to surprise me at every other meeting on the issue; I don’t know why I expected anything different this time.

They did vote to close a school. Which, I think, was a mistake: it looks like there’s enough money in the budget to keep a school open next year, and I think there are good reasons to do so. They did not, however, vote on which school to close. They had set their sights on Slater, my daughter’s school; last night, however, they decided to explore the idea of exploring another school, Castro (which I, not entirely coincidentally, used to live half a block away from). It’s a school with a huge proportion of English-language learners, in a neighborhood where families frequently move in and move out (as we did); unsurprisingly, the school dosen’t have as high test scores as others in Mountain View, and the board has been trying for years to figure out how best to help the students there. And it looks like some board members are ready to throw up their hands and send the Castro neighborhood kids to schools with more native English speakers.

So closing Castro is now a possibility, but no decision has been made. To their credit, the board is behaving well with regards to this new twist: they’re putting the final decision off for a month to give the Castro community time to respond, and they’re holding a couple of community meetings at Castro. So that’s all to the good. I’m mad at them for closing any school at all, though. And if they can hold community meetings at Castro, why can’t they hold community meetings at Slater as well? (The demographics of the neighborhoods aren’t all that different, after all.) I honestly don’t know which school would be less harmful to close: I’d prefer that they close Castro instead of Slater, but obviously I’m biased. And I don’t really know what’s going on with this plan: maybe it’s (intentionally or not) more of a ploy to act like they were listening to the issues that Slater parents raised, but handled in such a way as to guarantee a community outcry in support of Castro, causing them to end up closing Slater like they wanted. And, at this point, the last thing I’m going to do is try to predict what the board will do a month from now: I’m completely incapable of predicting what they’ll do a week from now, let alone a month from now.

There are some other twists and turns, the most bizarre of which is that the “close Castro” proposal was actually put forward by some parents in the Spanish/English Dual Immersion program, which is currently located at Castro! Which might sound like a good argument for closing Castro – if current families there want to close it, then why keep it open? – except that I don’t think that the families proposing the plan actually live in the Castro neighborhood, so they wouldn’t be losing their neighborhood school. (Though I don’t live in the Slater neighborhood, and I, like all other families I’ve heard of with kids attending Slater, certainly don’t want Slater to close.)

My apologies if this drama is a bit boring to those of you who don’t live around here. (As opposed to my other blog entries on other topics, which are of course fascinating to all!) You’ll have to bear with me for another month or so, I’m afraid…

mary poppins

February 14th, 2005

Liesl’s dad gave Miranda a copy of Mary Poppins for Christmas. And it’s great! I was starting to suspect that I might be a Julie Andrews fan, but now I’m sure of it (and should really go out and watch other movies of hers). I had no idea how good Dick van Dyke was, though, and for that matter I’d never considered the possibility that he might have been young once.

The other big surprise is the songs. I was, of course, aware of some of them: “A Spoonful of Sugar,” “Supercalifragilisticexpialidocious”, “Let’s Go Fly a Kite”, “Chim Chim Cher-ee”. (I’m honestly not sure if I would have identified the source of the last two, though.) But they’re singing all the time in the movie: looking through the list of scenes, there are 13 songs in the movie! It’s a long movie for a kid’s movie, but that’s still one every 10 minutes or so. And they songs are all at least pleasant; there’s a reason why I was aware of the ones I mentioned above, but the others are far from shabby, and Miranda and I quite enjoy dancing around to “Step in Time”.

And it has a good story, good politics, and I really like the way the Dick van Dyke character (and his mix of jobs) are presented. Good thing I have a daughter with a grandfather with good taste in movies!

(Incidentally, Miranda has recently been asking to watch a DVD of The Marriage of Figaro. I really do think she could have a good career in musical theater ahead of her, if she so choses…)

metroid prime 2: echoes

February 13th, 2005

Today’s video game is Metroid Prime 2: Echoes. The first Metroid Prime game was my favorite Gamecube game, and was a real eye-opener for me. It was my introduction to the Metroid series, so I’d never seen its particular brand of exploration before. Games in the series take place in one big world; it’s divided up into different regions with various themes (hot, water, etc.), but there’s no other distinction between areas (no buildings, dungeons, etc.). And you can always go back to areas you’ve seen before, and in fact frequently do. The reason for this is the way they open up areas: you can’t go everywhere from the beginning. Instead, you periodically (usually after (mini-)boss battles) earn upgrades allowing you to move in different ways, or giving you weapons that let you destroy barriers that you couldn’t destroy before.

So every time you get an upgrade, new areas open up for you. Usually there’s one primary largish area that opens up to you, giving some direction in the game. (This was much more the case in Metroid Prime 2 than in earlier Metroid games.) But there are always lots of things that you can do in old areas, too, typically allowing you to get hidden items (ammo/health expansions) that you couldn’t get before.

There’s a lot of shooting in games in the series, but it’s handled exceptionally well. Your primary weapon has an unlimited supply of ammo, so while getting ammo expansions is important, you almost never are seriously lacking in ammo as long as you’ve done at least a cursory job of finding the expansions. (The one exception is boss battles: these are where having a lot of ammo can really help.) And ammo refills are plentiful. Similarly, your health gets refilled every time you save, and health refills are plentiful, so outside of boss battles, health isn’t a serious issue. Ammo and health aren’t irrelevant by any means: typically, the enemies in the most-recently-opened area are tough enough to keep you on your toes, preventing you from spending all your time looking around. But if you return to an area after initially opening it up, you’ve usually progressed to a point where the enemies aren’t much of a challenge, allowing you to spend your time exploring and figuring out what new things you can do that you couldn’t do the last time you were in the area. (For that matter, if you’re just travelling through an area that you’ve been to before in order to get somewhere, you can usually ignore the enemies, because they won’t do enough damage to really matter.)

That’s the way all the Metroid games work; I’ve now played the 2D ones on the GBA (though I’ve still yet to play the apparently-excellent Super Metroid), and the 3D ones on the Gamecube, and they all have the same excellent balance of exploration and fighting. In particular, the series made the transition to 3D extremely well, and I like some of the features that they’ve added (like the scan visor, which allows you to get information about your environment and bring more of a story into the game). The boss fights are, in general, quite well designed, challenging but not tedious. (Most of the time, even if you die, you can figure out more about the enemy’s vulnerabilities, letting you do better the next time.)

So: what about the latest game in the series? It’s great, it really is. I thoroughly enjoyed playing it, I found myself happily going back through areas trying to find all the secrets, I liked almost all of the boss battles (and rarely looked up help for them online). The one exception to the latter is the final boss: it really annoys me when games not only give a final boss that’s quite difficult (which, by itself, can be reasonable enough: you get better at fighting bosses as the game goes on), but then follow it up with a second final boss without giving you a chance to save in between, so you have to spend twenty minutes beating the first boss again each time you need another crack at the second boss. As a result, I haven’t actually finished the game: I’m sure I could, but I also suspect it would take me maybe three hours, much of which would be rehashing the same battles over and over again, and frankly I have much better uses of my time. (Like, say, playing the latest GBA Zelda game or playing Jak 3.)

On the other hand, it didn’t bring anything new to the series. This particular game’s “feature” is that there’s a dark world and the light world (and no surprises as to which one the bad guys are from), so you get to travel through (most of) the map in two versions. It’s not a particularly original idea (we saw this in Zelda a decade ago), and the execution is pretty unexceptional. They wanted to make the dark world bad, so it hurts your health to be there, except that then it would be impossible to explore in the dark world, so they gave you light bubbles in the dark world that restore your health, with the end result that the dark world is actually easier on the health than the light world! (So, when fighting most dark world bosses, your first tack is to figure out how to avoid enough damage so that the light bubbles balance out the damage; once you’ve done that, you know you can fight the boss for as long as it takes for you to figure out how to beat it.)

All in all, I feel about this game the same way as I felt about Banjo-Kazooie: it’s a great game that does everything its excellent genre predecessor did well (where the genre predecessor in the latter case was Super Mario 64). But if I see another game like this, I will lose patience fairly quickly (as happened with Banjo Tooie). Unfortunately, in the case of the Metroid series, I don’t have any constructive criticism here: I can’t quite figure out a way that the series should progress that wouldn’t turn it into something significantly different. We can imagine, say, taking its putative “bounty hunter” theme and turning it into a multi-planet adventure game, or something, but that would be a completely different game with the same name. I guess I can imagine setting Metroid in a city instead of a cave: that could let them preserve the same “go anywhere you’ve been while opening up more and more of the game” feel, while opening up more room for interaction. And who knows: the fine people at Nintendo have successfully reinvented their various series often enough that they may well come up with a surprising, amazingly successful way to invigorate this one. On the other hand, recently they’ve been rehashing their series more often than not; I can’t say that I’m too hopeful for the future of the series. We’ll see; it’s got a solid enough foundation that I’ll put up with a few more rehashes, I suppose. And those of you who have never played any games in the series should run to your local video game emporium: it’s a great series and, unlike most other great series, it hasn’t spawned a flock of other games where you would have seen the same ideas.

Update: when skimming an earlier post, I see that I forgot to mention Metroid Prime 2‘s amazingly bad menu system. Menus are presented as a 3D shape with a dot in the center with lines coming out of it, with labeled balls attached to the lines: the ball that is closest to the “front” is the currently selected item. The thing is, when I first saw this, my brain didn’t have enough information to parse it as a 3D object: it just saw it as a collection of longer and shorter lines, whose length and position would change in a fairly random fashion in response to joystick movements. I got used to it after a little while, but game designers should know better: this menu has absolutely no benefit over a traditional 2D system, it’s not “cool”, it’s just gratuitously confusing to newcomers.

school closure, continued

February 11th, 2005

The school closure saga continues, and it gets stranger every week. Two weeks ago, I liked the school board but was mad at the superintendent. Last week, I was mad at everybody: the school board was just letting the superindentent and her staff talk, without (largely) seriously questioning any aspect of the report and its proposals. (I’m biased, but trust me, there’s stuff in there worth questioning.)

But yesterday was just plain bizarre. First, it turns out that the school board will almost certainly have a few hundred thousand dollars available each year than they thought; at this point, I can see no financial reason for them to close a school next year, and there may not be any financial reason for them to close a school after that, either. At this point, it suddenly turns out that we’re supposed to believe that closing a school, instead of a necessary evil, is actively good! That Slater (the school my daughter attends) is a disaster and the presence of PACT (the special program she’s in) is hurting the neighborhood kids (largely poorer, with lots of English-language learners), but if PACT gets moved to Castro (another school attended by poor kids who are English-language learners), then all of a sudden PACT’s presence will be a huge blessing! That the school district is completely confident that it has suddenly found exactly the right teacher training program to cure all of Castro’s (long standing) woes, despite the fact that we have no actual experience with the program, and that in fact teachers were first exposed to it in a training session two days ago! That, despite the fact that PACT is nothing other than the reification of a particular educational philosophy, it must be the case that, if we disagree with switching over to this newfound gospel, it must be because we’re bigots! Oy.

Anyways, I’m more favorably inclined towards the Superintendent than I had been: I still think she’s pushing a harmful program, but she is doing a fair job of evaluating some of the possible evidence that speaks against the necessity of school closure. I’m quite impressed by two of the trustees (Rosemary Roquero and Fran Kruss, for you local readers), I get angrier every time one of the trustees says anything (Ellen Wheeler), and am disappointed but not giving up hope in the other two (Gloria Higgins, Fiona Walter). At least this soap opera should be over, for better or for worse, by next Wednesday: the discussion has suddenly gotten a lot more heated and serious.

generics in Java

February 8th, 2005

One of the things I was excited to learn about in the new version of Java was how they added generics to the language. I didn’t expect it to be as powerful as C++ templates: that amount of generality, with its associated complications (e.g. having to separately compile separate instantations of the same template, or the parsing problems that arise), doesn’t seem like the Java way. So my guess was that, if a template calls a method on the parametrized type, it would require the parametrized type to inherit from a class (or interface, of course) providing that method. In particular, you wouldn’t be able to get much use out of, say, types that are nested inside the parametrized types: you wouldn’t be able to assume that, say, each type T has a nested type T::iterator.

And, it turns out, I was right! (Incidentally, they sensibly added covariant return types at the same time, to ameliorate some of the potential negative implications of this restriction.) But there’s one twist I hadn’t expected. It hadn’t been at the front of my mind that Java already had one built-in generic type, namely arrays. And what I had completely forgotten is that Java arrays aren’t type-safe! If, say, Manager is a subclass of Employee, then a Java compiler will happily let you pass an array of Managers to a function expecting an array of Employees. Which would be fine if Java had a notion of const arrays, but it doesn’t; and a (non-const) array of Managers doesn’t support the full interface of an array of Employees, because you can add an Employee to the latter, but not the former. Java’s solution is to nonetheless allow you to pass an array of Managers to a function expecting an array of Employees, but to throw an exception at run time if you try to stick a non-Manager Employee into the resulting array.

They did a similarly weird thing with generic types. Say that you have a generic type Generic that’s parametrized by a type T. (Which must inherit from some specific class: we’ll assume it’s Object.) Then you can write Generic in place of Generic<T>, and you can pass an object of any type Generic<T> to a function expecting an object of type Generic. As with arrays, an exception will be thrown if you do something too horribly un-type-safe to the object (though, I think, the details differ somewhat); but, as with arrays, it’s really the sort of thing that should be caught by a compiler in the first place.

So why was this conversion allowed? One motivation is that it would allow you to implement generics without changing the virtual machine; apparently, they decided to change the virtual machine anyways, however. (I don’t know the details here.) And it allowed them to provide generic versions of various classes/interfaces in the standard library without changing their names. And, well, I guess throwing exceptions in certain places where the compiler could catch your mistakes for you is just the Java way of doing things?

All grumbling aside, I’m glad that Java added generics. Non-type-safe collections are pretty passé, even if I wish the new collections were really type-safe instead of only sort of type-safe. The language isn’t so simple that adding generics increases its complexity very much. Part of me thinks it’s too bad that, as far as I can tell, we’re just not going to see in Java the incredible wealth of techniques that C++ templates allow. I expect people to use Java generics in some surprising ways, but I just can’t see how they’ll lead to anything as exciting as we’ve seen in C++. But I guess that’s okay: it’s hardly the only way in which Java is less exciting than C++, and it’s still a quite serviceable language.

grand theft auto: san andreas

February 6th, 2005

I’ve played through somewhere between a third and a half of Grand Theft Auto: San Andreas now. I’m not sure I’m going to finish it, largely because I don’t play it when Miranda is around, but I think I’ve seen enough of it now to say something.

It (preceded, of course, by earlier games in the series, and other games influenced by them) certainly has some important gameplay advances, ones that were new to me. Much of the development of video games, especially once 3D hardware came on the scene, has consisted of giving people larger and larger worlds to explore in, with fewer and fewer artificial barriers. The most dramatic single advance was probably Super Mario 64: before that game, platformers had people starting from the left side of a (quite artificial) world, moving to the right (getting items from boxes and squashing bad guys), until they reach their goal. But in Super Mario 64, levels were 3D areas that you could wander all over in; you had a task to accomplish instead of a location to reach; and you went back to the same level multiple times to accomplish different tasks.

Still, the game was divided up into multiple levels (connected by an overworld), the goals were pretty arbitrary, and, while the levels looked large at the time, they look pretty small a decade later. These issues are all grappled with by GTA:SA (and, presumably, other games in the series), quite successfully. There are no longer individual levels linked by an overworld: the action takes place on one map. (With the slight caveat that some missions have you entering buildings that can be only accessed during that mission.) The goals of missions, instead of being arbitrary, are (largely) designed to advance the plot. And the map is much larger than that of any other game I’ve seen; I haven’t compared the map to those of actual cities, but it wouldn’t surprise me if the number of streets and blocks in the map compared favorably with a medium-size real-world city.

This vastness requires some careful gameplay design: it’s great to have a big world to explore if you’re in the mood to do that, but if you’re in the mood to make progress in the game, the vastness can turn into tedious traversals if you’re not careful. All in all, I think the game’s designers did a good job of dealing with this issue. They broke the map up into three cities (plus some intermediate rural areas); while you can drive anywhere at any time if you want to, the missions at any one time are relatively close together, reducing travel time and encouraging you to become familiar with one specific area of the map. You usually have several different missions to chose from, so if you’re frustrated with one mission for some reason, you can do something else instead. You can buy new houses to serve as save spots in different areas of the map. (Though it can be hard, at least initially, to save enough money to do so; fortunately, most of the time it’s not really necessary, and I was able to save up enough money to buy a house when it really mattered.)

The missions themselves are extremely varied. In the first mission, you just have to get from one place to another without being killed. But soon you’re hunting people, breaking into houses (with either stealth or mayhem in mind), protecting people, delivering items, planting evidence for cops, starting gang wars, racing cars, dancing, evading cops, burning fields of marijuana, piloting radio-controlled airplanes. and who knows what else. I have a hard time thinking of a video game genre that isn’t present here – there are shooting, racing, stealth, rhythm (including one where you have to bounce your car in time to the music), strategy, and rpg elements. You ride bicycles, motorcycles, lots of different kinds of cars and trucks, a combine harvester, planes, and walk. It’s a very varied game.

As I mentioned above, it also has the distinction of being the only game I own that I won’t let Miranda watch. Some people seem to be up in arms over this aspect of the game; I tend to think that people like that are ridiculous. Why would you expect an art form to limit its productions to those that can be appreciated by 5-year-olds? Surely that would be a sign of intellectual bankruptcy? (As would, of course, a form that can’t produce works that can be appreciated by 5-year-olds.) Do these same people want me to only own movies that 5-year-olds can watch? Or only read books that 5-year-olds would like? The mind boggles.

As is obvious from the list of activities presented above, your character in the game does lots of things that would be considered horrible in real life. The game can hardly be considered as showing uncritical approval of these actions, however. One recent article I read complained that in the game, you can make progress by stealing cars and shooting policeman. I doubt that the reviewer in question (unlike Alison Bechdel) has actually played any of the game (shooting policemen, in particular, actually isn’t a major component of the game, and in most situations is more likely to hinder your progress than to help it), but in fact these actions are presented in a much more problematic fashion in GTA than in most other games. It is no exaggeration, I think, to say that looting and vigilanteism have been major themes throughout the history of video games: in the Colossal Cave adventure, you were supposed to take all the treasures you could find in the cave, with no thought of whom they might belong to. In the Zelda or Mario games, you look for items wherever you can find them: for example, in Zelda games, whenever you go into people’s houses, you break their pots hoping to find money or items, and you open their chests searching for treasures to take. When wandering through the countryside, you’re encouraged to kill everybody you meet, partly for defensive reasons, but partly just to get stuff. (Indeed, if those games were written from a different point of view, then “vigilanteism” would be far too kind a description: thuggery and amoral killing might fit the bill better.)

So, yes, in GTA, you steal a car whenever you want to get somewhere: you don’t have your own car that you actually take care of. But the very realism of the game means that you can hardly ignore the moral implications of your actions, and what would happen if everybody acted the way you were. Every time you bump into another car, your character makes a quip along the lines of how the other driver got their license, but of course you’re the one at fault, not the other driver. And in the first quarter or so of the game, when you frequently have passengers along on your trips, those passengers make fun of what a bad driver you are.

Similarly, a reviewer who hadn’t actually played the games could pretend that, for example, they valorize gang violence. And, in fact, in the first portion of the game, you do spend time building up your gang, and getting a fair amount of power and profit while doing so. But the end of this part of the game, that’s all in ruins: your gang is destroyed, two of your closest friends were really police stool pigeons, your brother is getting raped in jail, and you’ve only survived because some corrupt policemen think that you can be more useful doing their dirty work for them instead of rotting in jail. (Incidentally, in later sessions of the game, the main character moves out of gang warfare into the fringes of more organized crime, and you make a lot more money that way: again, hardly an uncritical endorsement of gang life.)

The best example of this problematization is in the character of OG Loc. When we first see him, he’s just gotten out of jail, and our job is to kill the person who raped him in jail. He’s trying to stay out of trouble from his parole officer, but he really wants to be a gangsta rapper, and is constantly going on about how he knows life on the streets, how he’s keeping it real. We usually hear him saying this while wearing the uniform of a fast food joint where he’s working, however. It’s typically followed by some awful rhymes that he spouts; his solution to his lack of success as a rapper is, instead of improving his skills, to steal lyrics from other people, and to kill other rappers’ managers. At the end of the first section, he’s decided that he can’t take the life of a fast food worker (which I certainly sympathize with), and that he would rather be an “ass technician” in jail instead of a “fry technician”, that he wants to “keep it real” by going back to jail.

Later in the game, we get to hear OG Loc in a radio interview. He’s apparently gotten out of jail and is a little more successful, and still can’t stop talking about how he knows life on the streets, how he’s keeping it real, accompanied by derogatory comments about women. The interviewer finds this ridiculous; as he points out, we all grew up with a street outside of our front door. So OG Loc pulls a gun on the interviewer in the studio; the interviewer takes back everything he said, saying that he didn’t mean to imply that OG Loc’s women weren’t all “bitches” and “hos”.

Which brings us to the role of women in the game. They are, of course, presented in a fashion that would give pause to anybody with a hint of feminist consciousness. But, as in the last paragraph, that viewpoint is treated in a far from uncritical fashion. And while most of the major characters in the game are male, I’ve seen three important female characters so far. One of them, Denise, isn’t too interesting. The other two that I’ve seen so far, however, are quite strong female characters: Catalina, while apparently insane, is also extremely competent (and easily bosses the main character around), while Kendl, the main character’s sister, is the most sensible person I’ve met in the game, and the only person with a real vision for how to make money and advance in life without crime.

There’s a lot of good stuff here: both in terms of video game gameplay advances and in terms of the sophistication of its plot and its approach towards real-world themes. Before playing the game, I suspected that the GTA series were the most important games of this generation of consoles; now, I’m sure of it.

school closure

January 28th, 2005

The full report of the school closure task force came out last Tuesday, so I’ve been busy writing to the school board, and I spent almost six hours at the school board meeting last night. I actually was pretty impressed by a lot of things that I saw there. Members of the public (including your humble scribe) spoke for three hours; people made a lot of good points, and repeated each other remarkably little given the length of comments. I also liked what I saw from the school board: they were clearly paying attention throughout the comment period, following along in the report when people referred to specific aspects of the report’s evidence or logic. After the public comment, the school board members clearly felt that they needed a lot more information than they had, so they decided to devote next week’s meeting to investigating evidence and digging into issues that people had raised, instead of proceeding to a vote as planned.

I can’t say that I was too impressed by the superintendent, however: in particular, she seems to have a habit of defining words to mean what she wants them to mean, instead of what the rest of the world thinks that they mean. The best example of this is in the press release that her office issued about the report: it says that

the over-arching goal was to make a closure decision that was the least disruptive

(emphasis in original) and then proceeded to outline a plan that wouldn’t simply close a single school (as was the plan, and as the rest of the task force thought they were deciding) but would, in addition, gut a second school, and ensure that students at that second school would have to change schools in third grade for the indefinite future, unlike all other schools in the district. She tried to ease the disconnect by following the above quote with

– meaning that it promoted the best learning environment for all students

but of course, as laudable as the latter goal might be, it simply is a completely different goal from minimizing disruption. (And I am personally not at all convinced that her plan met the latter goal, either.)

This curious use of language wasn’t confined to the press release, either. In response to complaints about the facts that the task force at times held their discussions in closed sessions, she explained that, in fact, the meetings were always open sessions. At this point, my jaw quite literally dropped, and I let out an involuntary squeak (which earned me a bit of a glare); while I’m aware of the expression, this is the first time in the life that I’ve had that involuntary physiological reaction myself. She then further explained that, by “open meeting”, she meant that people were allowed to speak in public for an hour before they were all ushered out, the doors were closed and windows covered, and the rest of the meeting proceeded in private. Which is, I think, not the way that most of us understand the phrase.

Anyways, I guess I’m attending school board meetings for the indefinite future; seeing how they work, I’m actually rather interested. And, as I said a while back, I’d been feeling that I should get involved with local politics a bit more…

const, and iterators

January 24th, 2005

One thing from C++ that I miss in Java is the notion of ‘const’. As I commented earlier, I’m always worried when I return an object that I’m exposing too much of my internals. If I had const to help, it might not be so bad, because I could return const objects, but I don’t have that to help me.

Still, while I like const, it’s a bit of a special case, so maybe I can accept it in the name of simplification. What bothers me more is that similar flaws show up in the library, in situations where they could be easily avoided. In particular, unlike the STL, there’s no iterator / const_iterator distinction. In Java, the Iterator interface has a remove operation; while the documentation marks it as an “optional operation”, saying that you can throw an UnsupportedOperationException, that’s not the way interfaces should work: if a class doesn’t support an operation, then that operation shouldn’t be part of its interface! That’s what static typing is all about!

Java’s Iterator interface is actually a little weird. I’m not that thrilled with the idea of combining the notions of retrieving the current element and advancing the iterators into a single operation. I guess I’ve started to buy into the notion of “Command/Query Separation”; while it’s not as important in Java as in C++, because you don’t have potentially expensive/exception-throwing copy constructors to deal with, it still seems a little unclean to put the two together, and couldn’t there be situations where you want to retrieve the current element without advancing the iterator? Also, it makes for loops look funny, because the third part is missing.

Of course, Java 5 introduced a new kind of for loop, saving you the trouble of doing all the checking and advancing yourself. Which I will also grumble about – it actually doesn’t take an Iterator as an argument! Instead, it takes a Collection (well, an Iterable) as an argument, which it gets an Iterator from (behind your back) by calling its iterator() method. This may save you typing much of the time, but it limits your flexibility – what if, for example, you want to iterate over elements of a list in reverse order? (Hmm: it looks like Java lists don’t actually support doing that by returning a separate reverse iterator object – instead, they return a ListIterator which allows you to go both forwards and backwards. Which is a useful capability, but it would still be nice at times to turn one into a normal Iterator running backwards.) Or what if you wanted to have an InputStream-like class that provided an Iterator interface?

The Java book I was reading touched on this issue, I think – they comment that Java frequently uses Collections where other people expect Iterators, on the grounds that that’s usually what you have around, and in a general interface, you might as well expose the more powerful notion. Which is a reasonable argument, I suppose, for returning Collections where I might be tempted to return an Iterator. (Which gives rise to the same worries about constness that I complained about above, with the same solution: the modification operations for Collection are “optional”, and the language even provides an unmodifiableCollection() function to turn a modifiable Collection into an unmodifiable one.) But it’s not a reasonable argument for interfaces to require a Collection when they only need the functionality of an Iterator: you’re just throwing away generality in that case.

Sigh. I guess, after the STL, most collection frameworks are likely to be a bit of a let-down.

not the best week

January 22nd, 2005

Thursday, a week and a half ago, we had our monthly classroom meeting (for Miranda’s kindergarten class). And we learned that Miranda’s school is probably going to be closed next year. It was public knowledge that one school was going to be closed, but I had kind of been in denial over the issue – even if Slater were the school chosen for closure PACT (the parent participation program that we’re in) would move to another school, and I can’t imagine that very many people want their kid’s school to be closed, and what reason do I have to think that Slater deserves to stay open more than any other school?

Confronted with the likelihood that Slater actually will close, however, I quickly realized that I didn’t think Slater should close; besides PACT, the principal is great, and Liping Ma is working with the teachers to improve their math teaching, which really excited me when I heard about it.

Anyways, Thursday night’s sleep was interrupted by Miranda puking. Then, on Sunday, it was my turn to get the stomach bug. Then, that evening, I heard some dripping in the fireplace; at first I assumed that it was raining outside, but when I walked the dogs, it was dry out. So then, the question is “what is above the fireplace that could cause dripping?”, to which the answer is “the water heater!”. Fortunately, I was staying home on Monday anyways (both because of illness and because of MLK day); it took a little longer than expected, but we now have a new water heater. Actually, it’s just as well that it was replaced now: it turned the old one had its pipes hooked up backwards, which was why the hot water only lasted about one shower’s worth, so I’m glad that’s fixed. (And I’m also glad that it failed with a slow drip while I was at home instead of in a more catastrophic fashion.)

On Tuesday, I went to a school closure task force meeting and had my say in the public comment period. (The actual deliberations were closed to the public, which rather bothers me – I thought California had a law forbidding that?) On Friday, it was Liesl’s turn to get the stomach bug – I devoutly hope that it’s the same bug instead of an exciting new one that Miranda and I will get to go through ourselves…

Still, we’re all on the mend now. We’ll learn on Tuesday what the school closure task force recommends; no matter what, I expect that I’ll be going to school board meetings the next two Thursdays. (I’ve already sent a long e-mail to the school board; I’ve also been pleased at the attention the press is paying to the matter.) And, if Slater is closed, we’ll survive; PACT will probably have a somewhat bumpy year next year, but I far prefer a bumpy year of PACT to a normal year in a normal classroom…

almost everything is an Object

January 12th, 2005

One not very graceful aspect of Java: everything is an Object, except for things that aren’t. (A few basic types: integers of various sizes, floats, booleans, characters, maybe one or two other things that I’m forgetting.) Why is that? The reasons must have something to do with making operations on those basic types more efficient, of course. For example, assuming that you’re on a 32-bit machine, you’d like to be able to store an arrays of 5 integers in only 20 bytes, to be able to add two integers with a single machine operation, etc. So, even if your integer type were to allow method calls (in particular, were to support the methods that Object requires), you wouldn’t want the method calls to be accessed via the normal method call mechanism. Or, perhaps on a more basic level, you would need a mechanism to avoid heap allocation for integer objects.

One way to avoid heap allocation for integer objects but to support it for other kinds of objects is via tagging: if you have a 32-bit value in memory, then the bottom couple of bits tell you if the value is a pointer to an object, an integer, a character, etc. One problem with that is that you lose a couple of bits, so you can only support 30-bit integers via this mechanism. Which is fine for languages like Scheme with arbitrary precision integer arithmetic (so this is just an optimization), but not suitable for Java where integers are defined to have exactly 32 bits of precision. The thing is, though, that’s irrelevant to the Java example, for a couple of reasons, the most basic of which is that I’ve used the word “object” in a completely generic sense in this paragraph, simply meaning “datatype”, which has nothing to do with the existence or lack thereof of an inheritance relationship. The second reason is that Java’s implementation model goes through the Java virtual machine, and while I know next to nothing about it, I’m pretty sure that it has enough strong typing to make type tagging unnecessary. (Otherwise, I don’t see how it could be as secure and efficient as it is claimed to be: either, sure, but not both.)

So that last paragraph was a waste of speculation. And, in fact, Java’s own (as opposed to the JVM’s) strong typing means that you should be able to normally do operations on integers very efficiently, even if integer were thought of as a subclass of Object: when you pass an integer to a function expecting an Object, then at that point the compiler could stick some goop around it to make it behave like an instance of a normal class, but if you’re passing it to a function expecting integers as arguments, then the compiler wouldn’t need to insert that goop. (As is, Java already has classes that correspond to basic types with enough goop added to turn them into honest Objects; in fact, Java 5 does this conversion automatically for you in some circumstances, though by no means all, or even (if I recall correctly) many.)

What flaws would a scheme like that have? It would cause memory allocation to occur behind the scenes in some situations; this might have some surprising consequences at times (in particular, allowing an OutOfMemoryError to be thrown when passing an integer to certain functions), but I don’t think that would be a show-stopper. Equality would be a little delicate: given functions

bool equal( int a, int b ) { return a == b; }

and

bool equalObj( Object a, Object b ) { return a == b; }

you’d certainly want equal(5,5) to hold, and presumably would also want equalObj(5,5) to hold; the latter would make equality testing a little less efficient in some circumstances than it currently is, but I don’t think that’s a bit deal. (Especially since it would only slow down equality testing for variables of type Object: if you know a more specific type, then you’d be safe.)

It would also interact badly with one aspect of Java’s arrays, but that’s a misfeature that I’ll probably whine about in the future.

So I guess I still don’t understand why they didn’t just make everything an Object. Then again, one can ask why I care? If pressed, I would tend to land on the side of languages without a universal superclass. Having said that, I’m not sure I would encourage all languages to provide generic types that are as powerful as C++ templates, and for languages without a mechanism of that power, it will unfortunately be the case that having a class like Object is a necessary evil, in which case you’d want Object to be a universal superclass for all types, not just a superclass for all types except for a few weirdos.

frances hodgson burnett

January 10th, 2005

Ever since we went to see a musical version of A Little Princess, I’ve been on a Frances Hodgson Burnett reading kick. I never read any of her books when I was a kid, but now that I’m giving them a try, I really like the ones I’ve read four so far (A Little Princess, The Secret Garden, The Lost Prince, and Little Lord Fauntleroy). They all follow a similar formula: the main character is a child (10 years old or a little younger?), of excellent character whom almost everybody (adult and child) adores, at least one significant change of fortune (with family, in particular removal from parents, typically playing a key role), everything turns out all right in the end for the main character as well as one follower who has been uplifted by contact with said character. Not a bad formula for children’s books, and quite well executed in all her books I’ve read.

It looks like several of her books are available via Project Gutenberg, for all you etext fans out there.

Other things I’ve enjoyed recently:

  1. The Incredibles. I’m not sure if it or Monsters, Inc. is my favorite Pixar movie, but I had a great time. A bit much for Miranda, though she was brave through it.
  2. Philadelphia Chickens. They are indeed remarkable cows. And remarkable aardvarks. And on and on…

java: what is an object? what is a variable?

January 5th, 2005

This is the first of a series of Java posts, occasioned by the fact that I’m doing some Java programming for the first time in a few years.

When I first started using C++, I thought that its insistence on supporting objects that aren’t held via pointers was, frankly, a little weird. The languages that I’d probably spent the most time with prior to C++ were C and Scheme. In C, you can of course pass structs by value and allocate them on the stack, but most of the time you pass structs via pointers. And in Scheme, there isn’t a notion of objects stored on the stack at all. In C++, though, the language support for objects on the stack is front and center: the copy constructor and the assignment operator are so important that the compiler will provide them for you if you don’t define them yourself, and referenecs are omnipresent, used to get the efficiency of passing via pointer without having to explicitly take an address. So I wondered if it was a good idea, or if it was a misguided legacy of of structs in C. Why not use a simple syntax for referring to C++ objects but have them be heap-allocated behind your back, like in Scheme?

I got used to it, though. Actually, you construct objects directly in C++ much more often than you construct structs directly in C: you construct objects on the stack all the time, and it’s quite common for data members of classes to be classes. (As opposed to C, where it’s not nearly as common for a struct to have a struct as a data member.) Of course, you could have the same appearance while having heap allocation everywhere behind your back, but the more I thought about it, the less appropriate that seemed for a C offshoot: it would go against the language’s obsession with efficiency, and it might not be possible without garbage collection. (Which is another thing that I used to love, but learning C++ has made me realize that garbage collection is much more of a mixed bag than I used to think. Maybe I’ll post on that some other time.)

And now I’m using Java, and I find myself brainwashed by C++. I’m constantly worrying about returning objects – is it safe to return them without cloning them, or am I exposing too much of my internal implementation? (Which has bitten me: my last Java project involved writing a toy compiler, and program-level testing turned up something like two or three bugs that made it through the unit tests; not cloning was at the root of one of them.) And typing ‘new’ all the time bugs me. And while Java does have an analogue of the copy constructor, namely Object.clone(), it’s not nearly as easy to use. At least I think it isn’t, though I haven’t implemented it frequently enough to be sure; the techniques and division of responsibilities involved just seem bizarre to me.

Still, I’m sure I’ll get used to it soon enough, and the fact that C++ has both references and pointers has to be a sign of a design flaw. Probably Object.clone is also a design flaw, and (assuming that I accepted garbage collection) I’d ultimately prefer a language that was more like Java but with Object.clone behaving more like a C++ copy constructor. For that matter, I suppose there’s nothing preventing me in Java from doing copy constructors of my own; it might be tedious without compiler support, though. Maybe I’ll give it a try, and see if I can end up at a happy medium.

free math books

January 1st, 2005

Some friends of mine were over for dinner the other day, and one of them (Ravi Vakil) was asking me about possible licenses for an algebraic geometry book he was thinking of writing. He’d like it to be freely available, so (for example) students could download it, though he doesn’t actually want to put it in the public domain. (Which was my first recommendation, under the influence of this article by Karl Fogel.)

For software, of course, I’d have lots of recommendations: the GPL is one obvious possibility, but hardly the only one. For books, though, it’s not so clear; the FSF has something called the GFDL, but I don’t particularly like it. (I wouldn’t necessarily call it a free license at all; it certainly doesn’t allow others nearly the range of possibilities as the GPL does, though admittedly it’s not clear whether or not Ravi wants to allow other users those possibilities, either.) One source of possible licenses that I found was Creative Commons; are there other good sources out there?

As Ravi commented, he’d like to have the book already be freely available when he’s shopping it around to publishers, to present them with a fait accompli. Which makes me wonder: are there reputable scholarly publishers out there that allow their authors to make the books in question freely available in electronic editions? In my experience, scholarly publishers are in the dark ages when it comes to these matters: they still try (and succeed) to wrest the copyright of works they publish from the works’ authors. Which is ridiculous.

How hard would it be to start a mathematical press, for the twin purposes of giving rights to authors and of encouraging as wide a distribution as possible? (Which are, of course, conflicting goals.) If I could find some friends to help, I could imagine trying such a thing in a couple of years. Of course, there may already be enough people out there trying to do the same thing that it would be more effective to join onto an existing effort.

disgusting food

December 27th, 2004

A new cookbook we got had a recipe for gorgonzola and walnut “ice cream” that we tried last weekend. It looked a little strange: cream together 4 ounces of dolce latte gorgonzola, 8 ounces of mascarpone, add a half-cup of chopped walnuts, whip and fold in a half-cup of cream, and freeze. But all the ingredients are things that I like, the other recipe I’ve tried from the cookbook (meringue chocolate chunk cookies) worked well, and she’s one of the authors of one of my favorite cookbooks.

Sad to say, it was awful. Miranda had several bites of it. Liesl’s mom thought that it might be okay at the start of a meal. Frankly, though, I thought that the combination of whipped cream and gorgonzola was almost nauseating. Admittedly, the gorgonzola we used, while good, wasn’t labeled as “dolce latte”; if I ever run into the stuff, I’ll give it a try and see if I think it would work well enough in this recipe to be worth trying again. But I’m not optimistic…