Reducers, or understanding the shape of functions

Swift is a peculiar language in that it combines many “paradigms” – styles of programming – to create a sort of melting pot where developers can pick and choose which style they prefer. One such paradigm that I’m very interested in is “functional programming”. Wikipedia states:

In computer science, functional programming is a programming paradigm where programs are constructed by applying and composing functions. It is a […] paradigm in which function definitions […] map values to other values, rather than a sequence of imperative statements which update the running state of the program.

Applying and composing functions. Sounds a bit abstract, doesn’t it? What does that actually mean? In this article, I want to show you concrete examples of this paradigm in Swift through reducers, and teach you a core skill in functional programming: understanding the shape of functions.

Bridging the gap, or why every kid should have the opportunity to code.

I live in London. More precisely, I live in the Royal Borough of Kensington and Chelsea. Sounds fancy, right? And sure, you can find endless amounts of Russian oligarchs, old English aristocratic families, and newly wealthy European families. Cross a single highway called Westway, however, and you enter one of the poorest neighbourhoods in London.

Hello, there.

print("Hello, world!")

That was the first line of code I ever wrote. A bit cliché? Definitely. Completely unoriginal? Most likely. And yet, that may have been the most important line of code I will ever write. Because ever since that day, ever since that moment, I fell in love with coding. Ok, this is definitely becoming too cliché.