Our team for the hackathon consisted of Andrea Borsos, Piotr Lazarczyk, Michał Talaga, and me, Harry Mitchinson.
Finding the “Something”
Our idea was to create an application using F# without a pre-defined concept, the main goal was to experiment with the language itself. As a team we had little experience working with F# (or other functional languages for that matter) so we felt that this would be a great opportunity to try learn some of the concepts of functional programming and hopefully see how it could benefit us in future development projects.
Since we needed to learn some F# and what it is capable of, we took some time out of our first morning to go some fundamental courses on PluralSight. We stopped the video after each segment and had a quick chat about what we learned and started to come up with ideas of what to create.
Once we felt that we had some understanding of F#, we began to look at the available resources and found that one of the most popular topics is data science. We found some libraries to help with data access, manipulation and visualisation. Eventually we have decided to use FsLab, as we thought we could load data from some of the Mountain Warehouse sources and display the results with the data visualisation libraries.
The final idea was a web app which consumes and manipulates information retrieved from our database and product feeds to display the results in different views.
What we struggled with
- Learning F# – We normally work with C# and the syntax differences are quite significant.
- IntelliSense type providers when dealing with large data sources – Visual Studio must have crashed close to 100 times between us.
- Coming up with an idea of what to make – It’s a lot easier to have the ‘what’ you’re creating before the ‘how’ you’re creating it.
- We couldn’t get SqlTypeProvider to work with our database – This would have been really powerful as we could query the database directly and infer types but we were unable to find out why it was failing. Our work around was using stored procedures for our database access which worked well for what we needed.
The end result
We met with our initial goal and created a simple web app which loads data from our database and product feeds and displays it as a graph on a web page.
Brands of products
Average spend per order by country
We had an issue when generating this graph since the order value uses the customer’s local currency, which meant results were skewed towards countries with weaker currencies. To resolve this, we hard-coded the exchange rate to GBP for each available currency. If we had more time we could have loaded this data from an API to provide real-time currency exchange rates.
Looking back at our hackathon project, I feel that we barely scratched the surface of what F# and functional programming is capable of. We learned some cool features of the language like type providers, immutability by default, type inference (very cool), pattern matching, easy partial application all with access to the entire .NET library. I also really like that F# and C# projects can exist within the same solution which is something that I will consider in my future development projects.
As a team I think we worked well together, we had regular stand-ups to chat about what we’ve been working on and what we need to do next. Most of us don’t work on the same team at Mountain Warehouse and I felt that it was a good experience to work with people from different teams and get to know them a little better. We had a few disruptions to our team due to external issues and availability however at the end of the hackathon we had something to show for our 3 days of learning F#.
https://fsharpforfunandprofit.com – Great resource for F# samples and tutorials.
https://www.pluralsight.com/courses/fsharp-fundamentals – We started our journey with F# using this course, it includes some good examples of where F# really excels over C# in terms of verbosity, capability and clarity.