Tuesday, October 18, 2005

Contracts fall right out

Jacob Matthews came to town this past weekend for several events, and on Monday gave a fabulous talk at Northeastern on multi-language systems. The experience made me proud to be a member of both the Northeastern PRL and the PLT research family. Jacob's work looks like it could be very useful, and I hope to apply it to several of my research projects. And the presentation was fantastic: he was entertaining and charismatic, and our group was a lively and interactive audience.

He's been talking for some time about how when programs interact between typed and untyped languages, "contracts fall right out." I was looking forward to finding out how, and he kept telling me that once I saw it it would be obvious. It had sounded rather magical to me, but sure enough, about halfway through his talk it became totally obvious! If a typed language is to use an expression from an untyped language in any useful way, it'll have to have a dynamic check to make sure the expression really was of the right type. But of course, you can't in general dynamically check the type of a procedure, so contracts are a natural solution!

1 comment:

Jacob said...

I'd go a little further than "a natural solution," actually, though I didn't mention it in the talk: I think that contracts actually represent policy that leads to the minimum number of dynamic checks you can make that will actually effectively guard ML from Scheme if you have to decide on the policy without getting to see the actual programs being linked together. I'm not actually sure about this, which is why I didn't mention it there; I'm hoping to talk to Robby about it after he gets back from OOPSLA.