Recap: First Functional Programming for the Web meetup

We recently decided to expand our horizons beyond the quite successful React meetup we host every month. The result was the functional programming for the web meetup - with the inaugural first meetup held last month.


Joe Stanton - The Functional Landscape 

As an introduction to functional programming in general, Joe gives us an overview of object orientation - or more specifically the problems that concepts like state everywhere and mutability bring, along with how functional programming solves these issues and makes writing safe, predictable, multi-threaded code much simpler.

Joe compared building a user interface in JavaScript with React - where your UI is simply a function of data UI = f(data) - to the fundamentals of functional programming y = f(x). This means your UI is predictable and reproducible - enabling you to do things like taking the state of a user's application and loading it up in your own browser for debugging, or server-side rendering which can give massive performance benefits as well as support for browsers and devices that don't support JavaScript.

Coincidentally - this was also a great intro for our next talk.

Viktor Charypar - The immutable truth

Many of us are aware of the benefits of immutable data - but there are a lot of questions left unanswered - most prominently how can copying a whole tree of data be efficient compared to changing a simple value?

Viktor's explanation was a very easy to digest approach to explaining the inner workings of immutable data structures. We are shown the origins of structural sharing and tries and how these concepts merged together to form what we consider a very performant data store.

He outlines Joe's explanation of purity and predictability - noting how immutable data makes for predictable functions and more predictable functions means code which is easier to debug, read and reason about.

Tomas Petricek - F#

Tomas' talk was the outlier of the three - no javascript? But this meetup is targetted at the web!

Tomas introduces us to the the basic concepts of F# as a functional language and as a web platform. We were introduced to the type system in F#, the Suave web framework (think express for F#), DotLiquid - a templating system for .NET, dependency management through Paket, and type providers.

Providers allowed us to connect and fetching external resource feeds (json, xml, etc.) into your application. A very cool feature is using these external data sources at compile time and inferring types from them, so you can know if you've made a type error even if you're loading the content dynamically. Through editor plugins, F# can also do this inferring as you type - providing you with autocomplete for things that aren't even defined locally! Powerful stuff.

A live demo followed Tomas' explanation of these concepts from fetching a news feed, a weather feed and injecting the data into a template which is rendered and served to the client. We also get a sneak peek at deploying to both Heroku and Microsoft Azure. Definitely worth a watch!

Full recording of meetup is available on YouTube.

You can follow Joe, Viktor, Tomas and myself on twitter.

Next month's meetup will be on the 30th September, make sure you don't miss it!