Today’s kids have a few things left to tinker with

[Drafts clean out. This one from January]

Mark Pilgrim laments the slow eradication of Apple products to which the owner has full (and gratis) software/hardware access.

Anyone can develop [for the iPad]! All you need is a Mac, XCode, an iPhone “simulator,” and $99 for an auto-expiring developer certificate. The “developer certificate” is really a cryptographic key that (temporarily) allows you (slightly) elevated access to… your own computer.

In the comments he claims, “By 2015, I predict Apple will not sell any devices with root access.” It’s a fun post—reminding me of my days with the CoCo (I had 1 and 3)—but a bit dramatic. Mark and I were pretty privileged and few to have several hundred dollar (in the early ’80s!) computers for us to tinker on; my dad let me drill into and add a motherboard switch to my CoCo 1! My tinkering was more or less limited to BASIC as I never found out about other programming languages really until high school. I mean, I’d heard of EDTASM for assembly editing but I had no idea what that was about, and it was hard enough getting decent documentation for BASIC.

What can today’s kids tinker on? Well, just about everything with a CPU and a port. It’s getting hard to find devices for which you can’t mod/jailbreak or find open firmware for on the web. You can compile and run programs right on the damn web.

I agree with Mark that bad laws and update patches make too much of this kind of tinkering illegal/temporary, but c’mon. Apple will not lead to a future where kids have no computers to experiment on. Yes, few iPad users will tinker, but in the past most kids didn’t have anything to tinker on at all.

Imagining Better E-mail

[Sitting in my drafts folder since August… Why not]

For building a clean and complete “paper trail” within a single message (which is irrefutably valuable in situations), top posting works great. For responding to individual sections, inline reply is great. Combining the two is generally a mess. In both top/inline models the manual management of quoted text in a text editor is pretty terrible. I posit that there’s no satisfactory solution to this multi-decade debate without a better UI than text editors provide. I’d like to see a reply process more like this:

  1. Highlight a selection for quoting. A reply form appears directly below with the cursor ready. (Commenting on a bill in OpenCongress is a bit like this.)
  2. Type the reply
  3. Repeat as necessary

Make the end points of each “quote” easily adjustable, and allow a preview to show you what the recipients would see, to allow you to reorder sections, to adjust header/footer sigs, etc.

A new message format based on git/hg could hold each previously referenced message in the thread, and with it the ability to walk back through the conversation, as well as embed cleanly the contact info of the senders, cryptographic signatures, etc.

The reader could chose to view the latest message in a variety of ways, including the traditional styles of plain text or HTML.

And you can’t fix e-mail without addressing sender authentication.

“Cartels don’t make any money on marijuana”

Opponents to CA’s Prop 19 ran pretty well with the narrative that legalizing cannabis would yield no reduction of the cartel violence in Mexico. After all, they don’t really make their money on pot; it’s all California-grown, they promised. They even were kinda sorta convincing me that might be the case.  Maybe—just somehow—they know that.

As if on schedule, the day after (mostly older) voters rejected the initiative, we find thirty tons of cartel cannabis—probably worth at least $20M—and a massive 600-yard tunnel from Tijuana to San Diego. (and today, more mass graves, of course)

But at least Prop 19 spurred a national conversation about cannabis policy like no other recent event has. Almost 3.4 million Californians voted for it (more than for Meg Whitman). In 2012, when the youth turnout will be more in force, who’s to say.

In the meantime, the proponents need to rewrite the damn thing, addressing all the B.S. non-issues that opponents dramatized. “You won’t be able to fire someone for showing up stoned!” And if you believe that, I have a border tunnel to sell you that’s never been used for cannabis trafficking.

The Hard Road Ahead

I’m starting to believe the only way out of this recession and national deficit is through tough choices that offend the ideologies of every political party:

  • higher taxes for everyone
  • spending cuts, including the military
  • bailouts for state/local safety nets that ease real human suffering, not select industries
  • finding and migrating to foreign aid measures that actually work
  • renegotiating way-above-market public pensions inked during the golden bubble years
  • forcing big banks to cramdown city/county debts that arose due to fraud
  • downsizing the massively expensive and world-leading incarceration industrial complex, perhaps by depoliticizing the CJS
  • reducing barriers to starting up new businesses, especially rent seeking at the local/state level
  • stimulating the wedding industry by ensuring the freedom of everyone to marry

Now who in Congress is up for all that?

Perks of Life in the Kingdom of Nouns

Execution in the Kingdom of Nouns is one of Steve Yegge’s most entertaining posts about the verbosity and noun-centricity of Java (and other strongly typed languages without first-class functions). His post paints a picture of life outside JavaLand, where things are simpler and more straightforward:

There’s rarely any need in these kingdoms to create wrapper nouns to swaddle the verbs. They don’t have GarbageDisposalStrategy nouns, nor GarbageDisposalDestinationLocator nouns for finding your way to the garage, nor PostGarbageActionCallback nouns for putting you back on your couch. They just write the verbs to operate on the nouns lying around, and then have a master verb, take_out_garbage(), that springs the subtasks to action in just the right order.

With simplicity, there’s always a tradeoff. How does one test that take_out_garbage() actually works? You’ll need a full environment with real nouns lying around and all you can do is check the environment after completion. In the Kingdom of Nouns, you can pass in mock nouns and carefully watch what the function does with them. Maybe it’s important that the recycling gets separated, but if you only check the end environment, you won’t be able to tell it wasn’t.

What if trash day is moved to a different day? You might need a new take_out_garbage_wednesday(). As ridiculous as it seems, passing in a GarbageDestination makes the chore more flexible and testable. During testing I can pass in a destination of “right here”, saving me the hassle of creating an environment that includes the walkway out to the curb.

Whether you’re executing global/static functions or class methods, being able to pass dependencies in (where to find the trash, where it goes, when is it supposed to be there) not only makes your function more flexible, but more testable to boot.

This is not to suggest that Steve’s post was anti-dependency injection. I get the impression it was more a frustration of the expressive limitations of Java (when he wrote it—I think it has lambdas now). You can do dependency injection just fine without concrete classes, of course, but you wouldn’t want someone to pass in an array of GPS coordinates when you really need an object that you could call getStreetAddress() on. Type hinting an AddressProvider in the argument would let end users know exactly what to pass in and let the compiler/runtime know not to even bother executing the function, because we don’t have what we need. Also type hinted arguments allow good IDEs to prevent you from making mistakes, or to autocomplete existing variables in scope matching that type.

A Zend Framework App in a Single File

Most PHP micro-frameworks I’ve reviewed have some major cons: incomplete namespacing of functions/classes/global vars; doing too much/little; being under-tested; and the worst: forcing a unique (and usually under-documented) code structure that will make it difficult to “graduate” an app into a more full-featured framework. It also seems silly to rely on “micro-optimized” code if performance isn’t your number one goal and you have well-tested libraries sitting around.

So over the weekend, as a proof of concept (and mostly to get better acquainted with ZF’s MVC implementation), I built some minimal classes allowing one to implement a “quick and dirty” Zend Framework MVC app in a single script, with the resulting abomination being relatively easy to convert to a full app. The README shows how such a script might look. Continue reading  

Minify update

Minify 2.1.4 is approaching release and will have several long-awaited features and hopefully easier configuration.

Looking towards version 2.2/3(?), I recently committed the beginnings of a complete refactoring of the Minify API. The goal is to have a more flexible and extensible design that can include plugins like LESS and maybe handle @imports on the server-side—I’m still mulling over how radically a plugin should be able to alter the overall processing of the request. A key to doing this is splitting plugins into at least two stages and allowing the first to influence the cache id, and possibly add more sources/processors. By asserting that the request’s cache id is stable after the first stage, you can serve requests from the cache most of the time without running the second stage (JSMin, calls to Closure Compiler API, etc.).

Another goal was to eliminate static/global state from all components and have each component independently testable, meaning refactoring out access to global state like request/$_SERVER vars, file access from controllers, etc. A bunch of new classes and interfaces (read: files) could mean a performance hit, but we will also add an internal URL cache so that most requests will not load the system at all. At most once every N seconds the full stack will be loaded in order to make sure the cache is up-to-date with file mtimes, etc., but most requests will hit a very minimal front controller that simply includes a pre-generated PHP script (sending the necessary headers and output) depending on query string and Accept-Encoding. In theory this should be absurdly fast (for PHP output anyway), but of course sticking a reverse proxy in front is always a better idea if you can.

There’s a lot of work to be done. I thought of the URL cache a little late so some of my earlier design decisions were based on performance, and they need to be revisited.