New Blog

I'm starting another blog called Type 3 EV to chronicle a project I'm working on to convert a 1969 Volkswagen Fastback to battery-electric propulsion. Nothing much there yet, but hopefully I'll be able to get some more content on there soon.


Honda, Hybrids and Diesels

From Green Car Congress today, we have a quote from Honda President Takeo Fukui:

Once we are able to cut costs and lower the premium price of the hybrids, there is a possibility that in some markets like Japan, we will only sell Civic Hybrids and no more gasoline-powered Civics. We plan to install diesels in bigger models and hybrids in smaller models.

This sounds about right: for light vehicles, the additional costs of adding a hybrid drivetrain aren't that great, particularly when some parts under the hood can be eliminated. But hybrid drivetrains are pretty much a dollars-per-kilowatt deal, unlike engines where adding displacement isn't all that costly. So for larger vehicles diesel is a better option for fuel efficiency.

There's also mention of selling light trucks in the US with diesel drivetrains, something anathema to Honda until very recently (they sell a diesel CRV in Europe). I always thought when driving my old Element that it really ought to be diesel powered, to the point that I often found myself short shifting the thing. I for one would be thrilled to drive a Honda diesel in the US.

The Hidden Costs of Private Health Insurance

Other, smarter people have written at great length about how screwed up the health insurance system is in the United States. To sum up, we're the only industrialized nation without any form of universal health insurance. There are a few reasonably good arguments against it, that basically fall into three categories: that it will cost too much, that the quality of care will go down, and that incentives for medical research will diminish. I'm of the opinion that the first argument is basically 100% bogus. Those with good jobs already pay for health insurance, be it through an explicit deduction or implicitly through a reduced salary. Huge companies like General Motors are basically HMOs with investments in product manufacturing. And health insurance for the poor in this country is paid for on behalf of minimum-wage employers and the unemployed by public hospitals and the insane rates they charge for services not paid for by insurance companies. And there's not a lot of evidence that as health insurance becomes cheaper people use more of it. In other words, the moral hazard myth is largely bogus, too. In the end the total cost of health insurance doesn't vary much with the cost to any particular end user, and hence doesn't vary much with respect to who is paying the bill. Empirical evidence suggests that people with private health insurance don't need to wait as long to obtain care as those who depend on socialized medicine. While most of the countries that have implemented socialized health care seem to have more-or-less phased out retail healthcare, I can't think of any particularly good reason why this has to be so. Under a well-designed plan, those with additional resources (be it cash or supplemental insurance) ought to be able to purchase their healthcare on the open market, whereas those who would otherwise go without (or be financially ruined by accident or illness) might have to wait a while for non-emergency services. So I don't see how this is a compelling argument either. Finally, some people are of the belief that financing health insurance privately will somehow flush the existing incentives for medical research down the toilet. But the existing incentives for the creation of lifesaving treatments doesn't have a lot to do with who pays for healthcare; it has far more to do with what sorts of treatments are patentable. With the reasons against it out of the way, what are some reasons for implementing universal health insurance in the US? First off is the ever-increasing mountain of paperwork we have to fill out, replete with odd "choices" to be made that strike me should really have been made for me by an actuary whose full-time job is to make these sorts of decisions. It reminds me of the recent company holiday party, where the invitation explained that it was a "mandatory meeting" and that we should "please RSVP." Redundancy aside, if it's not really an option, why are you asking me? Case in point for me is the so-called Flexible Spending Account. That sounds good, but in reality it's a pretty-darned inflexible account I can only use on certain uncovered medical expenses. Oh, and if I don't use it up, the money is "forfeited." Forfeited to whom is anyone's guess; does it just sort of disappear in a puff of smoke? The only upside is that it's deducted pre-tax. It's one of those stupid "bets" that American companies seem to be so big on. For instance, why do I have to decide at the beginning of the month how much I'm going to yak on my cell phone? Why don't they charge me less per unit the more I use it, like any other sensible consumer product? But I digress... The second case is the new Medicare prescription drug coverage. From their FAQ:

Do I have to join a Medicare drug plan?

No. Joining a Medicare drug plan is your choice. However, if you don’t join a plan by May 15, 2006, and you don’t currently have a drug plan that, on average, covers at least as much as standard Medicare prescription drug coverage, you will have to wait until November 15, 2006 to join. When you do join, your premium cost will go up at least 1% per month for every month that you wait to join. Like other insurance, you will have to pay this penalty as long as you have Medicare prescription drug coverage.

Who the fuck thought up this brilliant piece of nincompoopery? Lemme guess: a mobile phone exec?

Can't you just take a chunk of my income, consumption, property, or whatever, and pay the good doctor when I get sick? Do I really need to be involved at every step? How much time is wasted in making and administrating these "choices"? Speaking of which, one of the major impediments of me going off and, say, starting my own company is not lack of money or good ideas, but the fact that I'd basically being playing fast and loose with my life savings in the event that I break my arm or get a bad case of food poisoning, let alone come down with some rare, serious and expensive medical condition. And that's me, as a perfectly healthy thirty-year-old. What about the mom and pop types in their fifties that want to open a bed and breakfast? How are they going to compete with the Holiday Inn if literally no one is willing to sell them health insurance? It seems that by shuffling around the risk a bit, we could remove a lot of the completely unnecessary uncertainty from being an entrepreneur, or even running or working for a small business.


What I Want from a Web Framework

As of today, it's been exactly six years since I started programming in PHP. When I started, the major players for writing web applications (to the best of my knowledge at the time) were CGI scripts written in whatever 1, mod_perl, and PHP, which was on version 3 and just getting started as a web-development language. PHP was free, open-source, and easy to get running under Apache. PHP also had good library support, which was important for interfacing in a clean way with our database at the time, Oracle 8i. PHP wasn't, and isn't, a framework (as I understand the meaning of the term). Frameworks, (such as the then-contemporary ArsDigita Community System) weren't really an option for us, since we were attacking the massive virtual hosting problem with a single set of PHP scripts that assumed the form of the website in question by, in essence, looking up the hostname in the database and spitting out HTML accordingly. For the problem we were trying to solve (in the way we were trying to solve it), it's doubtful an out-of-the-box framework would've done the trick. Still, by writing what in some sense was a framework (albeit one with an installed base of one system targeted toward a handful of markets), I feel like I have a reasonably well-thought-out wishlist of what I'd like to see if I were creating a new web app from the ground up. So here goes: First off, some prerequisites. Some of these are givens, but others not even longtime players like PHP achieve. But this is a basic list of things that a web language/framework needs to include to even step up to the plate: ease of getting started, cross-platform capability, free and open-source licensing, decent libraries (with some caveats) and built-in support of international character sets.
  1. If a web framework isn't easy to set up, very few people will take the time to try it. It's precisely the "what should I write this in if I just want to get it running quickly" crowd that is needed to make a language succeed. These quick prototypes often quickly accrete into larger projects, which then turn into companies (cf. PHP, for a meta-example). Also, unless there are obvious and compelling features to make me want to try a framework or language, I'm probably only going to try those that are easy to experiment in.
  2. Second, good cross-platform support for a language or framework is essential. One of the reasons the reddit guys switched from Lisp to Python was that the Lisp on their dev system didn't match the Lisp on their production system. I like to do development on my iBook, but for various performance reasons, Mac OS X isn't a particularly good server OS yet. So it would be nice to be able to deploy to Linux or FreeBSD for production use.
  3. A related reason the reddit guys switched was that although there are Lisps that work on both MacOS X and FreeBSD, they are all commercial, and I assume, closed-source products. This ties into ease of experimentation as well. If I need to buy a license or deal with a crippleware free version, I'm less likely to try a product. Also, open source is a pretty-well proven way to develop a platform, if not consumer-oriented software like word processors.
  4. Library support has historically been quite important as well. I'm on the fence whether an RDBMS is going to be the long-term winner for persistent storage for web apps, but at the moment it's pretty important. And lacking first-class support for things like bind variables is a pretty big unfeature, so the libraries have to be complete and up-to-date. And library support adds the sorts of candy that gets people to try your environment in the first place.
  5. Lastly, (and I'm talking to you, PHP), transparent and built-in support for international character sets is an important feature. Heck, if internationalization in general could be cleanly integrated into the framework, so much the better.
Now onto my personal preferences. First in the list would be a clean, powerful language. This is another area where PHP falls short. I'd like to be able to have something like this work:

function that_returns_an_array()
        return array ('foo' => 1, 'bar' => 2);

echo that_returns_an_array()['bar'];

It should print 2 but it doesn't even parse; a little more closure would be nice. Having to type "array" to define a hash is also a little annoying; something that looks a little cleaner couldn't hurt. And I understand functional programming is supposed to have some kind of salubrious effects, so maybe a language that lends itself to functional programming would be a Good Thing. One thing I do like about PHP is it's inside-out nature. There are all sorts of ways to shoot yourself in the foot with this sort of architecture, but it sure helps with point 1 if you can mock up a site in HTML and then add the active portions in place. Related to this, however, is a pet peeve of mine: the profusion of template languages. I can think of three arguments for the existence of templating languages:
  1. Web designers are scared of programming languages
  2. We need to separate presentation from content
  3. Bad people can do bad things in the native language
The first argument, I think, is bogus. Most sufficiently powerful templating languages are at least as complicated as the equivalent constructs in, say PHP, and if you're in something that's effectively a template language, why spend a bunch of processor cycles str_replace'ing tags?2 . The second argument has largely fallen by the wayside with the standardization and widespread adoption of CSS, and it doesn't even really solve the problem of internationalization. The third argument I'll deal with below, but basically an ideal web framework would use a capability model that would render it moot. Which brings me to the only possibly-original idea in this post: using something along the lines of a capability architecture to provide transparent security. The current state of the art seems to be to use an RDBMS for persistent storage and to use SQL to query and manipulate data. Typically a connection with full privileges is made to the database, and the so-called business logic in the Web application or framework decides what level of access is afforded to the end-user. The problem with this arrangement is that the integrity of the database is potentially no greater than the attention paid to security in the most poorly-written piece of software on the server. Furthermore if someone manages to sneak a script onto the server, the damage done is limited only by the permissions of the Web server process. If the process has some kind of built-in persistent connection to the database, the security of the database is equally compromised. In the ideal case, the web framework would have user accounts with fine-grained privileges (possibly including a generic "guest" account with read permission on public areas), and those privileges would trickle down to the lowest levels of the execution of the script. For instance if Joe has write permissions on all appointments belonging to Joe, Joe wouldn't be able to delete Mary's appointments even if poorly-written code would otherwise allow it. The script that Joe manages to sneak onto the server (itself a much less likely scenario under this architecture) still wouldn't allow him to query or manipulate any data that the Joe account isn't authorized to access. I'm not sure if the user accounts on a UNIX machine, much less an off-the-shelf RDBMS are robust and scaleable enough to be able to handle one "user" per user, and it would be interesting to see if any existing frameworks use this approach or something similar. Even then I'm not sure if most RDBMSes have good row-level access control. The second newish feature I'd like to see I haven't thought through well enough to describe in detail. But basically it would come down to (more) transparent persistence for user data. This is somewhat problematic in a stateless architecture like the Web, but it would be neat if I could simply flag a variable as persistent and have it stick around between requests. And not only that, but have it be the first-class way of storing data between requests. This could, of course, be shoehorned into a RDBMS and/or filesystem, but an integrated approach might be superior. If we combine these two, then the use of UNIX user accounts and native RDBMS users sounds increasingly infeasible. In that case it might be the right approach to ditch the RDBMS and raw filesystem, or bury it under enough layers of carefully-reviewed code to make the features transparent. I apologize if this has been a disorganized rant. I'm sure most of the concepts have been gone over by people far more knowledgeable than myself, and it's even possible that all of these are encapsulated in an already-existing framework that I just have to go out and learn. If so I'd love to hear about it in the comments ;) 1 I have it on good authority that Amazon's obidos is written in C, and also that the number of requests a particular Apache process is allowed to handle before being killed—to control memory leaks and such—is in the single digits. 2 As a stunt I'd like to see someone write a templating language in another templating language, preferably on top of PHP or some other inside-out language.


Minor Annoyances Part I: SourceForge.net

Sometimes I like to browse the web in Safari on my local machine while installing updates on a remote machine in a terminal window. Typically I'll try to find a link to the download on the web and right click it, selecting "Copy Link." Then I type wget "<pasted URL>" in my terminal window to put the file on the machine in question. So the first part of this rant is against links called "Download" that don't actually download. If the link is going to lead to a page that has me pick a mirror, the text should specify such, goddammit! I can't even count the number of times I've wgetted a file only to find the file consisted of a html comprising a mirror-selection page. The next part of this rant is against what happens once you've selected a mirror. At this point it loads a page that says "the download should have started automatically", as though I have nothing better to do than look at your goddamned ad page while the download downloads to the wrong place. Good thing we don't pay for incoming bandwidth. How about a nice simple link to the file, folks?


Up-front and Lifetime Costs

A few years back my good friend Craig Meyer pointed out that in the days when the Chevy small-block engine was designed the primary criterion for engine design was how many horsepower the engine could produce for a given cost. Of course the packaging had to be reasonable, as did the ease of service and manufacturability, but both of these feed back into overall cost in the end. Efficiency and pollution were, if they were considered at all, at most afterthoughts. It took the oil shocks to change that mindset. I bring this up because until recently computers have been in the same boat. With the exception of laptops, the same criterion has been applied to computers in general and microprocessors in particular: how much power can we squeeze out of every dollar? But it seems like Google, among others, is running into an electricity shock: lifetime costs of servers will soon outstrip up-front costs. This, and a lot of other things suggest that maybe Wally Rippel, the resident mad scientist at my previous employer, was right. He said something along the lines of "[the last] century was when we learned the value and limitations of data; in [this] century we'll learn the value of energy."


Extreme Climbing

This—and I do not use the term lightly—is the fizznucking bomb.


Drivetrain Deathmatch: Diesel or Hybrid?

I've been thinking a bit lately about conventional diesel versus hybrid spark-ignition drivetrains and what their respective strengths and weaknesses are. For purposes of this discussion, diesel will refer to a turbocharged direct-injection diesel engine like that found in the US-spec Volkswagen Golf. Hybrid, unless otherwise specified, will refer to a series-parallel system like that found in the Toyota Prius.

I will look at price premium, fuel savings, emissions, and semi-intangibles. All prices are base MSRP (before any incentives), and I'm going to look at marginal values for nearly everything. The wisdom of this is certainly up for debate, but if we're looking for something like a dollars-per-tonne of carbon value, this seems like the best approach. Finally, I won't be considering straight-up gasoline power, battery-electric power, or fuel cells, stirling engines, or nuclear flywheels. That may make for a lame deathmatch, but two contestants makes things much more manageable.


Comparing a Toyota Prius ($21,725) to a similar non-hybrid car isn't trivial, since not only does Toyota not sell a non-hybrid Prius, it also doesn't sell a vehicle that is exactly comparable in terms of size and features. Using the Camry LE ($20,375) at the high end and the Corolla LE ($15,215) at the low end, you could say the Prius represents a $4,000 premium over a comparable non-hybrid car. Honda makes things a little easier on us, where the Accord Hybrid Sedan ($30,140) costs $2,840 more than the Accord EX V-6 Sedan ($27,300), but also makes slightly more power. The Civic Hybrid Sedan costs $3590 more than the Civic EX Sedan but makes slightly less power. So we could put the price premium over a comparable conventional vehicle at roughly $3,600 to make the math easy (see below).

For a mid-priced passenger car, a turbocharged direct-injection diesel engine adds something like $1200 to the price of the vehicle. The engine will typically have lower peak output but higher peak torque that's also available at lower RPM. In other words, outside of the the occasional On-Ramp Grand Prix, the diesel will exhibit driveability that is equal to or better than the equivalent spark-ignition engine.

Advantage: Diesel. The price premium for a diesel is roughly one-third of that for a hybrid. However, as hybrid technology matures, this difference is likely to shrink, if not altogether disappear.

Fuel Economy

The Accord Hybrid's EPA gas mileage is 29/37, or 8.1/6.4 in sensible units (l/100km)[1], whereas the standard V-6 Accord (which makes slightly *less* power) comes in at 11.8/8.1 (20/29), giving us a 100 kilometer fuel savings of 3.7 liters in the city and 1.7 liters on the highway. The Civic Hybrid is rated at 4.8/4.6 (49/51) versus the Civic EX Sedan's 7.8/5.9 (30/40), resulting in 3 liters saved in the city and 1.3 liters saved on the highway.

The Prius' fuel economy is rated at 3.9/4.6 (60/51), versus a Camry LE's 9.8/6.9 (24/34) or a Corolla LE's 7.8/6.2 (30/38). Over a hundred kilometers of driving, the Prius saves 5.9 or 3.9 liters over the Camry or Corolla (respectively) in the city, or 2.3 or 1.6 on the highway.

For diesel cars, the VW Golf again provides a good comparison. The diesel uses 6.4/5.3 (37/44) versus the 2.0's 9.8/7.6 (24/31). So the fuel savings for a 100-km trip are 3.4 liters in the city and 2.3 liters on the highway.

Advantage: Depends. The hybrids pretty well outshine the diesel in the city, but the best of the hybrids just matches the diesel's savings on the highway. This is idle stop and (to a lesser extent) regenerative braking at work, both of which could in theory be applied to a diesel, a topic I'll delve into in the conclusion. One thing to keep in mind is that diesel fuel is more energy-dense than gasoline, so the carbon footprint of the fuel—and hence the fuel savings—is more significant.


Advantage: Hybrid. I'm going to cheat on this one with a bit of just-trust-me hand-waving, and if someone can find numbers on this, feel free to call bullshit on me. I know that Emission-control technologies for diesels are much less mature than those for gasoline engines. Currently they still emit quite a lot of NOx and particulates—particularly under high load conditions—when compared with conventional spark-ignition engines. Gasoline-electric hybrids are even cleaner than conventional spark-ignition engines and therefore are the clear winner in the emissions department. As diesel emission-control technology improves, this difference is likely to shrink as well.

(Semi) Intangibles

Toyota's fiendishly-clever Hybrid Synergy Drive gets a few points in the intangibles department. It doesn't require a conventional starter, alternator, or torque converter/transmission. All three are replaced with two synchronous permanent magnet (basically BLDC) motors and a planetary gearset. So you have a stepless transmission with none of the "Captain to Engine Room" lag you get when you mate a modestly-powerful engine to a conventional slushbox. You can fill up at any gas station, and the fuel doesn't smell funny. Plus it has a nifty on/off button.

The diesel has the advantage of an energy-dense fuel that has a readily-available and cost-competitive renewable version (B100 biodiesel). It's a proven technology that's quite fun to drive. And the hint of turbo whine when you take off sounds really cool.

Advantage: Depends. I like the hybrid because of the propellor-head geekiness of it's drivetrain, but that's probably more personal preference than anything.


If we look at the underlying technology, the reasons behind some of the above conclusions become clear. A diesel engine runs in an unthrottled lean-burn regime with the turbocharger enhancing the expansion ratio. A hybrid also runs it's gasoline engine more or less unthrottled in a lean-to-stoichiometric regime with an Atkinson cycle enhancing the expansion ratio. Because they're unthrottled, diesels can idle relatively efficiently. Hybrids typically implement an idle-stop function, achieving the same thing. So in one sense, a hybrid is a clean diesel, and a diesel is an inexpensive hybrid. The price performance of each is likely to converge as both hybrid technology and diesel emission-control technologies mature.

The obvious question is why not both? Why not a diesel hybrid? The answer, keeping the preceding in mind, is that there are diminishing returns due to overlapping advantages, along with accelerating costs. One way to mitigate the costs would be to create a mild diesel hybrid that eliminates the redundant starter and alternator. This could improve the city fuel economy and emissions, but would still cost more than the diesel alone, possibly so much so that it wouldn't be worthwhile.

An interesting side note is that the Prius-style drivetrain is being experimented with as a simple replacement for a conventional transmission, without any true hybrid capability (i.e. no traction battery). It will be interesting to see what the optimum traction battery size is for such a vehicle, and whether it is even greater than zero.

If I had to bet on a winner for the next 10 years or so, I would bet on the diesel. Nearly every car sold in North America has a diesel version that is sold overseas (including such cars as the MINI Cooper and Mazda 5 (nee MX-5 Miata)). Now that ultra-low-sulfur diesel is coming online in the States, there is nothing stopping us from slowly converting our entire fleet to diesel in fairly short order. But a significant drop in battery prices, along with the relentless downward march of electronics prices might well make hybrids, even diesel hybrids, the winner in the longer term, until and unless fuel cells or peak oil dethrone them both.

[1] To reiterate my previous rant, measuring fuel economy in miles per gallon is like specifying your salary in minutes per dollar: it makes for a nice round number, but it makes it needlessly difficult to compare differences. To use my favorite example, a one-mpg improvement in a 10-mpg car saves as much fuel as doubling the fuel economy of a 50-mpg car.

Weird Dream

Last night I dreamt that I went back to visit my college to find that the late Bob Ross (not late in my dream) had become an art professor there. That is all.

Does AJAX Suck?

Here's a delightful spoof of a 1996 Jakob Nielsen article entitled Why AJAX sucks.

While the arguments are generally valid, it misses an important point: nobody (for sufficiently large values of "no") is using AJAX for information presentation. Sure, there's the occasional client-sorted table, but in general AJAX is being used to replicate content creation apps in the browser, rather than for content presentation.

This is in stark contrast to the scourge of frames (and don't get me started on all-Flash™ sites) which are primarily intended for use by end users, and have all the attendant problems like breaking bookmarks and the Back button. But I don't know if anyone really expects the Back button to un-send an email they just sent in Gmail.

(I can go on for pages on all the reasons frames suck, since I've had to deal with them for the past six years here at work. If you'd like me to do so, please post a comment accordingly)



How to Become an Early Riser

Wait. Or, more specifically, grow up.

To clarify, this is in response to this post (found via reddit). This site goes on a great length about how the author now goes to be earlier than he did when he was in his early 20's.

But according to people that research this kind of stuff, our sleep patterns are much less a matter of simple habit than we'd like to think.

Maybe I'm being unduly harsh, but the end result reads like me trying to explain how I stay thin. (The real answer is probably genetics, but here goes: shun sugary drinks, don't skip breakfast, eat small balanced meals, stop eating when you're full and don't be afraid of fat or a small balanced snack when you've got the munchies).


It's snowing outside

The snow is still coming down outside my window, which around here is—like rain in Southern California—an unusual but in no way unexpected event. That makes it somewhat topical to comment on local drivers' reaction to this. They basically fall into three camps:

There's the normal reasonable driver camp, that makes up perhaps half of the cars on the road, or slightly less when it's snowing. These are people that have been driving long enough or are generally well-adjusted enough not to hold their masculinity and/or self-worth hostage to their driving style. So they drive at a safe and reasonably speed and are generally law-abiding and courteous. Sure, each individual driver occasionally veers into one of the two modes I'll describe below, but overall they react rationally to current driving conditions.

The second camp is the so-cautious-they're-dangerous camp, that make up around a quarter of the drivers around here. Their style is to drive at a snail's pace any time they see white around them. No matter if the roads are bare and wet, fifteen miles an hour is plenty for them, thankyouverymuch. Similar to the granny doing forty-five in the right lane of the interstate with her left blinker on, their primary function is to provoke the third style of driver.

The third camp has a noticeably forced nonchalance about the fact that traction conditions might be sub-optimal. In fact they typically drive more aggressively on snowy or icy roads than they would if the roads were merely wet. More often than not they're driving a large four-wheel-drive pickup or SUV, but the occasional chip-on-their-shoulder Saab or Volvo driver is also guilty.

Back when I had a more performance-oriented vehicle I was often a member of the third camp (of course there was also the Walter Mitty aspect of playing World Rally Championship on the streets of Bellingham), though I now like to think I'm in the first camp. Fortunately we all grow up. Unfortunately there is always a new batch of whippersnappers to take our place.

Electron Band Structure in Germanium, My Ass