Back to 2014-proposals

Title: Getline considered harmful
Proposer: Frances Buontempo
Type: Tutorial
Duration: 90 mins
Description:
High level interfaces can make code simpler to understand but can sometimes be slower than dropping down to lower level APIs or resorting to neat tricks. People with Computer Science degrees will have been taught complexity notation to use as a guide for how quickly something may run, but this ignores constant factors.On the face of it, getline is a simple high level function to use to read a file, but reading the same bytes over and over again is *obviously* slower than reading them once, so how quickly can we read and parse a file? We will remind ourselves of how to sketch out the algorithmic complexity of code, why we might have to take the constant factors into account and consider various ways of reading and parsing files. On the way, we will recall the complexity guarantees in the C++ standard and see if we can figure out those for various algorithms, including classic sorting algorithms in C++ and python just by way of revision. We will ask if complexity really matters and if just timing what we have is a better way to go.