Last week I was revisiting the always fun problem of
implementing “classical” inheritance in JavaScript. I’d taken a few
stabs at it, and had gotten it to a reasonably good state that borrowed
some good ideas from Doug Crockford, Sam Stephenson, and Dean Edwards. Joshua Gertzen wrote a good post about various methods on his blog.

I’ve never been terribly thrilled with the form Class.superClass.method.apply( this, arguments ).
It was redundant: replicating both the class and method names. Copy
& paste of code could lead to subtle errors, and it’s annoying to
type that much. But the alternatives were worse: Recompiling the
function to generate a “magic” lexical for the superclass or wrapper
methods. So the Class object basically sat untouched for a year and a half.

Back to last week…It occurred to me that in all the JavaScript we’d built for Vox,
we almost never shared a method between two objects, except via
inheritance. There were a couple exceptions, but they could be
rewritten (it turned out to be a good idea anyway). Second, functions
are objects like everything else, and can have arbitrary properties.
Third, arguments.callee is available in every function
call in JavaScript. I realized then that storing the superclass was not
as useful as just storing the supermethod.

For any given method in a class, store its supermethod as a property of the method: method.__super. Instead of the unwieldy construct above, any method could simply use arguments.callee.__super.apply( this, arguments ).

arguments.callee was useful in the constructor too: Instead of creating a circular reference by overriding the constructor like this: constructor.prototype.constructor = constructor, the constructor itself can just set it on the this object when the constructor is called: this.constructor = arguments.callee.

Calling a supermethod can be simplified further, to arguments.callee.applySuper( this, arguments ) via a little sugar:

The third alternative is to abolish DRMs entirely. Imagine a world where every online store sells DRM-free music encoded in open licensable formats. In such a world, any player can play music purchased from any store, and any store can sell music which is playable on all players. This is clearly the best alternative for consumers, and Apple would embrace it in a heartbeat. If the big four music companies would license Apple their music without the requirement that it be protected with a DRM, we would switch to selling only DRM-free music on our iTunes store. Every iPod ever made will play this DRM-free music.

Why would the big four music companies agree to let Apple and others distribute their music without using DRM systems to protect it? The simplest answer is because DRMs haven’t worked, and may never work, to halt music piracy. Though the big four music companies require that all their music sold online be protected with DRMs, these same music companies continue to sell billions of CDs a year which contain completely unprotected music. That’s right! No DRM system was ever developed for the CD, so all the music distributed on CDs can be easily uploaded to the Internet, then (illegally) downloaded and played on any computer or player.

In 2006, under 2 billion DRM-protected songs were sold worldwide by online stores, while over 20 billion songs were sold completely DRM-free and unprotected on CDs by the music companies themselves. The music companies sell the vast majority of their music DRM-free, and show no signs of changing this behavior, since the overwhelming majority of their revenues depend on selling CDs which must play in CD players that support no DRM system.

So if the music companies are selling over 90 percent of their music DRM-free, what benefits do they get from selling the remaining small percentage of their music encumbered with a DRM system? There appear to be none. If anything, the technical expertise and overhead required to create, operate and update a DRM system has limited the number of participants selling DRM protected music. If such requirements were removed, the music industry might experience an influx of new companies willing to invest in innovative new stores and players. This can only be seen as a positive by the music companies.

Tina and I rode 160 miles this weekend. 75 on Saturday, taking a modified Mt. Tam, Seven Sisters + Alpine Dam route, out through Fairfax with a Strawberry detour. 85 on Sunday, on this brutal fun Luna Chix training route that took us to the top of every hill in Oakland, some twice.

High point: Riding on near-abandoned east bay roads on Super Bowl Sunday.

The first of the month, when there are bills to pay and other sundry tasks to get one’s house in order. Rent (or mortgage), car insurance, gym memberships, PG&E. This February brings another pair of open hands: Renter’s insurance and the ever-looming car registration tax. I suppose I should be grateful they are as small an amount as they are. Renter’s insurance is almost laughably cheap, and I have been blessed with living in an area of SOMA designated as a special residential parking zone.

I pay $60 per year for a sticker on the right-rear bumper that lets me park with impunity in any non-metered space in my district. I’m not fully taking advantage of this the way that Danielle Steele is, but I do appreciate the way that our office also happens to fall within the oddly gerrymandered area that is District U.

As it happened, the first of February fell on a Thursday this year, which means I had to park somewhere other than my lovely alley due to San Francisco’s brilliant parking revenue recovery street cleaning program. Returning home last night I dropped my car off around the corner in a metered spot, pulled various valuables out (cars are broken into in my neighborhood fairly often) and made a mental note to move it in the morning.

Which brings us back to this morning, the first of February. I left my door at approximately 8:02 AM, Pista in tow (or was it the other way around) and walked around the block to move my car. In the intervening time, Pista decides to go for the gold, filling up a pair of, well, you get the idea. Her deposits deposited in the trash, we walk the remaining half-block to my car.

Where there it was, in all its glory: A DPT envelope, fluttering in the wind beneath my car’s windshield wiper. Reaching for the envelope, my blood pressure rising, I made a mental run through the list of reasons I could have potentially gotten a ticket:

It’s February. My registration expires this month. Does it expire on the 1st or the 28th?

The meter starts running at 8 AM and not 9 AM.

The DPT agent decided to fuck with me.

In the end it turns out to be none of the above. Maybe a bit of the last, but the reason for my minutes-old parking citation: Parking on a hill without turning the front wheels. Not only did I get a ticket between the time I left my front door and arrived at my car (8:04 AM), or on a day I specifically moved my car to avoid getting a ticket, or parking exactly between the proscribed white lines—but I got a ticket for the most utterly bullshit reason. I couldn’t even chalk it up to DPT quotas, unless my particular agent decided to get a jump on the short month ahead.

I shake my head, swearing and wondering if this was the sort of thing that led to the recent spate of violence against DPT officers.

So another ticket to throw on the pile, another 35 bucks between me and a new yearly registration for the Subaru.

Footnote: I heard a curious thing: A car waiting at the light, windows cracked, blasting Sufjan like it was 50 cent. Trumpets don’t quite vibrate the license plate holder the way that dub does, but the emo-indie-christian mob made me laugh.