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.

Plastic Sitars Intro for piano

I’ve been playing more music lately, but also trying to go back and learn the fundamentals of reading/writing music and keyboard playing—I can play chords and pop melodies semi reliably but suck at playing scales with either hand. Yesterday I created a free account at Noteflight, which lets you compose scores online (you have to enter notes via mouse/keyboard, but the UI is pretty quick once you get the hang of it). The import feature successfully digested a 15 year old MIDI file of something I wrote in college.

The (yet unrecorded) French Horns song “Plastic Sitars” always started with rhythm guitar live, but for a few months I’ve been toying with a short solo guitar piece as an intro, ideally stealing Johnny Smith’s tone. Below is a piano arrangement for my tour of airport cocktail lounges.

Elgg Core Proposal: New Table “entity_list_items”

[This proposal has been superseded with ElggCollection.]

As of Elgg 1.7.4 there’s no way to specify a specific list or ordering of entities for use in an elgg_get_entities query. E.g. one might want to implement:

  • A “featured items” list for a group or user widget. On a group page this could be implemented in “left” and “right” lists for better display control
  • “Sticky” entities in discussion lists, or any other object lists
  • A “favorites” list for each user

Continue reading  

About damn time, guys

Opera 11 will have extensions.

Mozilla 1.0 had the first decent extension system in 2002, and since then Opera users have been begging for one and getting lame excuses and half-baked substitutes that offered none of the power of real extensions:  “Panels” were just HTML docs beside the viewport, and “widgets” just HTML apps in separate chromeless windows.

If Opera doesn’t want to sit at 1% market share for 10 more years, they better get this right. An “extension” system should be able to alter chrome and context menus at the bare minimum.