Thursday, February 25, 2010

A long series of posts

I was arguing recently that it was important for programs to have semantics. Would someone dispute this? Apparently so. Therefore, I started a series of Socratic arguments. I never finished it, but maybe I'll finish it here in my blog.

Let me start with something extremely simple:
(define (factorial x)
 (if (< x 2)
     1
     (* x (factorial (- x 1)))))
and I ask the question to my hypothetical students “What does this mean?”

Student A says “No computer program can ever have a meaning. Someone could redefine *, or shadow if, and make any answer incorrect.”

Student B says “I don't know, but the computer says ”

 (fact 0) => 1
 (fact 1) => 1
 (fact 2) => 2
 (fact 3) => 6
 (fact 4) => 24 ...
Student C says “It defines FACTORIAL as a recursive program that computes the factorial function for positive integer arguments.”

How do you grade these answers, and why?

Monday, February 22, 2010

Unbelievable

How's that Scheme working group doing?
  • defmacro nostalgia? — check
  • case sensitivity sensitivity? — check
  • first-class environments? — check
  • FEXPRs re-exhumed? — check

Friday, February 5, 2010

A Wacky Idea

All computer languages should come with a fully parenthesized API to their syntax tree.

The semantics of other languages are nasty enough. Having to deal with quirky syntax is just rubbing salt in the wound.

Furthermore, the language reader and pretty-printer should be break-out modules that can simply be imported and linked. I'm getting sick of writing parsers just because I can't trivially hijack an existing one without bringing in the entire compiler.

Wacky idea #2: A standalone syntax-rules preprocessor could be used on the parenthesized syntax tree. This would give the language a nice hygienic (lexically scoped) macro system with no work on the language implementor's part. (The preprocessor would have to know what the native binding forms are and how to distinguish identifiers from keywords.)

Thursday, January 28, 2010

High and dry

A few weeks ago Douglas Gregor wrote to me to ask:

How does someone break out of a dry spell? How do you remain focused on things? I'm sure you have many things going on simultaneously, so do they raise and fall in priority? How does work affect your focus? Is work a downer or an upper? I need to figure out how to break out of the funk. Do you have any hobbies other than computers? Where can I find smart people who want to do amazing things? Do they still exist out there?
I've been feeling in a dry spell myself for a couple of months, but I might be coming out of it, so I thought I might try answering a few of these questions.

How does someone break out of a dry spell?

I wish I knew a reliable, predictable way to do that. It may be that you just have to wait it out. It is frustrating, but these things happen. On the other hand, dry spells do eventually end. I try these tricks:

  • Relax — worrying and fretting just make it seem longer.
  • Have some mindless, non-intellectual fun. I'll watch television or play some video games. The activity is distracting enough so that I'm not thinking about the dry spell, but not so engaging that I'm not thinking at all. It lets my mind wander a bit.
  • Sometimes it isn't really a dry spell. There's something you want to do but you can't justify the effort or the reason. You want to redesign the entire system, but your assigned task is to fix 5 high-priority stupid bugs. Be irresponsible. Start the system redesign. A brand new system won't have those bugs, right?
  • Revisit a fun project from the past. I love Lisp machines and operating systems and I know I have fun with them. When I'm trying to think of something to get my creative juices flowing I aim my thoughts in this direction.
  • Work on something completely outside your field. I went down to the local community access television station, learned how to make and edit some video, and made a few music videos for local bands several years back. You can find interesting ways to think about things by looking at how people solve problems unrelated to computing. (You'll also find some amazingly obvious applications for simple computer programs that no one has noticed before.)
  • Go out and meet people. A few of the regulars that hang at the pub that I frequent are building a dirigible. I'm not entirely convinced that this is a good idea, but it is an interesting one.
  • Do something wacky. Whether it succeeds or fails, you'll get a good story out of it.

How do you remain focused on things?

I really don't. If it's a hard or interesting problem, then I tend to obsess on it until I get it. If it is a boring problem, then it depends. If it isn't too tedious, I just do it. If it is more than a little tedious, then I try to get my computer to do it. If it is tedious, boring, and not amenable to a software solution, well, I might just lame out or blow it off. If possible, I'd delegate it to someone who found it more interesting. I've never been able to force myself to focus, though.

I'm sure you have many things going on simultaneously, so do they raise and fall in priority?

All the time.

How does work affect your focus? Is work a downer or an upper?

That depends, too. For me, work has to be an upper. This isn't a ‘lifestyle choice’; it's a simple observation. When I'm working on something interesting and challenging I'll put in hours of overtime and drive the project forward. When it's uninteresting I'll either get pissed off and quit or get fired within a few months. But I've also found that whether work is interesting or not depends a fair amount (but not completely!) on whether you can find the interesting parts of it. Recently I was working on a rather mundane problem of estimating market penetration of a particular product. It's relatively easy to get the Forrester or Gartner report on such things, but is there any way to verify the accuracy via an independent measurement? It turns out that if you have access to certain statistics about the web, you can do some analysis to find the right information. The statistics were plentiful, but the analysis was intractable, so I had to learn how to manipulate the data and extract the answers to the questions I had. Market research: boring. Data mining: really interesting!

Do you have any hobbies other than computers?

Film and cinema, reading, history, skiing, blacksmithing, people watching, and hanging at the pub and talking.

Where can I find smart people who want to do amazing things? Do they still exist out there?

They do! But you might have to go looking. A bigger city is going to have a lot more possibility than a smaller town (even in this day where everyone is on line). Boston and San Francisco are just overflowing with a number of smart people doing all sorts of crazy things. Go to a conference or submit a paper. I meet a lot of interesting people that way. Be a bit eccentric and attract interesting people.


Ob scheme/lisp: I'm working on a problem that I don't quite understand yet, so this is a good opportunity to blog about it. I should have an upcoming post in a bit.


Friday, December 11, 2009

Simple Sabotage

A co-worker forwarded to me a copy of the OSS Simple Sabotage Field Manual. I have reproduced the section on organizational sabotage. It is hilarious, but frightening how many companies that I have worked for seem to follow such self-destructive advice on purpose!

Sunday, December 6, 2009

It seems the problem with apropos was a simple missing argument. I haven't hooked up the error handler yet, so this caused some really weird behavior. It's getting time to think about that. The MIT Scheme debugger uses some special operations to parse the runtime stack, so I have to make a reasonably faithful replication of this.

Friday, December 4, 2009

Innumeracy

I happened upon an article discussing glacial retreat and ice melt. At the end of the article there were several ‘glacial facts’. Here are some:
  • Average yearly retreat of the Himalayan glaciers: In 2006, 30 metres;
  • Rate at which Gangotri is melting per year: 28.1 m
  • Gangotri Length: approx 30 km;
  • Year in which Gangotri will disappear: 2050, if glacier melt continues at the same rate.(emphasis mine)
There is an obvious problem here. 30 meters per year times 50 years (1500 meters) is nowhere near the entire length of the glacier (30000 meters). It's a factor of 20 too small. This isn't a rant about climate change, it's a rant that the journalist and the editor didn't notice the problem with the math. I wouldn't expect that the journalist or the editor be wizards at calculus, but this is just a simple estimate. You don't even need an exact answer (I rounded up the melting rate and the time span to make it easy to multiply).