If Only I Was Multi-threaded…

 2 min read

I’ve taken on more of a software engineering role since starting my PhD, despite designing some FPGA-based asynchronous digital logic that connects up to SpiNNaker last year. This paradigm shift (which, clearly, improves synergy) has made me broaden my “coolness scope” to include some new things. I think this mainly started when I attended SASO last year and talked to some really interesting people. Two suggestions, off the critical path, were to learn Lisp because it’s unlike most other programming languages, and to use Proto to model spatially-distributed systems.

Unfortunately I haven’t really played with Proto, but I did have a look at Lisp. Lisp has a very simple syntax and is over fifty years old, yet it has lambda expressions and its macros have clearly influenced things like closures in more modern languages like Python. Shortly after I played with Lisp, I decided I should probably broaden my programming skillset. I write everything in Python, C++, or C depending on what I’m trying to do and what hardware I’m working on. So I transcribed a simple Python+PySide tool into Java+Swing and C#+WPF as a learning exercise. Another goal was to rewrite it in Lisp+CommonQt but that might be a bit too far from my comfort zone…

Anyway, the reason I bring this up is because I stumbled onto Avdi Grimm’s blog (specifically his post on code editors while searching for some Lisp development tools) and ended up reading quite a few other posts. He decided to learn a new programming language every year which was kind of similar to my transcription learning exercise, I suppose. Long-story-short: I started thinking about some things I’d like to learn too:

  • Io is a prototype-based OO language that looks quite fun to play with. It uses message passing for method invocation which sounds quite interesting!

  • C++11 has loads of cool new features over regular C++ (the second language I ever learned — after BASIC on a ZX Spectrum!). The introduction of atomic types into the standard library should make cross-platform lock-free programming easier!

  • Stackless Python has been on my list for years now; ever since I discovered that CCP use it for EVE Online. The idea is actually very similar to how we structure applications for SpiNNaker: programs are represented as graphs detailing how a set of tasks are joined together. In SpiNNaker we call it a problem graph, each node is a problem device, and each edge is a multicast network route. In Stackless Python, each node is a tasklet running as a micro-thread, and each edge is a channel.

  • Google Go has only recently been officially released. It’s a statically-compiled language that supports concurrent programming techniques similar to those in Stackless Python. The two features (in addition to the concurrent stuff, of course) that really caught my interest are:

    • that it is compiled and can be used in place of C/C++ for some things, and

    • interfaces (i.e. abstract classes) are implied by impressively flexible function overloads.

    Russ Cox’s video A Tour of Go demonstrates these really cool features — well worth watching!

If you study these points carefully you may be able to pick out a trend. I think concurrent programming has always been an interest of mine, but I’ve only recently realised how much I care about it. Working with SpiNNaker has clearly been a catalyst for this, and some of my more recent consultancy work has probably helped too.

Concurrency is going to become increasingly important as computers gain more and more application processors. SpiNNaker’s final goal of a one million processor super-computer will take these concepts to the absolute extreme. Perhaps I should start with porting Go to an 864-processor SpiNNaker fragment that just happens to be on my desk…