Monday, June 28, 2004
Saturday, June 26, 2004
Static typing and Java collections
Java's collection classes provide fertile ground for the perpetual debate between static and dynamic typing. One argument says that since Java collections are effectively dynamically typed, but
ClassCastExceptions are still rare, static typing may not be as helpful as its advocates would like to think.
I ran into a
ClassCastException the other day. My initial thought was to count this as a place where static typing wins out, but once I found and fixed the mistake, the particulars paint a rather different picture.
- The container in question was
HttpSessionattributes - a heterogenous collection that cannot be made typesafe by generics or similar mechanisms.
- The cast that caused the problem was because I put a
Collections.synchronizedSet(new HashSet())in the session, and tried to take a
HashSetout. In a dynamic language, this wouldn't be necessary - if it acts like a set, it's a set.
- This is not the kind of bug that lays dormant in code for long periods of time. The compiler didn't catch it, but my unittest did.
Even though Python is my favorite language overall, I tend to believe that static typing is valuable for large projects. The aforementioned Bruce Eckel article says that static typing is a form of testing, but I think it's really more like documentation. Type declarations are a form of comment whose accuracy can be verified by the compiler. In a dynamic language you usually end up putting comments describing the types of objects, so you might as well do it in a machine-readable way.
Thursday, June 24, 2004
No Republican senator has sponsored more laws later held unconstitutional than Hatch. I've always thought that sponsoring (or perhaps even voting for) unconstitutional legislation should be an impeachable offense. The "Republican" qualification in that quote makes me wonder, though - is there a Democrat who meets or exceeds Hatch's record for broken legislation? If so, I'd like to know who it is so I can give him an equal-time bashing.
Thursday, June 17, 2004
Mac OS X: Sidetrack and new versions of Mozilla
New versions of Mozilla-based browsers (Firefox 0.9, Camino 0.8b, and Mozilla 1.7rc3) introduced some strange new behavior: They interpret a "horizontal scroll wheel" as clicks on the back/forward buttons. This is not good for those of us who use Sidetrack for scrolling with the touchpad. This tip at macosxhints explains how to restore the old behavior.
Who defended the country?
IsThatLegal points to an essay by Elaine Scarry that argues that the passengers who brought down their own plane on 9/11 were more effective at defending the country than the military is. This is something that I've felt for a long time - the biggest thing that has made us safer since 9/11 is not airport security or military action, but the fact that passengers will now do everything in their power to stop a hijacking instead of playing along in the hope of landing safely.
Tuesday, June 15, 2004
Second Life releases XML-RPC interface
Massively Multiplayer Online Building Toy Second Life has released an update that, among other things, allows player-written scripts on in-world objects communicate with the outside world via XML-RPC. I've been interested in Second Life for a while, both for the technology (3d models, textures, and sounds are all streamed to the client on the fly) and the economics (players retain intellectual property rights on things they build in the world, and the publishers encourage the exchange of in-world goods for real money). It's the closest approach so far to the metaverse from Snow Crash. In spite of this, I haven't found the "gameplay" to be a very compelling experience - if I want to build something, I might as well play with something like Blender. I wonder if this connectivity to the outside world opens up enough possibilities to make it more interesting (just like how the internet changed the nature of personal computing)
One thing that I think could really bring a lot of users into a world like Second Life would be instant messaging integration. Imagine being able to log into your in-world identity via an IM-style client (either a custom client for the particular world or using XMPP to open it up to third-party clients), and then hop into the world when your friends show up. If you can maintain some sort of presence in the world even when you're not actively walking around in it, the world becomes a lot more suitable for casual socializing. You can of course achieve an approximation of this by exchanging handles for the IM system of your choice, but the separate identities make this awkward (and receiving outside IMs while you're in the game is disruptive).
Of course, the question is whether the publishers would want such an influx of players. In the case of Second Life, the answer may well be no. In Second Life, a basic membership has no monthly fee - you only have to pay a monthly fee if you want to own land (and you need to own land in order to build anything outside of designated sandboxes). Landless sightseers soak up bandwidth without paying anything. They're valuable only to the extent that they are likely to convert to paying memberships, or that they encourage other builders to join or stick around. This last point raises the interesting possibility of in-world advertising, but that's another story.
Saturday, June 05, 2004
UNH Biodiesel Group
UNH Biodiesel Group: "Enough biodiesel to replace all petroleum transportation fuels could be grown in 11,000 square miles, or roughly nine percent of the area of the Sonora desert."