Monday, August 31, 2009

Snow Leopard is a disaster

PDF display is broken in both Safari and Firefox. Most of my files have lost their proper application bindings. And my external SATA drives aren't working (apparently a known problem. So I can't connect to my Time Machine drive. So I can't even revert my Snow Leopard install.

What the fuck, Apple?

[UPDATE] The PDF display problem turned out to be an incompatible plugin (the Schubert PDF plugin). But the ESata problem seems to be real, and the only solution is to either buy a new ESata adapter or wait for Silicon Image to update their drivers. I'm not optimistic. It's not as if they didn't know Snow Leopard was coming. :-(

Reflections on a fire

Now that I've had a chance to put a little mental distance between myself and the immediate prospect of losing my house, I thought I'd take a moment for some sober reflection about the Station Fire.

First, OH MY GOD THAT THING HAS GOTTEN MOTHERFUCKING HUGE!!! Just a couple of days ago, the Station Fire was the little fire, the smallest of four active fires in Southern California. The nasty one was down in Rancho Palos Verdes, and when they managed to put that one out in just a couple of days I assumed that the Station Fire would be short-lived as well. They were predicting relatively favorable weather. Hot and dry yes, but no wind. Wind is the killer. If you're in the path of a wind-driven fire, run. Do not pass go. Do not collect $200. Just take whatever is irreplaceable and go.

But the Station Fire was not -- and is not -- a wind-driven fire. It's just a plain old ordinary run-of-the-mill brush fire. The current conditions are not a worst-case scenario. In fact, they are -- to paraphrase Quentin Tarrantino -- pretty fucking far from worst-case. Which is why I am just shocked at how out-of-hand it has gotten. I shudder to think what we'd be looking at if the Santa Anas had been blowing for the last week.

Second, I am at once pleased and dismayed at how we dealt with an actual emergency. We had a plan, we executed on that plan, and almost everything went according to plan. But, man oh man, did we have the wrong plan.

I had a relatively sophisticated fire-fighting setup. I bought a gas-fired fire pump that could draw water out of the pool on the theory that even if it didn't actually do any good, it would suck less to watch the house burn while I was spraying water at it than watching it burn while standing by impotently. I also re-plumbed the main water feed to the house so that I could hook a real fire hose up to it as well. And I had fire-retardent gel and foam. I was as prepared as I could possibly be. It all worked more-or-less flawlessly. And it did make me feel a lot better, like I was doing something instead of just being a spectator. But in retrospect, I would have been much better off with a roof sprinkler and a truck.

The problem with brush fires is that they don't come with a program. You never know until after it's over whether this one is going to pass you by or bear down on you with wind-driven rage. In the middle of the broad scope of possible outcomes is a fairly narrow range where your intervention can actually help without putting yourself in danger. I think there's really only one scenario where homeowner intervention makes sense, and that is the case of the flying ember that lands on some tinder near the house, smolders for a while, and then burns the house down while the main body of the fire is still some distance away. And if you catch that early enough you can handle that situation with a garden hose.

I think if you're going to live anywhere near the mountains in SoCal you have to make your peace with the fact that your house might burn down some day and there will be nothing you can do about it. Accordingly, the best thing you can do is to figure out well in advance what stuff in the house really matters to you, and have a plan for getting that stuff out of the house, storing it somewhere safe for a while, and then putting it back, either in the same house or a new one that you build after the old one has burned down. Making that inventory was not part of our advance preparation, and that was a huge mistake. We found ourselves trying to decide under pressure what we wanted to save. And it turned out that some of those things -- mainly artwork -- wouldn't fit in our cars.

Happily for us, we were able to call on a friend who had a truck to come to our aid and help us cart away a few bulky paintings. And in the final analysis I think we did a pretty good job of triaging our possessions under pressure. But in the chaos, some really essential things, like the cat's litter box, ended up in the wrong place. If I had it to do over again, I would have made a written inventory of everything we wanted to save, which car it should go in, and done a dry run of packing to make absolutely sure it would all fit.

Someone asked me if I've had second thoughts about living in SoCal as a result of this fire. The answer is no, this fire hasn't changed my views at all (except on using Barricade Gel. I won't be doing that again.) In fact, I feel much better about living here now because the fire danger for us will be a lot lower for the next 5-10 years until all the brush grows back. Having the area around our house burn the way it did, in wind-free conditions, was the best possible outcome. That the brush would burn was inevitable (as is its growing back eventually). And I think it's also inevitable that our house will burn some day. We are surrounded by tall pine trees. That's one of the things that makes our neighborhood a really great place to be -- it's like living in the woods. But those trees can't keep dodging the fire bullet forever.

Trick is, there's no place safe on the planet. No matter where you go you have to deal with something, whether it's blizzards or hurricanes or fires or earthquakes or drought. And I guess I'd just as soon deal with the fires and the earthquakes as anything else. When it's not smoking and shaking, which is after all most of the time, this is actually a pretty nice place to be.

Sunday, August 30, 2009

Fire for the impatient

Time lapse video makes the fire look pretty gnarly. When you're as close as we are, it's every bit as ominous in real time.

Living through a brush fire: some lessons learned

This post is the one that I wish someone else had written that I could have read before yesterday.

The first thing you need to know about brush fires is that it's all about the wind. If the wind is blowing, you're screwed. There is nothing you can do but pack your stuff and the hell out of Dodge. I learned this from an acquaintance who lost his house in another fire a few years ago. He's a volunteer firefighter, so he has all the right training and equipment. He did all the right things. He had pumps and hoses and a chainsaw to cut away the wooden deck outside his house. The fire came to with a few yards of his house and then stopped. He thought he was safe, since there was now a wide zone between him and the fire that was depleted of fuel. The same brush can't burn twice, right?

Wrong. The wind shifted, and what had previously burned as a relatively controlled slow-moving fire, now re-ignited as if it was a blast furnace. His house pretty much just went "poof", and he was lucky to escape with his life. The heat from the fire blew out the back window of his truck and lit him on fire as he was heading down the hill. Fortunately, there were firefighters at the bottom who were able to extinguish him before turning their attention to their own truck, which had also caught fire. And yes, I saw photos. He documented everything quite meticulously.

Miraculously, although the weather has been unseasonably hot and dry (and that's saying something in August in Southern California) we have had virtually no wind. That's been horrible for air quality, but it's almost certainly the only reason more houses haven't been lost.

So last year I decided to get better prepared for the fire that I knew would inevitably come (though I wasn't expecting my timing to be quite this good). I explored various options, including a roof sprinkler, and a gas-fired pump that draws water from the pool. After consulting with a local fireman we decided to go with the pump. We also got a supply of foam and Barricade Gel. Yesterday I was able to put all that stuff to the test.

In retrospect I think we got it exactly backwards. If I had it to do over again I'd go with the roof sprinkler and forego the pump. The problem is that you have to be there to man it, and you have to be there when the fire arrives. And, as we found out the hard way yesterday, the same fire can arrive more than once.

The gel and foam turn out to be pretty useless also. The foam in particular just seemed to dissolve on contact with whatever it landed on. Five minutes after being applied there was no hint it had ever been there. The Barricade Gel, on the other hand, works as advertised. It leaves everything covered with a 1/4-inch thick layer of slimy goo. Word to the wise: wear leather work gloves when you apply this stuff, not because you need the protection, but because it's incredibly slippery, and if it gets on your hands you can't grip anything any more.

The trouble with the gel is it only lasts for an hour or two, so your timing still has to be pretty much dead-nuts on. It also leaves a horrible mess behind. Our house is now covered with a slimy film of residual gel, and I have no idea how we're going to get it off.

A roof sprinkler system has its own problems, of course. If you have eaves it won't do anything to protect the sides of the house. Of course, you can install sprinklers all around the eaves as well, but that starts to get expensive and/or unsightly. PVC will melt in a fire, so you need to use copper or galvanized steel for the plumbing. But the nice thing about it is that it's fire-and-forget (so to speak). You turn it on, evacuate, and whenever the fire arrives everything will be nice and soggy. It won't protect against a wind-driven fire (nothing will) but it will help prevent flying embers from igniting your house, which is pretty much all you can do. If mother nature decides she wants your house she will take it. The only way to be absolutely safe is to build out of concrete (and even then the radiant heat from a really hot fire can penetrate the windows and light the interior on fire).

One last thing to keep in mind if you decide to go with gel: it's seriously hard work to apply. You can do it with a garden hose, but that's very slow. We used the gas-fired pump, and let me tell you, wrangling a 100PSI fire hose make you feel very manly, but it is seriously hard work. By the time I was done applying the gel I was at the limits of my physical endurance in my upper body. Granted, I'm not in great shape. Most of the exercise I get above the waist is from typing. But I think I'm not alone in this. Oh, also, buy four times as much gel as you think you need.

There are two more drawbacks to the gel: its expensive, and it has a limited shelf life. You have to shake the containers every six months, and even then it only lasts a couple of years.

Of course, the best way to prepare for a brush fire is to buy a house far away from brush.

Out of the frying pan

6:45 AM, got about 4-5 hours of sleep. Woken up by the cat, who can tell that something is not quite right, and despite the fact that I'm yawning like George Bush at a Constitutional law class, I can't fall back asleep. LA Times still reporting that the only structure loss in the fire so far are three houses in Big Tujunga Canyon, which is in the middle of the Angeles National Forest. So all indications are that our house is still standing. But I have no idea whether the fire has burned itself out in our neighborhood, or is still working its way up the canyon. That's definitely the worst part of being evacuated, the not knowing.

We're staying with some friends in Altadena. We had a great dinner here last night. The air was clear (one of the side-effects of being dry) and we had a spectacular view of the city lights. This morning it looks like a fog has descended, but it's not fog. It's smoke. The eastern flank of the fire is slowly working its way across the front range in this direction. And our friends' house is even more vulnerable than ours. It's a race against time between the fire and cooler weather which is supposed to arrive in the next few days.

I swear by all that is holy that I will never again wish for more excitement in my life.

[Update 10:00 AM] Our house is still standing, along with all the others in our neighborhood. The roadblocks have been removed, and a small army of firefighters are moving on to warmer climes. There's still some smoldering in the canyon, and today is going to be another scorcher so it's a little premature to breathe a complete sigh of relief, but it certainly appears that the worst is over.

Saturday, August 29, 2009

Evacuated

Tonight for the first time in my life I am involuntarily not sleeping in my own bed. We've been evacuated. This has been quite a day. The fire came in from the east and it was a real nail-biter for a while, but then they beat it back and I thought that was going to be the end of it. But then it jumped a fire line and is now creeping back towards our house from the north and west. It's coming in very slowly, and the fire fighters have been doing an amazing job of saving structures, so we have every reason to believe the house will be OK. But we don't know. It's tense, but things could be a whole lot worse. There's very little wind. We had plenty of time to prepare, so we managed to get a lot of stuff into our cars. We're together, uninjured, and we have a place to sleep (and shower!) Thanks to everyone who offered help and lodging. I'll write more about this tomorrow, but right now I am beat.

Turn for the worse

The fire turned around overnight. Mandatory evacuations are in effect 100 yards from our house. Fresh layer of ash on the ground, tons of smoke. Need to go make preparations to bug out.

[UPDATE 9:10 AM] Not as bad as I thought. FIre is still slow moving, coming up the canyon one ridge over from us. There's a street between us any any direction the fire could come. If the Santa Anas were blowing we'd be hosed, but they're not so I'm not too worried yet.

[Update 10:08 AM] Mandatory evacuation was just extended to our area. We're bugging out.

Friday, August 28, 2009

The shocking truth about Ezekiel 25:17

Yesteday I took a drive to reconnoiter the brush fires near our house and heard an interview of Quentin Tarrantino by Terry Gross of the NPR program Fresh Air. It was mainly about Quentin's new movie, but at one point she asked him about the scene in Pulp Fiction where Samuel L. Jackson's character, Jules, recites a Bible verse, specifically Ezekiel 25:17. I have long thought that this scene is one of the most brilliantly written scenes in movie history, and it also contains, apparently, one of the best kept secrets. This is what Jules says:

"The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he who, in the name of charity and good will, shepherds the weak through the valley of the darkness. For he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who attempt to poison and destroy my brothers. And you will know I am the Lord when I lay my vengeance upon you."

But Ezekiel 25:17 simply says:

"And I will execute great vengeance upon them with furious rebukes; and they shall know that I am the LORD, when I shall lay my vengeance upon them."

And here are a few of the preceding verses:

"Unto the men of the east with the Ammonites, and will give them in possession, that the Ammonites may not be remembered among the nations. And I will execute judgments upon Moab; and they shall know that I am the LORD. Thus saith the Lord GOD; Because that Edom hath dealt against the house of Judah by taking vengeance, and hath greatly offended, and revenged himself upon them; Therefore thus saith the Lord GOD; I will also stretch out mine hand upon Edom, and will cut off man and beast from it; and I will make it desolate from Teman; and they of Dedan shall fall by the sword. And I will lay my vengeance upon Edom by the hand of my people Israel: and they shall do in Edom according to mine anger and according to my fury; and they shall know my vengeance, saith the Lord GOD. Thus saith the Lord GOD; Because the Philistines have dealt by revenge, and have taken vengeance with a despiteful heart, to destroy it for the old hatred; Therefore thus saith the Lord GOD; Behold, I will stretch out mine hand upon the Philistines, and I will cut off the Cherethims, and destroy the remnant of the sea coast."

All that stuff about shepherds and the path of the righteous man, which is integral to Jules's incongruous (because he is a hit man after all) philosophical analysis in the climactic scene, isn't there. I had always thought that Tarrantino composed those lines, and I was expecting him to reveal this when Terry Gross (who apparently hadn't done her homework) asked, not about this wonderful hoax, but simply how Tarantino came to choose that particular verse.

The answer shocked me: he said that he stole it from another movie! (I forget which one.) So not only had Gross apparently not bothered to look that verse up, Tarantino hadn't either!

This still ranks in my book as one of the great inside jokes in all of moviedom. But I am disappointed to learn that, apparently, it was played on Quentin Tarantino and not by him.

Dodged a bullet

It's about a quarter to ten and we're still here. Looks like we dodged the bullet. But that was as close as I ever want to get.

Got about four or five hours of sleep. Not bad all in all, but I still feel like somethin' the cat dragged in. The air in our neighborhood is stagnant and thick with smoke. There is a thin layer of ash covering everything outside, and though our house is pretty well sealed, the smoke has started to seep in through the chimneys. (They are gas fireplaces, so they don't have regular flues that you can close.) We had to abandon the mater bedroom last night and sleep in the guest room because of the smoke (note to self: never build a house with a fireplace in a bedroom), but I'll take a smoky house over a burned-down one any day.

An acquaintance of ours lost his house to a brush fire a few years back. He was a volunteer fireman, so he knew all the right things to do, and he did them all, and he still lost his house. It turns, unsurprisingly, that it's all about the wind. If the wind is blowing a brush fire in your direction you are absolutely fucked. So I am profoundly grateful for the stagnant air. This could have been much, much worse.

[Update at 10:15] Seems I may have spoken too soon. I just turned on the TV. The fire is apparently still heading closer to town. 800+ homes have been evacuated, presumably in the neighborhoods just east of us. So it's not over yet.

Ironically, the best coverage of the fire is on the local Fox News station, and it's none too good. It's amazing how much TV news reporters can talk and how much footage they can show without conveying any actual information. But every now and then they pull out into a wide shot from a helicopter that shows us exactly where the fire is, which is, of course, the main thing people want to know. Someone needs to figure out a way to track a fire in real time.

[Update at 11:00] The latest info from the LA Times seems to indicate that the fire is moving north, which is to say, away from us. The official word as of 6AM was "no structures immediately threatened."

[Update at 12:00] The smoke has dissipated a bit, so I went outside and shot a couple of photos:







Believe it or not, that's looking a whole lot better than it has for the last eighteen hours or so.

[Update 3:20PM] It has been a tense afternoon as the fire moved east to west across the ridge behind our house, but it now definitely looks like it will pass us by. Weather conditions seem to be improving a bit as well. I'm starting to relax a little.

Thanks to everyone who called and emailed to express their concern and offer help. It was very much appreciated.

Thursday, August 27, 2009

Going to be an interesting night

The Station Fire is burning about a mile from our house. They've apparently started to evacuate some of the nearby neighborhoods. We've started packing up some things, staging the fire pump by the pool. Probably not going to get a lot of sleep tonight. Thankfully, there's not a lot of wind or we'd probably be toast (a little dry humor for the occasion).

Pray for us. It can't hurt. (Update: and for the folks down in Rancho Palos Verdes. They seem to be in much worse shape down there than we are.)

[Update at 11:32] Just heard on the news that there are no mandatory evacuations yet, and there are still a couple of canyons between us and the fire. Still no wind. So we're OK for the time being.

[Update at 11:49] Never really had to think seriously about what to save if the house burned down. We have a ton of stuff. Most of it is replaceable, but a lot isn't, and a lot of what isn't replaceable is heavy (photo albums) or awkward (we have a ton of art). How much of it should we try to save? How paranoid should we be? Should we go ahead and load it all into our cars? What about the stuff that just has sentimental value, like my AdWords Launch lava lamp, or the stuffed gorilla from the "gorilla marketing" campaign from two startups ago? Should we take clothes? Toothbrushes? Happily, all this still appears to be academic at this point. But the glow of the fire is clearly visible over the ridge line behind our house.

[Update at 1:00 AM] I think we've done all we can to prepare, and everything seems quiet outside, so I'm actually going to try to get some sleep.

Sunday, August 23, 2009

Global variables done right

If you've read my Idiot's Guide to Special Variables you will already know that I am not a big fan of the design of Common Lisp's global variables system. There are (at least) three problems with CL's design:

1. There are no global lexicals.

2. DEFCONSTANT doesn't actually define a constant, it defines a global variable with the less-than-useful property that the consequences of attempting to change its value are undefined. Thus, a conforming implementation of Common Lisp could expand DEFCONSTANT as DEFVAR. (I am, frankly, at a loss to understand why DEFCONSTANT was even included in the language. As far as I can tell there is nothing that you can do in portable CL with DEFCONSTANT that you could not do just as well with DEFINE-SYMBOL-MACRO.)

3. There is no way to declare a global variable without also making the name of the variable pervasively special. In other words, once you've created a global variable named X it is no longer possible to write new code that creates lexical bindings for X. It is, of course, still possible for code evaluated before X was declared special to create lexical bindings for X. IMHO this is just insane. The only reason for this design is for backwards compatibility with code written for dynamically scoped dialects of Lisp. Well, guess what, folks. It's 2009. There are no more dynamically scoped dialects of Lisp. (Well, there's eLisp, but it lives safely sequestered in its own world and can be safely ignored by rational people.) And if you're still unconvinced that Common Lisp's pervasive special declarations are a bad design, consider the rule that all global variables should have named that are bookended by asterisks. Any time you need to impose a rule like that on your programmers, your language design is broken.

Fortunately, the situation is not all that hard to remedy. All that is needed is to implement the hypothetical L-LET and D-LET constructs from the Idiot's Guide, and to provide a way to declare global variables in a way that doesn't make them globally special.

Ladies and Gentlegeeks, I give you Global Variables Done Right:




(defun get-dynamic-cell (symbol)
(or (get symbol 'dynamic-cell) (setf (get symbol 'dynamic-cell) (copy-symbol symbol))))

(defun dynamic-value (symbol) (symbol-value symbol))

(defmacro defv (var val)
"Defines VAR to be a global dynamic variable with initial value VAL"
`(progn
(setf (symbol-value ',(get-dynamic-cell var)) ,val)
(define-symbol-macro ,var (dynamic-value ',(get-dynamic-cell var)))))

(defmacro dval (var)
"Returns the current dynamic binding of VAR, even if there is a lexical binding in scope"
`(symbol-value ',(get-dynamic-cell var)))

(defmacro dlet (bindings &body body)
"Unconditionally create new dynamic bindings"
(if (atom bindings) (setf bindings `((,bindings ,(pop body)))))
(let* ((vars (mapcar 'first bindings))
(dvars (mapcar 'get-dynamic-cell vars))
(vals (mapcar 'second bindings)))
(dolist (v vars)
(let ((e (macroexpand v)))
(if (or (atom e) (not (eq (car e) 'dynamic-value)))
(error "~A is not a dynamic variable" v))
(if (eq (car e) 'non-settable-value) (error "~A is immutable" v))))
`(let ,(mapcar 'list dvars vals) (declare (special ,@dvars)) ,@body)))

(defun get-lexical-cell (sym)
(or (get sym 'lexical-cell) (setf (get sym 'lexical-cell) (copy-symbol sym))))

(defun non-settable-value (s) (symbol-value s))
(defun (setf non-settable-value) (val var)
(declare (ignore val))
(error "~A is immutable" var))

(defmacro defc (var val &optional force-rebind)
"Immutably binds VAR to VAL. If FORCE-REBIND is T then VAR is forcibly rebound."
(let ((cell (get-lexical-cell var)))
`(progn
,(if force-rebind
`(setf (symbol-value ',cell) ,val)
`(unless (boundp ',cell) (setf (symbol-value ',cell) ,val)))
(define-symbol-macro ,var (non-settable-value ',cell)))))

(defmacro deflexical (var val)
"Defines VAR to be a global lexical variable"
(let ((cell (get-lexical-cell var)))
`(progn
(setf (symbol-value ',cell) ,val)
(define-symbol-macro ,var (symbol-value ',cell)))))

(defmacro lval (var)
"Unconditionally returns the global lexical binding of VAR"
`(symbol-value ',(get-lexical-cell var)))




The best way to show what this code does is with an example:




? (defc constant1 "Constant value")
CONSTANT1
? (setf constant1 "Can't change a constant")
> Error: CONSTANT1 is immutable
> While executing: (SETF NON-SETTABLE-VALUE), in process Listener(6).
> Type cmd-. to abort, cmd-\ for a list of available restarts.
> Type :? for other options.
1 >
? (defc constant1 "Can't change a constant value, take 2")
CONSTANT1
? constant1
"Constant value"
? (defc constant1 "Can rebind a constant by specifying FORCE-REBIND" t)
CONSTANT1
? constant1
"Can rebind a constant by specifying FORCE-REBIND"

? (defv v1 "Global dynamic variable")
V1
? (deflexical l1 "Global lexical variable")
L1
? (defun test1 () (list v1 l1))
TEST1
? (test1)
("Global dynamic variable" "Global lexical variable")
? (let ((v1 1) (l1 1)) (list v1 l1 (test1)))
(1 1 ("Global dynamic variable" "Global lexical variable"))
? (dlet ((v1 "Dynamic binding 1") (l1 "Dynamic binding 2")) (list v1 l1 (test1)))
("Dynamic binding 1" "Dynamic binding 2" ("Dynamic binding 1" "Global lexical variable"))
? (let ((v1 1)) (list v1 (dval v1)))
(1 "Global dynamic variable")
? (let ((l1 1)) (list l1 (lval l1)))
(1 "Global lexical variable")

; Watch this trick!
? (deflexical v1 "New global lexical binding for what was a dynamic variable")
V1
? (defun foo () v1)
FOO
? (let ((v1 1)) (list v1 (dval v1) (lval v1) (foo)))
(1 "Global dynamic variable" "New global lexical binding for what was a dynamic variable" "New global lexical binding for what was a dynamic variable")
? (dlet ((v1 1)) v1)
> Error: V1 is not a dynamic variable




Things to note:

1. The design is completely orthogonal. In fact, a single variable can have a local lexical binding, a global lexical binding, and a dynamic binding all at the same time, and all of which are accessible in a single scope. No more pervasive special declarations. (In fact, no more special declarations at all. They are replaced with the DLET macro.)

2. Constants are enforced to be immutable unless this is explicitly overridden by specifying FORCE-REBIND to be true.

3. Because the design is orthogonal, it is actually a design choice whether dynamically binding a global lexical should be an error. There is no reason why this couldn't be allowed to proceed, to create a dynamic binding that could then be accessed (only) via the DVAL macro. But I decided that although it's possible to have both global lexical and dynamic bindings for the same variable at the same time, it's probably not a good idea.

Thursday, August 20, 2009

Tipjoy RIP

TipJoy is shutting down. Bummer. I was really hoping they would make it.

AT&T Is A Big, Steaming Heap Of Failure

I'm stealing my headline from MG Seigler because I can't think of any better way to put it. I found out the hard way today that my iPhone voice mail has been down for several weeks, that AT&T has known about this, that they have not been able to fix it, and worst of all, that they didn't bother to let their customers know. This is a failure of staggering proportions. When I finally got caught up on all my voice mail messages it turned out that I had missed some really important ones, including a reminder from my mom to call my dad on his birthday (which I actually did forget to do -- sorry Dad!) God only knows what important messages other people having this problem may have missed.

Honestly, Apple and AT&T, it's not like this is some obscure feature that no one ever uses, this is absolutely central to the fundamental function of a phone nowadays. And how hard can it possibly be to fix?

Wednesday, August 19, 2009

The Quantum Mechanics Mystery Conspiracy

There is a long-standing problem in physics concerning the flow of time. All known physical laws -- except one: the second law of thermodynamics -- are "temporally symmetric" that is, they operate equally well whether time is flowing forwards or backwards. Take a movie of any physical phenomenon and run it backwards and everything you see will be consistent with physics. But the Second Law is not really a fundamental law, it is just the statement of the empirical observation that time seems to flow in one direction and not the other, so the deeper question of why this should be so has remained a mystery.

Actually, it's not mysterious at all once you get past the quantum-physics mystery conspiracy, which insists on presenting QM in false and misleading terms. In particular, the QMMC focuses on measurement and entanglement as if they were two distinct physical phenomena, one simple and familiar, the other alien and inscrutable. In fact, measurement and entanglement are one and the same physical process. Once you realize this, the answer to the arrow-of-time "dilemma" becomes obvious: time appears to flow in one direction because the perception of the flow of time relies on the formation of records of "past" events, which is to say, the formation of classical information, which requires "measurements", which requires particles to become entangled with each other. It is possible to reverse this process, but only by bringing all the particles in an entangled ensemble physically together, which is possible in principle but not in practice. (See section 5.4 in the link above for more details.)

This result has recently been (re)discovered by a card-carrying physicist.

It's really starting to annoy me how many physicists get press by making these kinds of "breakthroughs". All this stuff was figured out in the mid-90's. You'd think that now nearly fifteen years on the word would have gotten out, but it hasn't. It's really kind of weird. I seriously doubt that there's a conscious QM Mystery Conspiracy, and yet here we are. Why people should still be scratching their heads about the arrow of time and "spooky action at a distance" in 2009 is the biggest mystery of all.

Friday, August 14, 2009

The New Atheists are a Disaster

So says Michael Ruse. I'm not sure I'd go quite so far as "disaster", but I certainly sympathize with the general sentiment.

Best health care system in the world, part II

I reported earlier about my recent adventures with America's "best health care system in the world." I can't imagine how all the right-wing fear-mongering about rationing and long waits can possibly be effective on anyone who has actually had to use our current health care system for any actual care, because I can tell you from first hand experience that unless you are rich (and sometimes even if you are rich) we already have rationing and long waits.

My PCP (primary care physician) read my blog and ran interference for me to get me in to see the dermatologist ahead of the queue. I was told that they didn't pull and strings, that there just happened to be a cancellation the next day, but I have no way of knowing if that was actually true. They may have just been telling me that because I specifically asked them not to pull strings. Either way, the fact that I got in early can't be counted as a victory for the system. At best, I got lucky. At worst, I got bumped to the head of the queue because I can afford to pay extra for access to a PCP who has enough free time to do things like read his patients' blogs.

At the dermatologist, I learned the following:

1. I almost certainly don't have cancer, but it's not a total slam-dunk. They told me to come back in three months for a followup just to be sure.

2. I was not waiting in line behind possible melanoma cases. I was waiting in line behind dermabrasions, botox, and facial hair removal.

So I believe it's fair for me to chalk up my experience as support for those who say that the present system is at least partially broken.

IMHO, the fundamental problem is that health care is (or at least ought to be considered) infrastructure, and free markets don't do a good job at providing infrastructure. I am a born-again capitalist. I believe in free markets, not for ideological reasons, but because empirically they tend to produce a net benefit for the well-being of mankind more effectively than any other system than has yet been invented. But free markets are not without their problems, and so various degrees of government regulation are needed to keep them performing their function even under the best of circumstances. If nothing else, government is needed to enforce contracts and discourage fraud. But even then, free markets work better for some goods than for others. They are really good at producing technology, commodities, and luxury goods. They are not so good at providing infrastructure. The U.S. is currently conducting an experiment at using free markets to provide wireless communications infrastructure, and the result is cell phone service that is not only universally crappy, but five times more expensive than anywhere else in the world. By way of contrast, the Internet, interstate highways, and the (wired) phone system are all cheap and reliable, and all are the result of government intervention of one sort or another.

I think health care ought to be treated as infrastructure. It's something everyone needs sooner or later, and it has a very long lead time to produce. Our current government-run health care plans, medicare and medicaid, work well enough to make them sufficiently popular that no politician dares to even suggest eliminating them. There are certainly ways in which government interference can go too far. Mandating centralized electronic record-keeping, for example, is an absolutely terrible idea. But opposing *any* government interference in health care because of possible abuses and inefficiencies is IMO throwing the baby out with the bathwater. The debate we ought to be having is not *whether* but *how* government should be participating in our health care system, because the system we have now is b0rken.

Tuesday, August 04, 2009

Best health care system in the world (as long as you're healthy)

It dawned on me today that the reason so many people support the current health care system in the U.S. is that it actually works pretty well as long as you don't actually need any care , which is true for most of the people most of the time.


In late April, Shelly Andrews-Buta was scheduled to undergo treatment for breast cancer that had spread to her brain, threatening her life.
...
But instead of having doctors working to remove her brain tumors on the day the surgery was scheduled, she sat in a San Francisco hotel room. Why? Because at the last minute, her insurance company, Blue Shield, decided it wasn't going to pay for the treatment her doctors at UCSF Medical Center had recommended.


I've actually had a personal experience with our wonderful health care system recently: I had a small skin lesion that wasn't healing up, so I thought it might be a basal cell carcinoma. My primary care physician referred me to a dermatologist, but the earliest appointment I could get was over a month away.

The fundamental problem with our current system is that it produces a perverse incentive to deny care. For an insurance company, all else being equal, the less care you provide the more money you make. So the insurance companies are strongly incentivized to provide as little care as possible without actually pushing people so far over the edge that they get motivated to change the system (and you can't get much more unmotivated then being dead). Hence the endless repetition of the "best health care system in the world" mantra: if you can convince people that this is true, then agitating for change becomes downright unpatriotic.

It is also ironic that it is exactly the same flawed logic that makes people fall for this con that makes them need insurance to being with: no one thinks they're going to get sick until they actually do. By the time they get into a situation where they really need medical attention and discover firsthand how b0rken the system actually is, it's usually too late for them to do anything about it. Which is, of course, exactly how the insurance companies like it.

Saturday, August 01, 2009

HTML is object code

Fate seems to be sending me a pretty clear message that my life's destiny lies in moderating discussions on the merits of CSS (240 comments and counting). Despite the fact that the argument seems to be going around in never-ending circles, and I've made several attempts to shut the discussion down, it just doesn't seem to want to die. When the market sends such clear signals, the thing to do is to ramp up production to meet demand. Hence, another essay on Tables vs. CSS. Pardon me a moment whilst I don my asbestos suit.

Whenever an argument among otherwise reasonable people turns intractable it is usually because both sides have overlooked something really fundamental, and I think this is the case here. The fundamental thing that both sides have overlooked in this case is that HTML is (or at least should be considered) object code. Let me explain what I mean by that.

Consider a hello-world program written in C:



main() { printf("Hello world"); }



Of course, this is not really a hello-world program. To get the "real" program you have to compile the above "source" code into "object" code, which looks more like this:



0000000 ce fa ed fe 07 00 00 00 03 00 00 00 02 00 00 00
0000010 0c 00 00 00 c0 03 00 00 85 00 00 00 01 00 00 00
0000020 38 00 00 00 5f 5f 50 41 47 45 5a 45 52 4f 00 00
[and so on for 12,588 bytes]



But now consider this:



0000000 6d 61 69 6e 28 29 20 7b 20 70 72 69 6e 74 66 28
0000010 22 48 65 6c 6c 6f 20 77 6f 72 6c 64 22 29 3b 20
0000020 7d 0a



Is that source code or object code? (Before you go on, take a moment to think seriously about what you think the answer is and, more importantly, why you think that's the answer.)

Here's a clue. Try this:



echo 'main() { printf("Hello world"); }' | hexdump



So if you said, "It's object code, because it looks like object code" you are wrong. But if you said "It's source code because it's just the hexadecimal representation of a C program" you are also wrong. The right answer is it's both. Yes, it's the hexadecimal representation of a C program. But just because it's C code doesn't necessarily mean it's source code. C is often used as an intermediate target language for compilers of other languages like Scheme. And Scheme can be used as an intermediate representation for other languages, like Qi. (Qi actually compiles to Common Lisp, but it's the same idea.)

Now consider this:


<html><div id="top">Hello world</div></html>



Is that source code or object code? In other words, is that code that a coder writes, or code that a compiler emits? Hopefully by now you realize that the answer is: it can be both.

I think a lot of the arguments against using tables for layout rely on the tacit assumption that HTML is source code. For example, one of the arguments against tables is that they fail to separate layout information from content. But this assumes that HTML is source code, and that the combination of content and layout information must be done in the browser. Neither of these assumptions is correct. I can create a layout as an html template:



<table>
<tr><td colspan=3> %header
<tr><td> %leftnav <td> %center <td> %rightnav
<tr> <td colspan=3> %footer
</table>



and combine this with separate content information on the server. Now my layout and content are completely separate, and yet I'm still using tables, and so I get the advantages of the simplicity and uniformity of cross-browser table rendering. Plus, my layout is only five lines of code. And it doesn't need Javascript. And it's going to look reasonable no matter what my content turns out to be.

IMHO, no one should ever write any HTML by hand. HTML should be considered exclusively as object code, except for the most simple of quick-and-dirty hacks. The idea that HTML can (or even should) be considered source code is the root of many evils on the Web. The right way to create web pages is by building higher-order abstractions in a programming language (preferably functional ones, but I'm not dogmatic about that).

Nowhere is this clearer than when it comes to forms. Even CSS advocates concede that it's OK to put form elements in tables. They say it's because "forms are a kind of tabular data, and that's what tables are for", but this just begs the question of how one can tell if a particular set of data is tabular or not. (Apparently, the criterion is: it's tabular data if it's completely hopeless to make it not look like crap when layed out with CSS.) But the trouble with forms goes far beyond layout. Consider the following:



<form method="GET" action="date-foo">
Enter the date:
<input type="text" class="dateinput" name="date">
<input type=submit>
</form>



Simplistic to be sure, but nothing offensive to the W3C standards. Now imagine a site that has this form and others like it throughout, and we want to augment our date input fields with a little javascript calendar widget. According to the philosophy of CSS we should be able to write:



.dateinput { ... }



but of course we can't, because the semantics of CSS are so hopelessly impoverished that the mere suggestion of doing something like this is probably enough to send CSS advocates into conniptions. (Any minute now, ChristianZ and Pherdnut will start to rant about how I Just Don't Get It (tm), and I need to study harder.)

But if we combine content and layout (and even style I might add) on the server, we can write:



<standard-form>
<date-input label="Enter the date">
</standard-form>



or something like that. Then we write a program that "compiles" this little private HTML-ish web page description language down to actual HTML for delivery to the client. Now changing all the date inputs to use a javascript widget is trivial, because we really have separated style from content, and we have done it in a way that is vastly more expressive and powerful than CSS.

There is only one argument for using CSS for layout that this approach does not completely demolish, and that is accessibility. CSS advocates argue that tables impede the rendering of web content for non-visual media. I think that's debatable, but even if it's true, it's irrelevant because there is no reason why the same content has to be rendered the same way on the server for all clients! This again assumes that HTML is source code, and you so you don't want to have different HTML for different clients because that would make extra work and violate the DRY (don't-repeat-yourself) principle. But HTML need not be source code. The source code can be a higher-level representation, and that higher-level representation can be rendered in different ways for different clients. For example, imagine a world where the client said to the server, "Give me web page FOO, and oh by the way, my user is blind" and what came back from the server was not HTML at all but an audio file. Now blind users wouldn't even need a special client! All they would have to do is configure a standard browser with a custom header to indicate blindness, and they're off to the races.

Separating styling and layout information from content is a great idea. But requiring that the rendering of those separate pieces be done on the client exclusively is overly restrictive because it requires that the kinds of combinations that can be done be standardized. It is that assumption that leads to the religious wars over CSS, not the merits or drawbacks of CSS per se. Whatever the standard is, it's either Turing-complete or it's not. If it's Turing-complete, you might as well just use Javascript (with all of its attendant problems) and if it's not, there will always be something that someone will want to do that's not possible. The answer is to cut the Gordian knot, treat HTML as object code, and do (at least part of) your rendering on the server. That way no one has to argue about anything. (Not that I expect that to stop anyone.)