Back to blog home

Predict My Ride: building a Scala cycling app from scratch

Here at Inviqa we’re delivering more and more projects based on Scala – the general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way.

Supportive of JVM environments, and enabling the native use of its libraries, the Scala programming language is seeing fast adoption in both startups and large organisations alike.

Our recent acquisition of software consultancy Byng significantly expanded our Scala expertise, but with increasing demand and need to deliver more Scala projects, our objective is to further grow our in-house Scala expertise.

There are ultimately two ways you can to do this: hire new developers, or train the ones you already have. And with almost 200 software engineers with a fierce appetite for learning and development, we suspected we’d find a few people keen to learn a new programming language.

Screen Shot 2016-12-14 at 18.18.07.png


And we weren’t wrong! The next question was how we should go about teaching Scala (even if we were dealing with very talented engineers). Classroom learning alone has its limitations and is restricted by timeframes. And if that newly-gained knowledge isn’t applied immediately, it’s easily forgotten.

For this reason, we thought about creating a ‘playground’ project – a project with no particular expectations where developers are free to try out different ideas, weigh them up and select the better ones – thus learning the skills of the language and knowledge of its ecosystem.

After scratching our heads for an interesting idea, Myles (the head of our content management practice), Paul (Inviqa’s co-founder and chief of sales), and myself (two of us being keen cyclists) came up with this objective for our Scala trainees: design a simple application that tells you how long it would take you to complete the Tour de France.

We’d take the cyclist’s data from Strava, which offers an API to track cycle rides, and project it onto the routes of the great race itself!

Project codename: Strava De France

And so project Strava De France was born. The original idea was to create a simple and compelling way to show users how long it would take them to complete the Tour de France. With the huge popularity of cycling a second goal was quickly agreed upon – to allow users to upload any route they were contemplating to get a prediction on. Be that a local ride, a sportive event, a race or maybe a milestone ride - like a first century ride!

We formed a team of keen developers, a couple of cyclists, with little or even no Scala experience, but full of enthusiasm to learn it!

So how did we get on?

Screen Shot 2016-12-15 at 16.07.21.png

Creating a Scala app

Given this was primarily a learning and development project, we thought it would be best to only share the project vision with our developers, and let them approach the project in the way they saw fit. So there was no project manager, and no sprints or any of the things you’d usually associate with organising a project.

What we did have was a task board, weekly checkpoints, and one goal in mind: to ‘go live’ as soon as possible. The checkpoints were mainly in place to review progress and identify and tackle any blockers. We aimed to deliver the minimum viable product, delivering it well and quickly.

Finding the right algorithm

The team tried out several algorithms for predicting the ride time. We started with very simple ones, only taking into account the average speed of the cyclist and applying it to the distance. Then we added some more elaborate algorithms that take into account a cyclist’s power output and the gradient of the route for more accurate predictions.

But we needed a way to verify the accuracy of our app. Saying that it takes a cyclist eight days to complete the Tour de France is not convincing! To resolve this, we slightly shifted our focus, adding a second page to the tool. On this page cyclists can predict the time of a ride based on the personal routes they’ve already saved in Strava.

Having a way to actually verify the accuracy makes it easier for us to try different ideas, and choose the ones that work best. Of course there are even more ideas to try, and the prediction accuracy of our app will be even better in the future!

Simplifying the development process

To make the development even easier, we use an excellent continuous deployment tool: ContinuousPipe. It allows us to preview a working application on each pull request in Github, and, once a pull request is reviewed and merged to the master branch, it deploys the application to the production environment automatically. The result: we can focus on code, rather than infrastructure.

Screen Shot 2016-12-15 at 16.07.36.png

Going live

Our app – christened ‘Predict My Ride’ – went live on December 12, 2016.The developers who took part in the project are now fluent in Scala, and have proved they can choose the relevant libraries and components from its ecosystem and deliver a real project using them.

If you have a Strava account, and have used it to save a few rides, do check out our app here.

Just tried out your new’s absolutely class! The level of detail it's taking in is crazy! It gives a better reflection of timings than what’s provided by Strava itself.

A Predict My Ride user

Continuous learning

Our journey doesn’t end here of course. We still have much up our sleeves for Predict My Ride, and we’re really enjoying this approach to growing new skills within our teams.

Want to learn what your organisation could do with Scala? Get in touch!