Notes from Milner Symposium

First-hand anecodote on the naming of the pi-calculus, courtesy of John Power. Robin Milner viewed it as a successor to the lambda calculus. What comes after lambda in the greek alphabet? Mu, but there was already a mu-calculus. Nu comes next, but sounds too similiar to mu. Next up is omicron, but who’d want to work on the “omicron calculus”?! And so you get to pi. PI CALCULUS.

GĂ©rard Huet’s opening talk was amazing. He talked flowingly for 40 minutes, entirely from memory. He talked about the early days of ML, including the ‘split’ between Standard ML and the INRIA caml/caml-light/ocaml. He described being asked by Milner to rename the INRIA flavour of ML after the Standard ML effort, and then cheekily naming it CAML, ostensibly because of the Categorical Abstract Machine but usefully keeping ML in the name.

I really enjoyed Xavier Leroy’s talk about a future in which programming languages and theorem provers increasingly blend into one – an area which I keep meaning to get deeper into. I also thought Benjamin Pierce’s talk was really appropriate for the occasion – taking the time to walk through the Hindley-Milner (or Milner, or Damas-Hindley-Milner) type inference algorithm in detail.

Another eclipse extension

Like this person, I often want to surround the eclipse selection with parens. For example, “42” becomes “(42)” with the cursor before the first paren, ready to turn into “foo(42)”. Combined with eclipse’s structured selection, this is pretty handy. For the last while, I’ve used a template for this. It requires a few keystrokes though, so was a prime target for optimization.

So tonight I threw together an extension called Parens which does it in a single keypress. The surprising thing was that it worked perfectly first time I ran it. This never happens!

I’m starting to like customizing eclipse. it’s not quite as ‘discoverable’ as emacs is .. largely due to it’s modular nature and careful dependency tracking. However, given that emacs’s lack of modularity and dependency tracking drive me mad, I can’t complain too much.

Remote android

I’ve got an HTC Wildfire, but text input is pretty dire. Even with a swype-style keyboard, it’s still too laggy to do things quickly. I could send texts twice as fast on my old phone which had real keys.

However, I do spend most of my life at a computer with a full keyboard. Recently, I tried out some apps (eg. Airdroid) which start a web server on your phone and let you control it via a browser. That’s pretty cool, but often my phone is connected to a wifi behind NAT, and my computer is connected to a different part of the network. NAT == no server. Also, my phone gets a random IP address each time it joins wifi, so there’s not a stable network name for ‘my phone’.

So, I decided to fix the problem. If NAT means my phone can’t be a server, then my phone needs to dial out to the outside world. It needs to meet up with my computer somewhere and exchange messages. Sounds like a chat server? That’s what I thought. So, I set up a private jabber server on t’internet and wrote a new android app for my phone. The app connects to the jabber server as “phone”. I connect to the jabber server like normal from my computer as “andy”. By striking up a conversation with my phone (!), I can instruct it to do a bunch of stuff. So far, it can send SMS’s, start beeping, vibrate and report its location. The app is smart enough to reconnect to the jabber server whenever wifi becomes available, which means it’s connects automatically when I go to work or arrive home – the main times at which this is useful. It also means if I lose my phone (at home or work) I can cause it to beep (ala WheresMyDroid).

I thought about adding the reverse direction – ie. if the phone receives an sms, it routes it to jabber – but I don’t have a pressing need for that yet so I’ve not added it.

This was an interesting project. Jabber/XMPP was a pragmatic solution. I originally planned on doing a custom socket protocol, using SSL/SASL for encryption/authentication. But then I’d need to handcraft a “command sending” application and carry it around. I’d also need to make it robust – automatic reconnections etc. I also looked at using various “message queue” technologies as the hub instead of jabber. They’d all work, and I kinda like queues, but there’s no need for that rich a feature set. Jabber is fine.


Thought I’d share my favourite eclipse tips, since I’ve been living in eclipse recently. I first used eclipse in 2003 on a laptop with a shoddy trackpad, and I think that lead me into a mouse-free habit.

Navigation around text:
1. ctrl-. and ctrl-, to jump to next/last compile error.
2. ctrl-shift-p to bounce between matching parens.
3. Expand/contract selection syntactically – alt+shift+up/down. Replaces 90% of all careful mouse-drag selecting.
4. Move cursor using incremental search (ctrl-j) rather than cursor keys.
5. See all uses of a field/variable quickly – bind “search all occurances in file” to a key (I used alt-shift-f), put cursor on a field, hit your shortcut, then use ctrl-. and ctrl-, to jump between occurances.
6. Move lines of code around with alt-{up,down}

Navigation around projects:
1. Switch to recently used editors/view/perspective – ctrl-{f6,f7,f8}. I also bind the f6 action to ctrl-tab too.
2. Most laptops have a “right-mouse-click” key on the keyboard.
3. “alt-shift-q p” to focus on the package explorer, shift-{left,right} to expand/collapse folders, then f12 to focus back on the editor.
4. Use ‘show call hierarchy’ (ctrl-alt-h) and ‘show in type hierarchy’ (f4) lots rather than dumb search.

Type less stuff:
1. Create new variables by just typing “new Foo();” and then “ctrl-2 l” to assign to a local.
2. In the outline view, drag methods to reorder them in the file.
3. Use templates to surround stuff – saves hunting for the correct location for a closing bracket. Create a template called “validate” with “Validate.notNull(${word_selection})”. Then use it by selecting an expression (using expand-syntactically), hit ctrl-space twice to see templates and pick your new template. Eclipse wraps the existing expression with the template! Or, do a more generic version, such as “${cursor}(${word_selection})” which sets you up to pass the selected expression as an argument to a method call.

1. Ctrl-shift-L twice takes you straight to the keybinding pref.
2. When changing existing code, try to only ever use refactorings – avoid editing at the raw textual level.
3. I also do a lot of speculative refactorings, most of which I immediately undo. For example, if I see a big method, I’ll select some likely looking chunk and try an ‘extract method’. If eclipse tells me it’ll need too many parameters, I’ll cancel and try a bigger/smaller chunk of code. Or, if one of the parameters looks odd to me, I look to see if I can reorder code, or extract a new local, prior to running extract method. I call the new method ‘foo’ until I decide if it’s a keeper or not.
4. Use the quickfixes for the if/when/switch keywords (eg. “invert if, convert to continue”)
5. Use ctrl-m to toggle maximize your view/editor.
6. Use the eclipse-fullscreen extension (ctrl-alt-z) for even more screen space.

Running stuff:
1. Go to prefs, search for “launching” and tick “always launch the last-run application”. Then use f11 and ctrl-f11 to run whatever tests/app you’re working on.

I also have an eclipse extension that I wrote to toggle between a class and its test class. I’m still squishing bugs in it, but I’ll share it if you’re interested.

Node.js and a changing world

When node.js was released in 2009, I didn’t understand why it got so much hype. I understood what it did, but since it didn’t let me do anything I couldn’t do before, it just wasn’t very interesting.

But since then I’ve put a few thoughts together:

1) Javascript *is* the ubiquitous client-side ‘platform’ in today’s web world. You might not have chosen things to be that way. But we could be a lot worse off. So, in today’s world, everyone has to know javascript.

2) Javascript is today what BASIC was in the ’80s. You get immediate feedback without compile/deploy cycles. You can futz around without any infrastructure. You don’t type ‘RUN’ any more, you just hit refresh in your browser. I learned BASIC then Z80 assembler as my first languages. Today, you’d learn javascript.

3) Not everyone knows C#/Java/C++/ruby or similar “server side” languages. I do, but only because of my career track to date. Everyone in the world has a different background and experiences. If you already know javascript, I suspect it’s not really that attractive to have to learn a second language just to do server-side programming?

4) Even if you did choose to use a ‘real’ server-side language, you end up with two sets of every library – a javascript version for the client, and a ruby/java/etc version for server. Two sets of collections, two different network libraries, etc, etc. This is boring. Why not pick one and use it on server and client? Oops, except your hand is forced because History has fixed the client-side language.

5) Event-based programming is an old, old idea. Desktop GUIs have always all been event-based. Threads were only added to windows in, IIRC, Win95. But node.js may well have been many web programmers’ first exposure to the idea. There are upsides and downsides to the event-based approach, compared to threads. But if your language runtime is single-threaded, you never even had a choice. If you’re a good salesman, you sell the upsides regardless. Ruby chose multi-process concurrency, whereas node.js chose event-based concurrency (augmented by processes) .. as did windows ..

6) Lots of well-funded people have a vested interest in making javascript run better. Speedups for client-side javascript translate into speedups for serverside javascript. Moore’s law delivered us into an era where even dumb interpreters were “fast enough”. Ruby and Javascript are both “fast enough” for most of the hobby webapps I’ll ever write.

7) The old split of “clever server code” and “dumb client code” is fading anyway. Client code is doing more. Webapps on mobile devices are able to better handle flaky networks. Client side code quickly gets to the stage of needing all the design patterns which ‘real apps’ have used – mvc, events systems, stuff that backbone provides.

So, javascript on the server makes some kind of sense – with or without hype. It’s not a slamdunk though. I still like my advanced static type systems thankyouverymuch. Quite possibly, javascript is more like the assembly language of the internet; whether at a superficial level like coffeescript or a deeper level like links.

(Thanks to Cameron for interesting conversations on this topic!)