Sunday, January 31, 2010

Emacs support for Scheme

Here's a nice summary of the various Emacs packages supporting Scheme from Alex Ott. The list includes general packages covering all Scheme implementations as well as packages specific to a single implementation, such as GDS for Guile and Xscheme for MIT Scheme.

Sadly, only Kawa and MIT Scheme have SLIME support.

Sunday, December 13, 2009

The New Luddites, Part 3

The New Luddites have stuck their heads up again. This time it's the Economist whining about information overload in mobile GPS units. The correspondent is, he assures us, a longtime lover and user of maps, but somehow all those curvy lines on the display just overwhelm him. He compensates by dimming the display and just listening to the spoken directions. The barely-below-the-surface theme is that maps have no business being digitized anyway. After all, people have been getting along with paper maps for centuries.

Is this a problem anyone else has? The GPS display seems perfectly clear and informative to me, even without a lifetime love affair with maps. I just don't get it. Every once in a while you glance at the display to see how far it is to your next waypoint. Actually, you don't even have to do that because the GPS unit will warn you in plenty of time.

If the GPS unit overwhelms you, turn the damn thing off and use paper maps or your memory or whatever. Just leave the rest of us in peace. Please.

Thursday, December 10, 2009

Proof That Book Publishers Learned Nothing from the Music and Movie Industries

Saturday, December 5, 2009

Rewire Redux

A few posts ago I ranted about gave a carefully reasoned analysis of an article about how computers were destroying our brains or something. Now Cory Doctorow makes the same points in a slightly different context. He even mentions the old “calculators are destroying our ability to do math” silliness and explains why that argument is not just wrong but the actually misses the point that by liberating us from spending years developing a facility to do arithmetic in our heads we are free to learn to think about mathematics at a more abstract and useful level.

The link takes you to an 11 minute video interview of Doctorow that is well worth your time. Doctorow's main thesis is that technology frees us from worrying about many of the mechanical details of writing and mathematics and allows us to concentrate on their more important aspects.

Friday, December 4, 2009

Another Slime for Vim

Over at Jonathan's Techno-tales Jonathan Palardy writes about using Vim for Lisp programming. His idea is to emulate some of the Slime functionality by using Gnu Screen to help communicate between the REPL and the Vim editing buffer. He's written a Vim plugin to automate the process but you don't need that to try the process out.

It's a nice hack but doesn't have anywhere near the functionality of Slime. Still, if you're a committed Vim user and program in Lisp this may be a good solution for you. The same technique should work with any language that uses a REPL-like mechanism.

Sunday, November 22, 2009

The CRU Files

This is not a political blog so I have nothing to say here about the ethics of the hackers who broke into the CRU network, downloaded 60–70 megs of files and emails, and posted them on the Internet. I also have nothing to say about whether Anthropogenic Global Warming is real or not because (1) I don't have the necessary scientific knowledge to make an informed decision, and (2) again, this is not a political blog and the AGW debate has, it seems to me, devolved into a political question. Finally, we should be clear that the files and emails have not been verified to be authentic although several have apparently been corroborated and no one, to my knowledge, has disputed the authenticity of any of the files or emails.

What I want to discuss is the shocking betrayal of science and the search for truth that these emails reveal. If the emails are genuine then their authors have forfeited any right to call themselves “scientists.” Rather, they are revealed as agenda driven politicos and particularly nasty and small minded ones at that.

The details are all over the Internet (see here or here for example) so I won't bother rehashing them but it's all there: gloating about the death of a rival, cooking the books on their data and then refusing to release raw data so that it could be verified, conspiring to evade (at least) the spirit of the UK Freedom of Information act, deleting incriminating emails, plotting to prevent skeptics from getting published, and more.

Again, it's possible that some of the more incriminating emails are fabrications, although no one is saying this, and they may well be taken out of context, but if they turn out to be genuine then the actions of the principals are shameful and they should be removed from their positions and no longer be treated as members of the scientific community.

Monday, November 16, 2009

Help! Help! My brain is being rewired

I usually ignore twaddle such as this, but really, enough is enough. The new Luddites are at it again wailing about how spell checkers and contact lists are destroying our ability to remember and process details. I'm old enough to remember the exact same arguments being used against calculators: “Oh my gosh, pretty soon people won't be able to add two numbers.”

And you know what else? Some college students actually text each other during lectures. One wonders why their minds are wandering. There's even a line about “BART riders reaching furtively into their pockets thinking their iPhone has vibrated—even if it hasn't.” The horror, the horror!

The article goes on and on like this and so could I, but why bother? We've heard it all before and in a few years no one will remember or care about these doomsday predictions. Go read the article if you must, but it will probably be a better use of your time to check out your favorite Twitter feed.

UPDATE: Sadly, this sort of nonsense is nothing new.

Sunday, November 15, 2009

Compiling DSLs

Recently I had occasion to revisit this post from Peter Seibel's blog about compiling queries in Lisp. It's a cliche in the Lisp world that “if you're using eval, you're doing something wrong.” A more helpful formulation is, “if you're using eval, you should probably rewrite your code to use macros instead.” This is generally good advice—see here for some contrary examples—but it does not tell the whole story; that's where Seibel's post comes in.

Seibel considers the problem of a DSL for performing simple keyword queries on a block of text. He gives the example

(or
 (and "space" "mission")
 (and (or "moon" "lunar") "landing"))

which tests whether the text contains the words space and mission, or moon and landing, or lunar and landing. It's pretty easy to translate the above into a Lisp expression such as

(or
 (and (word-in-string-p "space" text)
      (word-in-string-p "mission" text))
 (and
   (or (word-in-string-p "moon" text)
       (word-in-string-p "lunar" text))
   (word-in-string-p "landing" text)))

where word-in-string-p returns t if the first argument is a substring of the second and nil otherwise.

The next problem is to evaluate this expression. The naive way to do this is to pass it to eval, and you know what? The earth will still be orbiting the sun if you do. But Seibel goes on to show us a better way and to illustrate why the prejudice against eval is usually well-founded.

Instead of invoking eval, we turn the above expression into a function

(lambda (#:G1)
 (or
   (and (word-in-string-p "space" #:G1)
        (word-in-string-p "mission" #:G1))
   (and
     (or (word-in-string-p "moon" #:G1)
         (word-in-string-p "lunar" #:G1))
     (word-in-string-p "landing" #:G1))))
where the #:G1 is a gensym'd symbol. Now an immediate advantage of

this is that we have a function that we can pass to some other function or otherwise use in any of the ways that Lisp's first class functions can be used. This means that it can be called over and over again on a series of text blocks (the original problem is posed in terms of a database query). The key here is that we can take this function and compile it using compile-expression so that (for systems that support native compilation) we have a fast implementation compiled to machine language.

Notice that we're not talking about much more work than using eval. We merely have to wrap the code in the lambda form and then call compile-expression rather than eval. Seibel's got all the code in the post I linked above, so you should go take a look at it.

Tuesday, November 10, 2009

MobileOrg!

The remote Org mode application for the iPhone that I've written about previously is finally available at the AppStore. I've downloaded the app to my iPhone, but still have to set up the WebDAV server for syncing data to and from the iPhone. I'll write more when I have things fully configured. In the mean time, get over to the MobileOrg Website and marvel at Org mode on the go.

Thursday, November 5, 2009

Tail Calls

I saw this post from Tim Bray at ongoing the other day and thought it was pretty silly. I was going to comment on it but decided that Bray is a serious and knowledgeable guy who is entitled to his opinion even if anyone with functional programming experience might find it snort-worthy.

Along comes Ezra Cooper at Ezra's Research with a response to Bray. It's too good to pass up and says everything that I wanted to say only better. He also points out that “tail-call optimization” is a misnomer. I liked that because the tail-call optimization nonsense has always annoyed me.

Cooper's blog has a lot of juicy content, so it's worth taking a look at even if you have no interest in the tail-call contretemps.