Tristan Penman's Blog

Parsing mathematical expressions

31 March 2019

Ever wondered how you can implement a simple calculator in C++? You probably haven’t, but it is interesting to look at how the problem can be solved very elegantly using code generation. This post looks at how we can use two code generation tools, Ragel and Lemon, to generate a parser for simple mathematical expressions like ‘(1.2 + 1) * 2.5’.


Why I came back to Australia

23 February 2019

A lot of people ask me why I came back to Australia, or more pointedly, why I left Amazon. It’s a good question, because after spending several years getting a grasp on the basics of Machine Learning, I had found myself in a good team, working on a product recommendation system, powered by a very innovative neural network framework. The problems we faced were fascinating, and I was able to live quite comfortably.


Reading list progress report

19 February 2019

Seeing as we are past the middle of February, I thought it would be a good idea to write a quick progress report on my reading goals for 2019. While progress has been slow, and on numerous occasions I have given in to temptation and found myself reading things other than the books on this list, I hope that writing this post will keep me on track!


A reading list for the year ahead...

10 January 2019

Like many book lovers, I am guilty of something that is common enough that there is even a Japanese word for it: Tsundoku. That is, the habit of acquiring reading materials but letting them pile up in one’s home without reading them. In an attempt to combat this (and to improve my reading habits) this post takes a different approach to the typical reading list blog post…


Tail Call Optimisation and C / C++

08 December 2018

At a recent Melbourne C++ meetup, the topic of tail call optimisation was raised. Tail call optimisation (or TCO) is a fascinating optimisation technique that is commonly discussed in the functional programming community, because of it’s importance in the implementation of efficient recursive algorithms. However, it is often overlooked when discussing other programming languages. This post gives brief overview of TCO, and looks at its use in C and C++ compilers.


Extending Ruby with C++

16 September 2018

In my previous post, I covered the basics of writing a Ruby gem with native extensions. We saw how C can be used to enhance the functionality of the Ruby language. This post takes the idea a step further, and looks at how to extend Ruby with C++.


Writing a Gem with native extensions

29 August 2018

There are many reasons you might want to write a Gem using native extensions. Performance is perhaps the most obvious. CPU heavy tasks, such as number crunching, can be re-written in C, to be many times faster than the equivalent Ruby code. For the daring among us, you can use multiple threads, GPUs, etc.


Build your own workstation

17 April 2018

A recent endeavour of mine has been to build a Linux workstation, for my work in the Data Science and Machine Learning space. The primary technical requirement for this machine is full support for two GTX 1080 Ti graphics cards.


Porting an Asteroids clone to JavaScript

08 January 2018

This post shares my experience porting an SDL-based Asteroids clone to the web, using Emscripten, an LLVM-to-JavaScript compiler.


Sparsehash Internals

11 October 2017

One of the C++ topics that have I wanted to write about is Google’s Sparsehash library. Sparsehash provides several hash-map and hash-set implementations, in particular sparse_hash_map and sparse_hash_set, which have been optimised to have a very low memory footprint. This post dives into the details of how this is achieved.


Fixing the authorship of a Git commit

11 December 2015

When working on code across multiple organisations, one problem that I have run into more often than I would like, is correcting the authorship of Git commits. You know the scenario - you create a new Git repository, but forget to set the appropriate user name and email address before a flurry of commits. This post covers one strategy that I have found useful for fixing incorrect Git commits.


WordPress and Docker

01 December 2015

With so much of my recent work involving WordPress, it made sense to re-evaluate my workflow and figure out how it might be improved. This post shares some of the things I have found useful in setting up a Docker-based environment for WordPress.


Implementing a Distributed Hash Table with Scala and Akka

26 November 2015

After diving into Scala and Akka earlier this year, I had been looking for an opportunity to apply what I had learnt to a non-trivial problem. The Chord Protocol seemed like a good place to start, and the project ultimately resulted in a talk at the Melbourne Scala User Group. Slides for my presentation, Implementing a Distributed Hash Table with Scala and Akka, are now available on Slideshare.


Installing R and RStudio on Mac OS X

20 October 2015

Although installing R and RStudio on Mac OS X wasn’t particularly difficult, I thought I would make some notes here, in case they’re useful to someone else. These instructions make use of Homebrew, a convenient command line package manager for Mac OS X.