death and taxes

I can’t help feeling haunted about the deaths in yesterday’s shooting. The shooting itself makes no sense to me.

I can appreciate that people are trying to find meaning in the murderer’s actions, trying to blame video games, or psychotic drugs, or jealousy, or divine retribution. It can’t all be random, can it?

I suppose there’s a story about the murderer that remains to be told, the motives and the exposure of lurid, petty details. Still, he is meaningless to me.

I do see clear meaning in the actions of people like Liviu Librescu. How gloriously different are the saints. I’d rather think about Professor Librescu and the others like him, who faced death with courage, teaching one final lesson: “Love is stronger than death.” Another one of those lessons that I’m trying to believe.

cyberdyne

I went to the NEPLS conference at Tufts University on Wednesday. It was a lot of fun; I got to hear programming language theory talks and meet with other people interested in the same sort of crazy things that pull my attention. I did like Dave‘s talk: the idea of collapsing idempotent type checks to preserve space seemed perfectly reasonable. I wonder if any of that will trickle back into PLT’s contract system.

The last presentation, on Spatial Computing, was especially fascinating. At a first glance, it seemed ridiculous, and the scope of the project so breathtakingly absurd. I clamped my hands over my mouth to muffle my giggles. But as the speaker presented more and more, the whimsical thought came into to me: maybe this is how Skynet begins.

I hope that I too will someday build something that brings both laughter and pondering thoughts. And I’ll also keep in mind to try avoiding the development of systems that might lead to the creation of bloodthirsty androids.

forgive

It’s one thing to intone in a dull monotony: “Forgive those who trespass against us,” where repetition drains the blood out of a revolutionary and crazy idea. It’s quite another thing to try to put the spirit of forgiveness into real action. Serious forgiveness seems to me something superhuman, and I’m finding it hard to do.

Early Monday, right around 1am, I got taken by a pair of con artists who pretended they needed to make an emergency call outside. I let them use my cell, and when they handed the phone back, I didn’t realize they’d yanked the battery and the SIM chip inside.

Still, I did get the physical phone back, and there wasn’t really much damage, except one night of uneasy sleep and an afternoon buying cellphone components. I should say that I forgive the people who did this to me. A part of me tries doing so, but another part feels that it’s a baldfaced lie, and I catch myself wanting something bad, something karmic to happen to the thieves.

But I think about it some more. Frankly, I got off easy: it could have been a lot more perilous, because the two thieves could have gone after much more than my cellphone. The guy had me in a bear hug at one point, pretending to be thankful. I couldn’t get out of his grip. He could have squeezed me more tightly, and then I would have been in real trouble. So I am thankful and lucky not to have been crushed in this encounter.

If something this insignificant raises my ire, how hard it must be to forgive when people truly hurt each other! It just makes me wonder.

new year

I came in last night from California back into Worcester. I opened my apartment door, half-expecting a nest of mice to scatter. If there were any, I didn’t see them. I fell blissfully asleep. I’ve been sleeping too much lately. Classes start tomorrow, so I suppose that will be remedied.

I’m about to fall asleep again, but before that happens, let me mention DivaScheme 2.1.

Here’s hoping this New Year is a good one!

christmas

Merry Christmas to my family and friends! What I have been gifted with is much more than I expected or deserved. I’m thankful for everyone’s support and love.
I don’t have anything really programming-related to say (because my brain’s fried from debugging DivaScheme).

May your holidays be peaceful and without the need of an exception handler.

the moon

I woke up early on Saturday to catch the airport shuttle. It was one of those hours of the night when everything was still and dark, one of those magic weird moments.

I could see a crescent moon above me, like a sharp scythe. But have I really seen a scythe in real life? The only scythe I know is the one held by a Grim Reaper, and that’s clearly fantastical. I have no practical experience with them. So what else would be a good analogy from my own experience?

The moon looked like a large left parenthesis. As soon as that thought floated in my head, I knew. I was doomed.

Anyway, it’s nice to be in California again.

baking bread

I had the compulsion to bake bread for about a week, but having never done so before, I hesitated. Do I get a bread machine, or buy a few books, or…?

It turns out there is a very nice recipe for newbies like me. I tried it, and it didn’t turn out half bad.

I suppose this is why almost everyone is forced to write a “hello world” program when they start off learning to program. If only “hello world” were more… sustaining.

how not to write xml

I came across Writing XML with Java the other day, and hoped that the authors wouldn’t advocate building XML through plain string concatenations. Unfortunately, they had.

Here’s what the author said to justify this:

Eventually we’ll take up some alternatives to the direct string approach such as DOM and JDOM that do allow you to automatically maintain well-formedness and sometimes even validity. However, for many simple cases, these are vast overkill. It can be much simpler to just write a few strings onto an output stream.

I disagree: maintaining well-formedness should be the computer’s job, not ours, because it it mindless and very easy to get wrong if we do it by hand. Well-formedness is something I shouldn’t have to worry about: it should be trivial to get this right.

The author also said:

Making sure the output is correct is simply one part of testing and debugging your code.

Yes, making sure we’re outputting the right thing is part of a good test suite. But there are some kinds of bugs that just don’t deserve to be out into the open. The most common error I’ve seen in HTML/XML generation is failing to properly quote and escape things. It’s precisely because of this cavalier attitude toward generating structured data that we see such problems.

Here’s the style of code they wrote (translation of Exercise 3.8):


(define (simple)
(printf "<?xml version=\"1.0\"?>~n")
(printf "<mathml:math xmlns:mathml=\"http://www.w3.org/1998/Math/MathML\">~n")
(let loop ([i 1]
[low 1]
[high 1])
(when (<= i 10)
(printf "<mathml:mrow>~n")
(printf " <mathml:mi>f(~a)</mathmi>~n" i)
(printf " <mathml:mo>=</mathml:mo>~n")
(printf " <mathml:mn>~a</mathml:mn>~n" low)
(printf "</mathml:mrow>~n")
(loop (add1 i) high (+ high low))))
(printf "</mathml:math>~n"))


This style of building XML is simple, as the author notes, but it doesn’t scale. As soon as we start dealing with XML documents that have interesting content, we suddenly have to start thinking about HTML injection issues, entity quotation, and keeping those darn tags balanced all the time.

Writing code that treats the XML as real structure is not much harder than the above:


(require (lib "xml.ss" "xml")
(lib "list.ss"))
(define (simple-2)
(define (make-row i low)
`(mathml:mrow (mathml:mi ,(format "f(~a)" i))
(mathml:mo "=")
(mathml:mn ,(format "~a" low))))
(define (make-rows)
(let loop ([i 1]
[low 1]
[high 1])
(cond
[(<= i 10) (cons (make-row i low)
(loop (add1 i) high (+ high low)))]
[else empty])))
(printf "~a" (xexpr->string
`(mathml:math
((xmlns:mathml "http://www.w3.org/1998/Math/MathML"))
,@(make-rows)))))


The difference here is that all the niggling issues from the first example — balancing tags, properly quoting values — don’t apply at all. The XML library takes care of this busywork, as it should. It’s guaranteed to be well-formed.

Not everything has to be treated as a string. We shouldn’t be afraid to play with structured data.

streaky

There’s a peculiar behavior in human psychology where something that catches your attention ends up showing up everywhere. Knuth noticed it in his discussion on randomness. We are pattern matchers: we try to make sense of the world by looking at similarity, at streaks of continuity.

So I was amused to post this and that within the same week.