Thursday, October 23, 2008

Things I don't like

Specifically, things I don't like in programming languages. When I design the world's perfect programming language, none of these things will be in it. I'm not going to justify any of these things, I am after all meant to be finishing my thesis.

inner classes
primitive types
raw types
private/protected/public annotations
Java-style reflection
non-reified generics
almost everything to do with concurrency
wildcards (the syntax, the underlying idea is nice)
non-virtual inheritance
friend functions
\* *\ comments (rather then \\)

These are mainly OO/Java-ish things, I'm sure I could think of as many from other paradigms, but I'm a bit OO focused at the minute.

Some we just have to put up with because there is no neat, all round solution (eg primitive types). Others are not as good as they could be (reflection, concurrency support), and others just shouldn't exist (statics, arrays, most of the rest)

Wednesday, October 15, 2008

Feynman Quote

"Physics is like sex. Sure, it may give some practical results, but that's not why we do it."

Substitute "PLT" for "physics"...


Surprisingly, this is not going to be a post about functional programming, nor about the existential types calculus, Fun; but, about fun, as in "having fun" or something being fun to do. More specifically, programming.

OK, most people who know me will know that I hate programming. Well, that's not really true, I love programming, but I hate all the crap that goes with it. Writing neat, elegant code to achieve some task and see it work is more fun than most (but not all) things I can think of. However, testing, debugging, writing documentation, writing boiler plate code, maintaining code, all of these are about as much fun as a kick in the nuts.

I believe the fun aspect of programming is important, it motivates lots of people to write open source and free software and to code in their spare time "just for fun"! It pretty much explains why anyone would work in the games industry. Even in well paid development jobs, I think that tasks that are fun to do are given priority, done with more enthusiasm and concentration, and, therefore, done faster and with less mistakes.

So here's an idea for language design, how about making a language that maximises the fun in using it? It would maximise the time spent on fun things and try and make the not-fun things more fun, rather than more efficent or more safe or whatever other software-engineering-ey things are considered important nowadays.

Of course, you would need to find out precisely what was fun and why and how to put these ideas into a programming language, but maybe that will be fun to do itself.

How's that for a research project that will never get funded and will never happen?

Sunday, August 17, 2008


I'm currently writing the background chapter of my thesis, and this involves a lot of re-reading of papers. Several times now I've thought "if only I had read this two years ago! This would have been so helpful, I could have avoid so many mistakes!" Of course, I had read the papers two years ago, and I thought at the time that I understood them (in the same way that I think I understand them (better) now). So, maybe, I should have put a lot more effort into properly understanding these papers when I first read them? Well, yes, I probably should, it would have saved me a lot of pain and effort. But, I can't help thinking that maybe I had to do all the work and suffer all the mistakes before I really could understand them. I like to think so, because then I don't feel so bad about wasting months on bad ideas that I could have avoided by spending a few days more on a paper.

p.s. I would particularly like to single out the two variations on the variant parametric types paper by Atsushi Igarashi and Mirko Viroli. It seems to be the paper that keeps on giving; I've read it at least five times now, each time in some detail, and yet everytime I seem to get more out of it!

Tuesday, August 05, 2008


Currently I am in Egypt, to be precise I am in Dahab in the south Sinai. My mission is to write my thesis. I figured that it is a lot cheaper than London and there are a lot less distractions. So far I am doing quite well, I have written more than I think I would in London even though I have been busy moving into an apartment and settling in etc. Now I am ready to accelerate to never before seen levels of productivity! This is kind of dependent on the air con in my apartment getting fixed because otherwise it is too hot too sleep and far too hot to think, but, insha'allah, it should be fixed today.

My other reason for being here is that it is the freediving capital of the world. There is lovely warm, clear, and, most importantly, deep water 3 minutes from my apartment, loads of people to freedive with (most of whom are very good) and some great people to take some coaching from. I am pretty much on my pb from last year (41m) and it feels easy. I am taking it slowly, doing lots of dives to about 40m, and have some technique to learn, but I hope to be hitting 50m and more soon. So these are my goals for the summer - one complete thesis and 50m+. My schedule is pretty much work in the mornings, noon, and evenings and freedive in the afternoon. No late nights, no alcohol, no noxious London pollution; by the end of September I should either feel more healthy and alive than I have done in years, or a complete physical and mental wreck, we'll see...

Update, well I seem to be edging toward the physical wreck end of the spectrum, had a bit of boo-boo freediving and was spitting a little blood afterwards. Apparently not too much to worry about, but need a few days rest and to take it easy for a week. That will teach me for being so optimistic! On the bright side it means I have even more time to write my thesis, so I am plowing ahead with the background chapter!

Saturday, August 02, 2008

PostDoc in NZ

Slightly belated news, but I wanted to blog the other things before I forgot them all. From 2009 I will be working for James Noble in New Zealand. We wrote a grant proposal (with more than a little help from Sophia - thanks!) to study existential types for ownership types and other mechanisms for making ownership types more flexible. Our proposal was accepted (yay!) and so I'll be starting work in NZ just as soon as I finish my thesis and get married. This is obviously very exciting and I'm really looking forward to moving to NZ and to working with James. We already seem to have too many ideas for two years and I still have a bunch of things to do with wildcards, so hopefully I won't be stuck for something to do.

Friday, August 01, 2008

A visit to an Najah University, Nablus.

After leaving Cyprus I went to Israel, to visit a couple of friends and to do a few days sightseeing in the West Bank. After a couple of days in Jerusalem and Bethlehem, I headed north to visit a friend; he lives on a Kibbutz in a little corner of Israel squeezed between Lebanon and the Golan Heights. It was very beautiful there and as he had to work during the days I got some work done too - thesis writing and some proofs, occasionally interrupted to cool off by swimming in the beautiful, and freezing cold, river Dan.

After a few days of this it was back to Jerusalem and straight on to Nablus, where, on the bus I met some very nice Palestinian guys, one of whom put me up for the night in Nablus. All of his house mates were students at the university, so I was taken along to a few lectures the next morning.

An Najah university is the largest Palestinian university and has 16,500 students in 3 campuses around Nablus. The campus I visited was very modern and the buildings were much nicer than, for example, Imperial College. Furthermore, as it is quite high on a mountain overlooking Nablus, it has probably the best views of any university I've ever visited. The facilities do not seem too bad either, plenty of computers, etc. Nicest of all it seems very relaxed, other than the slightly over-keen security at the gates, there is none of the background tension that permeates most Palestinian towns. Also, if you have travelled in Palestine, you may wonder where all the young women are, the answer seems to be that they are all at university, there seemed to be (and apparently this is the case) far more female than male students, especially in engineering and science, apparently - which makes a bit of a change from Imperial!

Mostly the place reminded me of any other university, lectures seemed pretty much like lectures anywhere else. There were a few differences: students talk a lot more in lectures than you'd get in England, the classes were a bit smaller, some lectures were in Arabic (although its amazing how much of an Arabic statistics lecture you can understand!), and there are probably more martyrs posters than you'd find in an English university.

I sat in on an English lecture and listened to a very nervous girl speak about colours. And was then press ganged into talking in English and probably confused everyone a great deal. Most students seemed more interested in chatting about why I was there and which football team I supported than anything about English, but I guess it is all practice.

After a late breakfast I knocked on the door of the head of Information Technology to try and find out a little about computer science in Nablus. He was a very nice guy and we were joined by a couple of professors who were also very nice, one of whom had done his PhD in program verification, so we had a little chat about my work and on PLT. They had the kind of problems you'd expect, not enough staff, not enough money, not being able to travel. Even though many of the lecturers have PhDs, they don't have time to do any research. In fact they seem to have lot of clever people (in contrast to say Addis Ababa, where all the lecturers with PhDs left to work in the states), but not enough time and money. They teach pretty much what you'd expect of a computing course, Java and C++ and databases, hardware, etc. Less maths and theory than at Imperial and more general options - the first year is a bit liberal arts like and they continue to do English and other options throughout.

Anyway, what was nicest was to meet so many friendly people, it was amazing how many people wanted to chat or say hello or were interested in this that or the other. Overall it was a great experience and I wish I'd had longer there; the staff wanted me to give a seminar on my research and it would have been nice to meet more of the staff and maybe sit in on some CS lectures.

After all this fun it was time to go back to Jerusalem, which entailed lots of waiting and queuing at checkpoints and very young and nervous (but always polite) Israeli soldiers pointing guns in my direction and general tension. I won't go into it here, but suffice it to say that the Palestinians really suffer for the security measures.

ECOOP day 3

First paper of the day was "Programming with Live Distributed Objects". I used to be quite into distributed programmer, so I was interested to hear this talk. I have some interesting looking notes which I will put here verbatim:
everything is a live, distributed object
eg naming
composition is fundamental
compatible end points is the most important relation, basis for subtyping
constraints on endpoints
parameterised types, XML
Unfortunately, I can no longer remember what any of it means (it has been almost 3 weeks since the talk), perhaps I will edit this once I read the paper and remember how it all works, but I wouldn't hold your breath.

Ray (Hu) from Imperial gave his talk on "Session-Based Distributed Programming in Java". They have implemented session types for Java and it all seems to work very nicely. Session types are cool and their use of them in Java seems to work very well, and they got good benchmarks. It is nice to see static typing used to verify something like distributed protocols, it just seems to make really good sense!

I'm afraid I missed "ReCrash: Making Software Failures Reproducible by Preserving Object States", which I wanted to see, so another paper to push onto the stack.

Next up in this session was "An Extensible State Machine Pattern for Interactive Applications". I started off understanding a lot and thinking the problem was quite easy. It reminded me more than slightly of work we did on StateJ (although they didn't mention us :-( ). They have a problem with interactive, stateful applications that is similar to the expression problem. Their solution seems to involve refactoring in some factory methods. I would have thrown some virtual classes at it and given my usual sales pitch about how nice and elegantly it would all work, but each to their own. Then they started talking about interrupting events and delimited continuations and I'm afraid I got a little lost, but I was motivated to read the paper and understand it.

Probably the most useful idea at the conference, "Practical Object-Oriented Back-in-Time Debugging" did just that, they have a back in time debugger for Java that works with realistically sized programs. If I did any programming I would want their tool! In terms of implementation the key idea is that they keep all of the _relevant_ history, and let the garbage collector get rid of the rest. Seems like a neat idea now that someone has done it!

The last talk of the conference was "How do Java Programs Use Inheritance? An Empirical Study of Inheritance in Java Software". A study of inheritance in Java programs. Surprisingly they use it a lot, not everyone just hacks things together without thinking of these things. I suspect that in a few years this will be the most widely cited paper presented, whenever we need an excuse to do some more research on anything vaguely related to inheritance, BAM! Motivation!

And that was that for ECOOP '08. I had a great time and look forward to next year, although Sophia is PC and so it might be difficult to write a paper for it, not to mention an inconvenient wedding just before the deadline.

I left Cyprus the next day, although obviously it did not go smoothly. After getting a ride to Larnaca airport (thanks to the Swedish contingent!) I had a marathon wait, followed by more waiting as my flight was delayed, followed by more waiting for an interview with security in Israel because they didn't like some of the stamps in my passport (I was kind of prepared for this). By the time I cleared the airport my hotel was closed so I spent what was left of the night sleeping on the roof of a full hostel in the wrong city; the sun was coming up as I finally tried to get to sleep...

Wednesday, July 30, 2008

ECOOP day 2

Well my notes get sparser by the day and I attribute this to conference fatigue rather than fewer good talks, so here is my rather brief account of day two at ECOOP.

The first paper I would like to describe was on UpgradeJ and the talk was given by Gavin Biermann. To be honest I thought this problem had been solved because I have not seen any work addressing it recently, but it seems I am wrong, and just as well because this was one of my favourite talks. The problem is to dynamically update running Java programs, which entails all sorts of headaches: Gavin started off the talk by warning that this was a topic for experts, not novice programmers. Although, after everything was explained it didn't actually seem _that_ hard, perhaps in real life it is more difficult (which begs the question - "how much can this stuff be encapsulated?"). Anyway, they propose a scheme of class upgrading with explicit (and multiply co-existing) versions; furthermore, upgrading is explicit too. I kind of like this approach - no surprises! There are lots of nice little features, such as fixing classes at a certain version or allowing them to upgrade, or allowing possibly breaking upgrades etc. Also, it is rather conservative, in a good way, you can not rely on versions being loaded at some point to call the upgraded code. I wonder if it is possible to rollback versions too. I suspect so, seeing as the system, is conservative type-wise, but I guess I'll have to read the paper to find out...

Next was Donna Vali... (sorry Donna! My internet has gone down, and I will be too lazy to check this later) talking about her system for mixing nominal and structural subtyping. I've looked at this work a few times before (see blog posts below vvv). I like it, it has a nice mixture of the features of both type systems and it seems well thought through. My only quibble is that it is hard enough to convince programmers to use types and I wonder if they will get enough benefit to deal with the extra overhead. Actually, I suspect they would, if they tried, but I also suspect that they are mostly to lazy to try and that language designers are too risk averse to try too. Also, the real joy of structural typing comes from the flexibility, and this has to be lost in order to accommodate nominal subtyping, so I am very interested to see how flexible the system is. I will read the paper and find out! And something to think about - Donna gives objects a structural and a nominal type, the structural type has a clear run-time counterpart - the record, and an object can be thought of as a record and a brand (the nominal part of its type). BUT, what is a brand? Is there a runtime entity that can exist without an object and captures the essential features of this mysterious brand? I am very interested to know, so if anyone has any ideas, please let me know!

The day was wrapped up with Gilad Bracha's summer school talk on his new language Newspeak, which was very popular (I would be a little gutted if my talk was scheduled for this time) and brought on a lot of George Orwell puns. Anyway, it was a great talk, Gilad is a wonderful speaker,and the language is interesting and abides by a lot of very sensible rules. One thing I lied was the design philosophy - you think of a rule, and everything else just kind of follows from it, no exceptions.

After all this intellectual tomfoolery we had the conference banquet in the evening. This was in a touristy taverna in Paphos town where the music was too loud and the entertainment was very cheesy, and apparently provided by perverts. If I ever have daughters they will never set foot in Paphos as long as I live. James Noble started a very entertaining speech, including heckling some tourists at one point, but was quite rudely cut off by the band halfway through, which is a shame since it looked like it was going to be the only entertaining conference speech in history. This was followed by more 'entertainment', not least of which was my supervisor, Sophia, dancing with performers and generally enjoying herself (there is video, although I have not received it yet...). We made a sharp exit, and had an enjoyable night chatting with various ECOOP people in various ECOOP places.

Tuesday, July 29, 2008

ECOOP day 1

And so to the main conference. First of all I would like to brag that our paper was nominated for best paper, which is very flattering, unfortunately we didn't win, but at least we have something to aim for next year :-)

The day started (well, after the usual welcome chit chat) with an invited talk about transactions, that dialled the usual numbers about multicores and concurrency being the next big thing, and transactions being _the_ way to address the whole concurrency problem, and asked the question "are these transactions the same as we were talking about 30 years ago?"

Following this was my talk, which went swimmingly, although I was still a little rushed at the end, although I still managed to finish (almost) on time and earn myself a pear.

Unfortunately I was to drained emotionally to pay any attention to the nest talk, which is a shame because it looked really interesting and I will definitely be reading the paper - it was about mixing inheritance between languages.

Later, I attended the summer school talk on JavaCOP which was very interesting and really sold the concept. They basically implement pluggable types, a concept of which I am a very big fan, and allow you to add your own type systems to Java. I think it is defiantly worth looking at a bit closer and I will do this as soon as I have some time (which really means after my thesis is finished). In a nutshell: you write extra types as annotations to your Java code, and define a bunch of predicates that makes them all work and JavaCOP compiles it all into a class file which can then check the programs you annotated. It all seems like an interesting and practical idea with probably a never ending list of extra things that could be added.

I rounded off the day with another summer school talk, this time by Jonathan Aldritch on SASyLF - a proof assistant for students. This was a great session and we all had a go at making and running SASyLF proofs. It got me even more convinced that I must learn how to use one of these proof assistant things. There seemed two novelties with SASyLF: first that it is really aimed at the ECOOP (rather than POPL) crowd, and so has natively a lot of things that you waste a lot of time doing in other proof assistants; secondly, it is aimed at students, which means you have to spell everything out and can't tell it do as much as it can with guidance at any point. Most people seemed to regard this as a shame as they'd like to be able to use it since it is adapted to their needs. There was much talk of some kind of professor switch to make things quicker whilst still making students understand everything, but this seemed impractical from a security point of view. Anyway, it was all very cool!

FTfJP and the DLS

So on to day 2 of the conference, where I mainly attended FTfJP and briefly popped into the Dynamic Languages Symposium.

First of all I'd like to bing attention to my colleague, Alex Summers' talk, which was a good talk, but more importantly the work is interesting. Actually I have been a little bit involved with it (only a little though) so I have heard a lot of teh stuff he talked about. But, I think it is very interesting, it is about adding static fields and methods to the universe type system. Frankly, I think this is a terrible idea, we should just avoid static anything like the plague (see Gilad's summer school talk and (I think) an earlier blog post), but if you're going to do it, then it turns out to be an interesting problem with no easy solution (the best kind, or worst, depending on your point of view).

The next great talk was by Stefen Wehr who talked about wildcards (a topic very close to my heart). He is concerned with decidability, admitedly not directly. In his work he shows that _a_ model for wildcards and another for interfaces in JavaGI, both of which use a similar kind of existential type, are undecidable. This is obviously interesting since decidability of wildcards is still an open question, which I'd love to look at if I had the time and skills, but I have neither, so I have to make do with reading interesting papers like this one.

The next talk of note was at the DLS, it was an invited talk given by Laurence Tratt entitled Language Design: Back to the Future?. The gist of the talk was that all current languages are almost identical and language designers are not really being creative. He also claimed there are some valuable things that people have done and that have been ignored. I kind of agree, although I don't agree that it is due to a lack of creativity on the part of language designers - there are plenty of fairly wild ideas floating around, but it is true that most never make it into real life languauges. He seemed to concentrate on 'micro' level language features such as new expressions, which is an area (I thinK) that has been neglected in research lately in favour of more 'macro' ideas - such as ownership types, different object meta-models etc. I was a little inspired by the speaker to think a bit more about language culture. His point is that programmers, lanaguage designers, and researchers are all absorbed in a certain culture of a language - the paradigm, the programming idioms, way of thinking, etc. It would be interesting to see some research on this - to charecterise and compare these programming cultures and the effects they have on programming languages, and importantly, vice versa. A quote I liked was that innovative language features were destined to have "some spotty twat at the front take the piss out of it".

I'm afraid that by this point I was a little drained and failed to make any meaningful notes, but I'd like to draw attention to the last two talks of the day that I thought were interesting - Rok Strnisa on the Java Module System and Samir Genaim and Fausto Spoto on constancy analysis

And an interesting thought from one of the talks - if we have an underlying database implementation (for example) that only has a next method as an accessor that returns null at the end of the table. If we wish to implement a wrapper with a hasNext method, then this method will have an internal side effect (it must cache the returned row, if it is not null), but logically it should be pure. Can this be handled elegantly in the various ownership/invariants/effects systems that are around?

Tuesday, July 22, 2008

ECOOP '08, Cyprus

This is turning into nothing more than a conference blog, and I apologise if anyone actually reads this (actually, at least one or two people do, as I found out - hello!). Its not that I've stopped having ideas, its just that I've been very busy. I'm now in Israel, en route to Egypt to write my thesis (yes, it is a good idea, actually). I have a little time to write a little in the blog, so here is my summary of ECOOP...

ECOOP this year was in Cyprus, not an altogether popular choice, since getting there from anywhere except London was a nightmare, but I came from London so I was happy. Also happy to be very close to the beach and for it to be very warm, thus making for a very enjoyable conference. Well, except for the fact that I was working a little and had a walk to the hotel and it was hot and I inevitably sweat so much I spent most of the conference smelling like a tramp, but hey.

Anyway, the first day was IWACO, which was great. I really like this little workshop and enjoyed nearly all the papers, so you could go worse than go to and read them all! Some comments on some of the talks follow:

First was Jonathan Aldritch's invited talk - the theme of which was making ownership types systems usable by real programmers. It was a great talk and he discussed a lot of aspects that make type systems more or less likely to ever make it into real langauges. He talked about the adoptability and applicability of ownership systems - adoptability concentrated on making these systems easier to use: less annotations, more inference, etc. And how to get the programmer to give the right guidance to the compiler to do inference. Applicability was basically about offering less strict organisation than classical ownership types - such as existential types (!), multiple ownership (!), domains, etc. He also encouraged us to _actually_ study more code to find the strucure of large software.

Alex Potanin then talked about unifying ownership and immutability by using generics, which is a very interesting idea at its early stages.

I gave a talk on existential types for ownership variance, which uses the nice clean framework of existential types to give owner variance without the kind of hackery we use in, for eg, MOJO.

The talk by Nicholas D. Matsakis and Thomas R. Gross was also good. They parameterise types with partitions that restrict effects and use this information to ensure thread safety. It seemed to me like a more fine-grained version of atomic sections, since they restrict the atomic-ness (i.e., the non interfernce of effects) to a parition, while atomic sections apply to the whole heap. I also wonder what would happen if you allowed some kind of variant partitions, like wildcards (not that I'm developing a one-track mind for wildcards or anything).

John Boyland gave a good position paper, which basically said non-linear reasoning (ownership) is better for reasoning about non-linear problems, specifically volatile fields, than linear reasoning (seperation logic).

The talks were rounded off by some interesting demos and a talk about J* by Dino from Queen Mary's, which inspired me to read the seperation logic literature, which I've been meaning to do for a while, but never got round to...

James Noble made the astute comment that some kind of ownership was creeping into seperation logic techniques in order to address certain problems. Also the composite pattern is the new subject-observer - it is difficult to model since you go bottom-up, breaking all the invariants as you go, and then repair them all. I wonder what we will do for motivation when we finish the design patterns book.

Monday, January 14, 2008

Existential types everywhere!

I am certainly biased in this respect, since most of my research work has been with existential types, but I think that existential types are vastly important to the world of OO programming languages, and probably the rest of PLT too. Existential types give us a way of expressing data hiding (i.e., abstraction) in the type system, and seeing as this is what most of software engineering is all about, it shouldn't be surprising that existential types start cropping up all over the place.

My own work has so far focused on Java wildcards, which are a (relatively) simple way of using existential types to deal with the mismatch between parametric (i.e., generics) and inclusion (i.e., subclassing) polymorphism. In the same way I have found existential types to be useful in the world of ownership types. I believe Werner Dietl is having a similar experience with universes.

Existential types are also a foundational model for objects themselves in OO languages. And, I suspect, are a better way of thinking of generic classes than the universal types that people often assume.

Furthermore, I've found some pretty elegant tricks that can be played using existential types mechanisms such as packing and unpacking types, in the realms of path dependent types and virtual classes. I'm pretty sure the same techniques can be used elsewhere.

More than a whiff of existential types can be had all over the place in current research, delayed types, ownership domains, and MOJO all come to mind, and I'm sure I've come across more that I can't remember.

And so what? Well I'm not sure, but I guess I'm glad I've managed to get pretty deep into existential types. I'm sure they'll keep coming in useful for some time to come.