Archive for January, 2011

STOP

This is the fourth of a series of posts based on experiences at POPL (Principles of Programming Languages), 2011, in Austin TX. (Here’s the firstsecond, and third.)

STOP (Script To Program Evolution) is a special interest workshop, colocated with POPL.

The day began with an invited talk by John Field (IBM Research) on Thorn, a new language for distributed computation with features for concurrency (actors with message passing) and gradual typing (like types).

I talked further about our POPL work, and gave a demo of our implementation. The response, as in POPL, was very encouraging: the overall consensus seemed to be that this was a really cool, “out-of-the-box” idea that would be great to continue work on.

Some students presented really cool work of particular interest to me. Tim Disney (UC Santa Cruz) talked about gradual information flow. It seems to me that this work can be extended to DCC (Abadi et al, POPL 1999), and thus may be more generally applicable to program analysis. Something to dig into when I have time. Ravi Chugh (UC San Diego) talked on polymorphic type inference with run-time logs. This work seemed to be along the lines of our POPL work, with some differences: we did not try to infer polymorphic types, but the types we infer are “principal” (most general). Frankly I do not think that their iterative inference algorithm based on contextual information has meaningful foundations; but I have to think more about this to be sure.

Phil Wadler expressed the need for evidence on whether type inference really matters for scripting languages. I had some thoughts around this, which I wanted to throw up for discussion but we ran out of time. I think that we need to be clear about what benefits types bring to programmers, and at what costs. Indeed, why would programmers want to evolve scripts to programs? Types improve robustness and performance. My stand is that to sell gradual typing, we need to sell performance, perhaps more so than robustness, since performance is a measurable benefit that the programmer can weigh against the cost of annotating or rewriting parts of the program.

Furthermore, should type inference coexist with gradual type checking? And what should the absence of type annotations mean: “dynamic” or “unknown”? (Remember Phil Wadler’s comment on the importance of syntax!)

After a quick lunch and a round of goodbyes, I rushed to the airport. There, I ran into Cormac Flanagan. Unfortunately, we were on different flights back. Picking up on a previous chat at POPL, we briefly talked some more on dynamic type inference and gradual typing; it seems they have made some interesting progress on semantic models for contracts, which may generalize some of this stuff. Seriously fun area to collaborate on in the future.

POPL (Day 3)

This is the third of a series of posts based on experiences at POPL (Principles of Programming Languages), 2011, in Austin TX. (Here’s the first and the second.)

The day began with a retrospective on Robin Milner, who passed away a few months back after a life of fundamental work on verification, languages, and concurrency. The session featured invited talks by Bob Harper (CMU), Alan Jeffrey (Bell Labs), Andy Gordon (MSR Redmond), Peter Sewell (University of Cambridge), and John Harrison (Intel).

I skipped the next session as well as the final session of the day in the interests of socializing, since this was after all the final day of POPL, and furthermore, several people were leaving before the end of the day to attend the PLDI PC meeting in Chicago.

The session in between was on compilation, which featured some cool talks: on a convex characterization of loop transformations, and tractable optimization algorithms over this expressive space; and on modular instruction selection. But the most interesting talk for me was on the essence of compiling with traces (by folks at UC Los Angeles). I followed up by wondering whether their theory said anything interesting about type specialization, which is an important application of trace-based JIT compilation: in particular, whether it subsumes or can coexist usefully with type inference. I briefly talked with Jens Palsburg (UC Los Angeles) on this, and thought about it further on my flight back; it would certainly be interesting to dive deeper into this at some point.

In the evening, some of us went to a pub, drinking beer and playing pool; this was followed by a sumptuous BBQ dinner. At some point (triggered by some random conversation), it occurred to me that there may be a relationship between dynamic software updating and concurrency control. Something worth exploring.

POPL (Day 2)

This is the second of a series of posts based on experiences at POPL (Principles of Programming Languages), 2011, in Austin TX. (Here’s the first.)

I’d stayed up most of the night to prepare my talk, so I skipped the first session of the day to catch up on some sleep. The next session was on separation logic, which had some cool talks: on a separation logic that allows compositional reasoning about atomicity for programs that manipulate concurrent data structures (by folks at Northeastern University); and on modular reasoning for deterministic parallelism (by folks at Cambridge).

Lunch followed, with some pleasant conversations with Stephen Freund (Williams College), Todd Millstein (UC Los Angeles), and Sorin Lerner (UC San Diego).

I sat through the next session fine-tuning my slides, and in the process managing to miss some interesting talks which I have to catch later: on amortized resource analysis; and on symmetric lenses.

The final session of the day was on types (with the final talk being mine). First up was a talk on dynamic multirole session types; Phil Wadler pointed out in his follow-up that an implementation of this system may not allow as must distribution as claimed. Next up was a talk on practical affine types, which showed how to infer some of the associated proof constructs via subtyping (similar to how one moves from sum and product types to union and intersection types). Phil Wadler stressed the importance of syntax in making something “practical”; in particular, he wondered whether the annotations on arrows that affine rules require were indeed practical. On the surface, this seems to be a trivial complaint; but there is definitely something to it, something worth remembering.

Finally, I talked about dynamic type inference of static types. A lot of anticipation had already built up around this talk; we had got top reviews for this paper, and apparently some other groups had been independently trying to solve this problem. The key idea of our paper is to infer types by running tests and logging subtyping constraints along observed paths; what makes it interesting is that we can prove a soundness theorem that is qualified by the coverage of those tests, and we are able to show that the coverage needs to be only linear in the number of functions in a program (although it may be exponential in the maximum number of paths in a function). Such a dynamic analysis technique is especially useful for dynamic languages, where (in our experience and of several others) static analysis is too imprecise. The cool thing about our technique is that while we are precise, we are not “too precise”: our analysis can extract enough abstract information to let us generalize types and predict type errors.

Fortunately, the talk generated a huge amount of interest. Mitch Wand and Matthias Felleisen (Northeastern University) followed up, and I was kept busy long after the talk by others. Sam Tobin-Hochstadt (Northeastern University) and Madan Musuvathi expressed interest in the implementation (which involves wrapping); Sam pointed out the “values-as-proxies” ECMAScript proposal for comparison, and Madan was on the lookout for similar tricks for his concurrency  work. Fritz Henglein (University of Copenhagen) pointed out that some of his work from the 90s may be relevant, where he had done the “converse”: static inference of dynamic types. Dave Herman (Mozilla) and I chatted at length on our similar roles at different companies, and discussed the importance of collaborating in the future.

The day ended with Mooly Sagiv (Tel Aviv University) describing the workings of the POPL 2011 PC (which everybody agreed had done a remarkable job), and Phil Wadler presenting the most influential paper award (from POPL 2001) to Samin Ishtiaq and Peter O’Hearn for their work on bunched implications as an assertion language for mutable data structures (a.k.a. separation logic). Peter O’Hearn, in his acceptance speech, recalled that this paper was ready almost half a year before the POPL deadline, but they decided to wait because the best work in programming languages deserves to go to POPL.

POPL (Day 1)

This is the first of a series of posts based on experiences at POPL (Principles of Programming Languages), 2011, in Austin TX.

Tom Ball (MSR Redmond) launched proceedings with his usual flair and some cool slides on POPL 2011 records.

The first session of the day was an invited talk by Xavier Leroy (INRIA Rocquencourt). I’ve known Xavier by face and reputation since the summer of 2002, when I was an intern in the Cristal group (working with Gérard Huet). Xavier talked about how his and others’ work on certified compilers over the years has ensured that the verification of realistic compilers is now well within reach. The next frontier is certified static analyzers, on which he provided some hope of progress. Finally, he called for more verification work around floating point (FP); of particular interest was a list of unfounded compiler optimizations around FP, which Alex Aiken (Stanford) extended in his follow-up with the curious fact that FP addition is non-commutative in C. Overall, a thoroughly educational talk, littered with memorable quotes:

“Old pots make tasty soups.”
“It makes me nervous to fly an airplane since I know they are designed using floating-point arithmetic.”

The next session was on memory models, which featured two excellent talks (by folks at University of Cambridge): on certified compilation of C under an exposed x86 memory model; and on semantics and proofs for C++ concurrency.

I skipped the next session; part of the typical POPL experience is being drawn into extended conversations with old and new friends on “stuff.” I was particularly surprised to find my undergraduate advisor on the loose.

The final session of the day was on types. Phil Wadler (University of Edinburgh) gave a hugely entertaining talk (in his inimitable style) on blames for the polymorphic lambda calculus. Dimitrios Vytiniotis (MSR Cambridge) showed a way of resolving the tension between generative type abstraction and type-level computation; Karl Crary (CMU) in his follow-up seemed to suggest that there might be a cleaner way.

In the evening, Tom Ball and co. did live jazz, much beer and scotch flowed, and the night ended with an interesting dinner: amidst some very lively conversations with Samin Ishtiaq (MSR Cambridge), Ranjit Jhala (UC San Diego), Cormac Flanagan (UC Santa Cruz), Madan Musuvathi (MSR Redmond), Eran Yahav (IBM Research NY and Technion Institute of Technology Haifa), and many others.

A round of introductions

We have some exceptionally talented people working in our Languages and Runtimes group.

Basil Hosmer (language design, type systems, concurrency), a freakishly clever veteran behind several products at the company (previously at Macromedia).

Adam Welc (concurrency, parallelism), a prolific author on transactional memory (previously at Intel Labs).

Simon Wilkinson (VM, concurrency, parallelism), a dexterous hacker of runtimes (previously at the University of Manchester).

Mathew Zaleski (JIT, interpreter), a seasoned expert on dynamic compilation (previously at IBM and the University of Toronto).

And finally, Bernd Mathiske (VM, language design), our manager and the dude who hired us all (previously at Sun Labs).

Furthermore, we collaborate with several people in the ActionScript Engineering team, including Lars Hansen, Jeff Dyer, and Edwin Smith.

In particular, Basil Hosmer, Lars Hansen, Jeff Dyer, and I together are the ActionScript Language Design Team, which means that we are responsible for the definition of the language and the design of future versions of the language.

Setting the context

Our aim is to evolve ActionScript into a safe and efficient programming language.

There’s a lot to do.

ActionScript Language Specification
(Because you can’t improve something you don’t understand.)
ActionScript is the core scripting language in which Flash applications are developed. While its roots lie in JavaScript, there are several features in ActionScript that go beyond JavaScript (e.g., class-based inheritance, namespaces, strict-mode compilation, application domains). Unfortunately, the only “specification” of ActionScript has been its implementation, which means that some aspects of the language remain arcane, and any bugs in the implementation cause backward-compatibility problems. We are working on a rigorous definitive specification of the syntax and semantics of ActionScript programs.

Gradual Type Inference for ActionScript
(Because if you have something, it should really count.)
ActionScript enforces a combination of static and dynamic checks on programs, but it is unclear what such checks guarantee. Furthermore, there is no type inference in ActionScript. We are working towards a new gradual type system for ActionScript with the following main design intentions: (1) reconciling type inference with static types (annotations) and the dynamic type (*) via the notion of “unsafe” code regions; (2) providing meanings to types via a combination of static and dynamic checks that provably restrict runtime errors to unsafe code regions; and (3) optimizing code by eliminating dynamic checks wherever they are subsumed by static checks.

The plan

…is to document various thoughts on language design, implementation, and evolution, hovering around and often diving into ActionScript.