'Premature optimisation is the root of all evil', Donald Knuth told us in 1974. He was talking about the perceived trade-off between optimising performance and keeping code readable and maintainable. And we all know that we shouldn't even try optimising anything without measuring if there's an actual bottleneck in our product first. Or do we?
Making something faster, even at the micro-level, doesn't always mean that readability suffers. There are a lot of improvements that make code both more readable and better-performing, turning what might be called premature optimisation into just another healthy refactoring. And although some developers like to label almost all forms of optimisation as premature, this depends on a lot of factors, and designing for performance might actually be important for the product you are building. Let us also not forget that optimising, even prematurely, can be a lot of fun!
In this workshop we take a look at examples of optimisations that make sense to both the reader and the end-user of code. We also let ourselves go and prematurely optimise the heck out of some (C++ and Python) code, so make sure to bring your laptop if you have one!