Wednesday, June 28, 2006

emacs / DrScheme keystroke of the day: kill!

C-M-k: kills the s-expression to the right of the cursor point. This is really useful in parenthetical languages like Scheme, since it further reduces the need to count parentheses.

But speaking of keystrokes, I should lay off typing for a little time; my wrists have been itching as of late, and I think I've been overdoing my keyboarding. I'm back in LA to attend Ken's wedding, so I should use this time to get away from the keyboard. But I'm typing at this very moment! But I can't write what I'm thinking without typing... Argh... C-c C-c C-c C-c...

Tuesday, June 20, 2006

reading papers: Exploring the Design of an Intentional Naming Scheme with an Automatic Constraint Analyzer

Notes to self on http://sdg.csail.mit.edu/pubs/2000/INS_ASE00.pdf. I'm revising this as I read more.

Shallow summary: the authors use Alloy, a model checker, to validate the design of the Intentional Naming System (INS); along the way, they show that INS has flaws in it. They use Alloy as a counterexample generator and as a tool to explore INS's design.

What questions does the paper ask?

* When does INS break?
* When does it work?
* Can we use the model to describe general properties for any intentional naming system?

Why is this novel?

* It's another data point showing that model checking can be used effectively in real world applications.
* It shows, in particular, that Alloy can handle the modeling of complex data structures. This is a new application of Alloy to a recursive algorithm (Lookup-Name) that has not been done before.

Thursday, June 15, 2006

learning to play wisely

I just played another Go game with Guillaume. One of the problems I have is that when I see a ko that I can fight, I'll rush into it like a lemming.

It must be exhausting to play me sometimes.

I have to stop fighting just for the sake of fighting. Playing games is not all I'm doing for the summer. I am getting a Nintendo DS tomorrow, though. Hmmm...

In retrospect, I suppose I am playing too many games. The days here at Brown have been a lot of fun, but there is serious work I am trying to do. (Or am I trying to be serious about my work?) I've been fighting with PLT Scheme's module system; who knew that loading a module could be so frustrating sometimes?

The issue I've been seeing involves trying to erase lexical scope and inject modules through the blood-brain barrier that is PLT Scheme's evaluation REPL. DrScheme likes to fight back, and I find myself very exhausted and writing error prone code.

In fact, my lexical-scope-erasing macro code was flawed; here's the corrected code. So Schemers do write buggy code too.

If only it were easy to transfer my determination in playing into programming well.

Thursday, June 01, 2006

learning to resign

I've been playing Go with Guillaume; it's a lot of fun, but occassionally I get boneheaded and just don't know when to resign. It's bad courtesy, and I should be better about it. There's a difference between optimism and denial, and I resolve to tell the difference better next time.

There's also a point when one is programming something difficult; sometimes I feel like I should resign and step back and see that my approach is altogether wrong. But there's the mythology of the heroic programmer --- that one last bug fix, and maybe-if-I-fiddle-with-this-it-will-work syndrome --- that I'm still enamored with.

This fault runs deep in me, and I will need to retrain myself to be less silly.

Wednesday, May 24, 2006

getting started in programming language theory

These are the two textbook resources I'm reading to get myself up to speed:



The second book, PLLC, is a very good book that appears to cover the same material as in Benjamin Pierce's Types and Programming Languages. (Why do all these textbooks have four-letter acronyms?)

Tuesday, May 16, 2006

nightmare

I wanted to post something entirely non-programming related. I had a nightmare last night; I dreamt of atomic bombs going off. It was bizarre; in my dream, I imagined that the ISS had been taken over by terrorists (or aliens; not quite sure who was responsible here). LA had been hit by bombs, the floor shuddered, and blackness. The scene shifted, and I stumbled into a dark bar. CNN played in the dim light. Were the talking heads even American? Whispers all around. And again, the lights went out, screams, and I heard a large thudding roar in the distance, with the earth shifting in protest. Much too close. I tried to close the ajar bar door. It didn't help, but it made me feel better.

It was as if I were an extra in a bad B-rated movie. I stirred and, half-waking, looked at my clock. 8:00am. Well, there's nothing else to do. The Apocalypse dream is, at least, more interesting than getting up. Might as well watch how this all ends. I went back to sleep to finish watching the nightmare of my dreams. I don't remember what happened afterwards.

I write this now so that my future self can laugh at me. What a strange time we live in.

Speaking of anxieties: I'm going here tomorrow. Not to say that this has anything to do with my nightmares.

Tuesday, April 25, 2006

macro-happy

I'm still a little too macro-happy these days. Hopefully this phase will pass.


I found a few good references on guidelines for macros:
http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg02079.html

I can't end this without not posting my little assert macro

(define-syntax (assert stx)
(syntax-case stx ()
[(_ expr)
(quasisyntax/loc stx
(unless expr
(error 'assert (format "~a lineno ~a: ~s failed"
#,(syntax-source stx)
#,(syntax-line stx)
(quote expr)))))]))

Wednesday, April 19, 2006

Reading and writing

I've been reading Richard Gabriel's book, "Writers' Workshops & the Work of Making Things". I'm really liking what I've read so far. It speaks a lot to what I think about collaborative learning --- what we do when we read and write each other's programs to give and share the gift of making.

In some sense, a mailing list like tutor@python.org tries to --- perhaps instinctively --- follow the writers' workshop environment. There is satisfying work in building communities that help each other; I would like to continue with it.

Besides reading, I'm continuing my study of PLT Scheme, and think that I can contribute to the documentation-for-mainstream-programmers-is-missing problem. I'll start by attacking classes, since that'll be the thing that Java programmers will reach first, and I'll probably try to tackle MrEd next.

Last: sometimes I'm too eager to jump into a question and write something that I think is helpful; I should watch out not to reveal too much, lest I do damage. The lessons that John Holt learned in How Children Fail should always be at the back of my mind.

Sunday, February 05, 2006

opening the time capsule

I've been starting to browsing through old archives of the RnRS mailing list and it's a blast to see how the ideas behind Scheme have evolved.



For example, it was somewhat shocking (and amusing) to hear that call-with-current-continuation was deliberately named to make it hard for programmers to type and misuse!



Well, better continue reading; I've only read up to 1985, and there's a few more years of mail left to read...

Saturday, January 14, 2006

learning to read papers: why calculating is better than scheming

I just finished reading Why calculating is better than scheming, and it's good stuff. But I get the feeling that I'll need to read a lot more papers to get up to date with programming languages.

One thing that bothers me occassionally is this: I don't think I know enough about programming language theory yet to talk with specialists about it. So there's an isolating feeling I get about reading early papers, because I think it's cool stuff, and yet it's probably so elementary that everyone else is so beyond it already.

But, despite all these being elementary, I still do want to write what I'm getting out of reading these papers, just in case I make conclusions that are absolutely wrong. If it's public, then there's still some chance that someone out there can correct me. *grin* So here goes...

A few of the critiques made in Wadler's paper are addressed in PLT Scheme. For example, pattern-matching does exist in a library. The sum Miranda code in the paper:



sum [] = 0
sum (x:xs) = x + sum xs



can be written in PLT Scheme as:


(require (lib "plt-match.ss"))
(define sum
(match-lambda
((list) 0)
((list-rest x xs) (+ x (sum xs)))))



though this also brings up a point about syntax: the Miranda code does use an appealing syntax, whereas everything in Lisp is an s-expression. Syntax is also an issue, though I think Wadler discounts too much the role of macros in Lisp-like languages.

The points for a type discipline seem fair, and I suspect a proper use of MrFlow would catch the same kind of mistakes that a static type system would catch. (Though I don't know yet: I haven't played with MrFlow seriously.)


Wadler's term "free data types" goes over my head slightly. *grin* Concretely in terms of Scheme, I think he's trying to say that equal? only works on s-expressions, and that trying to do equal? on arbitrary compound data might not work because we're never sure what the choice of representation is.

Does PLT Scheme's structure and inspector support meet the requirements of free data type definition? It seems to me that:


;; a structure is either a Weight or a Mobile.
(define-struct Weight (n) (make-inspector))
(define-struct Mobile (left right) (make-inspector))

(define-struct Branch (length structure) (make-inspector))


could also be considered a way to define free data types, though I'm probably missing something subtle.

Anyway, better stop now and sleep.

Thursday, November 24, 2005

starting with dtrace

Notes about setting up dtrace user on a Solaris 10 system: by default, it appears that normal users don't have enough privileges to access dtrace. These privileges are:

* dtrace_user
* dtrace_proc
* dtrace_kernel

and these are described in the privileges(5) man page.

So how do we add these privileges to a user account? According to http://forum.sun.com/thread.jspa?threadID=22787&messageID=73761, it's a matter of editing /etc/user_attr with a set of default privileges.

Friday, November 18, 2005

One hacker's treasure is another hacker's junk

Sun's patch 120289 recently change gnome-terminal's behavior on page up and page down keys. Some people are very happy about this:

http://ptribble.blogspot.com/2005/09/yay-gnome-terminal-fixed.html

Unfortunately, I'm not. *grin*

I do understand why the change was made --- usability matters! --- but for me, the existing behavior was perfectly usable and right: I want those keys to be sent to the terminal. I use those keys all the time in pine, and they don't work anymore.

I'm now trying to figure out how to work with gconf-editor to preserve the old behavior but haven't figured out where things need to change yet. Oh well.

Wednesday, November 16, 2005

Emacs keystroke of the day

I learned two new Emacs keystrokes that will make Scheme coding that much less painful:

C-M-f: forward-sexp
C-M-b: backward-sexp

Tuesday, October 25, 2005

Testing, testing

(define greeting (lambda () (printf "hello world!~%")))
(greeting)