Functional Programming Inception (Presentation)
My presentation from the Bucharest FP meetup.
Links from the presentation:
- Typelevel Cats
- Generic Iterant Implementation
- Simplified Task-based Implementation
Designing functionality that exhibits the properties of functional programming is hard because it requires a mentality change, coping with immutability and consideration for recursion, performance and polymorphism. This talk is a lesson in FP design that makes use of Scala’s hybrid OOP+FP nature.
We are going to start from Scala’s (and Java’s) ubiquitous Iterator/Iterable types which expose the famous iterator pattern, analyzing its strengths and weaknesses. And then we are going to work our way up to a fully featured FP replacement that has referential transparency and that fixes everything that’s wrong with Iterator, while being more generic.
This lesson in design involves talking about immutability, imperative programming, asynchrony and problems encountered when going FP, like performance considerations, recursion and memory leaks. We are also going to talk about ADTs, higher kinded polymorphism and type-classes versus OOP subtyping. Interestingly the example presented will use both OOP subtyping and type-classes and thus we can make a clear comparison about what to use and when - a problem that the Scala developer has in his daily work.