2018 Yearnotes

Last year, inspired by Nat Buckley’s “2017 Yearnotes” and Julia Evans’ “2017: Year in review”, I wrote my own “2017 Yearnotes”. Despite the fact that year saw me getting engaged at the top of Goat Fell on the Isle of Arran and later married (not before completing the frankly colossal act of yak shaving of writing my own PHP web framework), I never published the piece. Reading it now, it’s somewhat strange to read my reflections on a lack of separation between my career and my identity and that my two hopes for 2018 were as follows:

I flat-out failed at the latter and, as for the former, well, you could say I made some progress in that area but not in the way I could have predicted.

And so, some reflections on 2018.

Travelling

In February, I travelled to Tromsø, Norway for a week-long holiday exploring the breathtaking Lofoten islands.

It was the first time I’ve ever been within the Arctic Circle and the combination of natural beauty and outside temperatures of -13 °C made for a heady mix of awe and fearful respect. In retrospect, our desire to take it all in and reach Å within seven days meant we spent too much time on the road but I did get my first exposure to lane assist technology which was frankly terrifying on icy roads.

One of the intentions of the trip was to break our daily habit of being glued to our phones and to break our dependence on constant stimulation from the internet. As with the rest of the year, I admit I wasn’t wholly successful in this endeavour though the place itself was wonderful.

Not long after returning from Norway, we travelled to Cheshire for the first of several weddings this year (the rest would later take us to Liverpool, Shoreditch and Durham) which—in a change from last year—are all-the-more enjoyable when you’re not planning your own.

2018 saw two weekend breaks: the first to sunny Margate and the second, my very first weekend break abroad when we went to Porto, Portugal. The latter gave us 48 hours to spelunk in port caves and seek out pastéis de nata in very good company.

In further attempts to “get away from it all”, we journeyed up to Scotland several times, visiting family in Aberdeen and Glasgow and, in search of true respite, retreating to remote parts of Skye (where I ended up spending hours playing Hollow Knight on the Nintendo Switch).

You may have noticed a recurring theme in the aforementioned journeys: attempts to dramatically switch context, to shake off daily routine and to find some peace outside of daily life in London.

Open source

I began the year by open sourcing the aforementioned PHP web framework I wrote in order to get married: Engine.

$ composer create-project mudge/engine-skeleton:dev-master my-project
$ cd my-project
$ php -S localhost:8080 -t public

The core idea of Engine is that modelling a web application as a pure function that takes in a request and produces a response as an output (i.e. f(request) = response) no longer feels accurate. Perhaps it is better to think of a web application as something that takes both a request and a response as input and achieves its desired goal by using the response for side-effects (think of the response as a sort of open socket). This way, you can easily send your response in bits or stream responses indefinitely.

It was also a great excuse to take advantage of PHP 7.1’s type system and baffle people who haven’t seen any recent PHP. For example, here is some real source code from our wedding site:

<?php
declare(strict_types=1);

namespace Wedding;

final class TravelController extends PrivateController
{
    public function index(): void
    {
        $this->requireUser();

        $this->render(
            'travel.html',
            ['lodges' => $this->user->isStayingInLodges()]
        );
    }
}

In February, I followed this up with a failed experiment to implement a Readable module in Ruby that would allow users to create IO objects from arbitary sources much like Enumerator allows users to create lazy Enumerable objects:

readable = Readable.new do |yielder|
  yielder << "\u001F\x8B\b\u0000[\u0017\x88Z\u0000"
  yielder << "\u0003\xF3H\xCD\xC9\xC9\xD7)\xCF/\xCAI"
  yielder << "\u0001\u0000)^\u0014\xFC\v\u0000\u0000\u0000"
end

gz_reader = Zlib::GzipReader.new(readable)
CSV(gz_reader).gets
#=> ['Hello', 'world']

Sadly, this didn’t fully work due to the sprawling surface area of the IO module (though, later in the year, Dmitry Kandalov’s “Coroutines explained” made me want to try this again with Fibers).

In July, thanks to the help of London Computation Club, a particularly thorny Graph theory problem at work led me to implement Dijkstra’s algorithm in Ruby.

While the initial implementation using arrays worked, it could take an hour to run and so I looked into implementing a priority queue data structure to speed things up. In a surprising twist, I discovered an ideal algorithm not online but in a printed textbook gathering dust on my shelf: Cormen, Leiserson, Rivest and Stein’s “Introduction to Algorithms, Third Edition”. Implementing their description of Fibonacci Heaps was difficult but ultimately rewarding when I published a new RubyGem imaginatively titled Fibonacci Heap.

The data structure allows you to insert nodes with a given priority and efficiently pop the highest priority node from the heap even if that priority has been modified after insertion:

heap = FibonacciHeap::Heap.new
foo = FibonacciHeap::Node.new(1, 'foo')
bar = FibonacciHeap::Node.new(0, 'bar')
baz = FibonacciHeap::Node.new(2, 'baz')
heap.insert(foo)
heap.insert(bar)
heap.insert(baz)
heap.pop
#=> #<FibonacciHeap::Node key=0 value="bar">
heap.decrease_key(baz, 0)
heap.pop
#=> #<FibonacciHeap::Node key=0 value="baz">

Replacing my array-based implementation of Dijkstra’s algorithm with a Fibonacci Heap-based one sped up our build times to mere seconds and was well worth it.

That would have been my open source highlight of the year until something else happened on Christmas Day: Ruby 2.6 was released containing a certain new feature.

That feature was the ability to compose Proc objects using << and >>. While I have dabbled in functional programming before, this feature is of particular interest to me as it is based on a series of patches I submitted in 2015. This is my first code contribution to Ruby to be accepted and, as such, has to be my open source highlight of the year.

Public speaking

I only did one talk this year: “HyperLogLog in 15 minutes” at the Drover Ruby Meetup in November. Huge thanks to those who listened to me rehearse this presentation (some people more than once), the feedback I received massively improved everything from the slides to my delivery.

I’m considering expanding this into a longer talk for the new year so that I can reduce the amount of hand-waving and dig into the mathematics a bit more but I’m still undecided.

Work

The elephant in this post is that in August of this year, after 5 years, I gave notice of my resignation as CTO of Altmetric.

The year leading up to that point had seen some great successes from the team: the rewrite of the company’s oldest data source, the addition of over 8 million patents, a huge user interface and technology overhaul to the flagship product, the integration of scholarly citations for the full database and some especially tricky performance work on the company’s Extract, transform, load processes.

Ultimately though, my struggle to find a sustainable place for myself within the company (as evidenced by my feelings in the previous year and by my attempts to take a break and even start meditating) was in vain. Considering how blissful I felt during my honeymoon at the end of 2017, it was shocking to me how much my work permeated my every waking thought and how quickly I fell into the same trap of my own doing.

At my lowest ebb, I booked a long Bank Holiday weekend off at the last minute and asked many people in my field for advice, many of them from London Computation Club. I am hugely thankful to all those who kindly took the time to speak with me and help me navigate a very difficult decision.

I worked the remaining four months of the year, handing over to my amazing colleagues, confident in their ability to learn from my mistakes and lead the team to even greater success.

I hope to write more about my time at Altmetric in the future as I learnt an incredible amount trying to build a software development team there over five and a half years and I would do it all over again in a heartbeat.

2019

I’m honestly not sure what is next. After working continuously for a decade in London, I plan to take a break from keyboards and screens for a short while before seeing how I can best be of help to others, be that as a contractor or as a full-time employee.

Despite having already published a new open source project this year, I hope to continue seeking a better balance between work and life and, as with last year, get back into running.