CS question: calculus vs algebra

I have never been sure if calling something a “calculus” as opposed to an “algebra” is intended to communicate something important in computer science. For example, people talk about the “lambda calculus“. But they also talk about “process algebras“. What’s the key property that would make some system a ‘calculus’? Or is it an arbitary naming choice, just indicating the personal preference of the creator?

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.