Scala Love in the City Scala Love in the City

functional programming

Saturday, February 13, 2021

- PST
Finite State Machines for Functional Software Machinery
Join Stream

Finite state machines (FSMs) are one of the simplest models of computation, but it’s this simplicity that makes them so useful. They are expressive enough to cover a wide range of practical problems while remaining easy to reason about. I believe they should be more widely used, and the only reason they aren’t is because many developers only know them in the context of a dusty theory of computation course. This talk sets out to change this!

I’ll first (re)introduce finite state machines as a model of computation. I’ll show that they are very simple, which makes them easy to understand and therefore create and debug. We’ll then see how finite state machines appear just about everywhere. We’ll see examples in the Scala standard library, and in application code from web services and user interfaces. We’ll finish by discussing implementation techniques and further applications.

- PST
An introduction to recursion schemes
Join Stream

Recursion schemes are a topic that often come up in conversations with experienced, knowledgeable developers. For the longest time, I’d just nod and smile and pretend I knew what was going on.

The purpose of this talk is to help people in the same situation. Recursion schemes are far less scary and confusing than the mystique that surrounds them suggests, and this talk attempts to prove it.

We’ll start from first principles and refactor our way to proper recursion schemes, discovering and explaining all the necessary concepts as we go along.

By the end of the talk, attendants should have all the tools they need to understand recursion schemes, and be able to explore the more esoteric ones on their own.

- PST
Greyhound - Powerful Pure Functional Kafka library
Join Stream

Wix has finally released to open-source its Kafka client SDK wrapper called Greyhound. Completely re-written using the Scala functional library ZIO. Greyhound harnesses ZIO’s sophisticated async and concurrency features together with its easy composability to provide a superior experience to Kafka’s own client SDKs It offers rich functionality including: - Trivial setup of message processing parallelisation, - Various fault tolerant retry policies (for consumers AND producers), - Easy plug-ability of metrics publishing and context propagation and much more. This talk will also show how Greyhound is used by Wix developers in more than 1500 event-driven microservices.

- PST
OOP versus Type Classes in Scala
Join Stream

Scala is a hybrid OOP+FP language. If you love OOP, Scala is one of the best static OOP languages. But Scala also exposes parametric polymorphism and can encode type classes.

Thus, developers can also choose to use parametric polymorphism restricted by type classes (aka ad hoc polymorphism). As if choosing when to use immutability versus object identity wasn't bad enough, developers are also faced with a difficult choice when expressing abstractions. Such choices create tension in teams, with the code style depending on the team leader or whoever does the code reviews.

Let's go through what is OOP, what is ad hoc polymorphism via type classes, how to design type classes, go through the pros and cons, and establish guidelines for what to pick, depending on the use case.

- PST
Sweet home Scala 3
Join Stream

I am the type of person who learns new technologies on the job, so I needed a project to explore Scala 3 in-depth. More or less at the same time, we’ve decided to make our apartment just a bit smarter, and I thought this is a perfect occasion to play with Scala 3 (and many other toys).

My plan was simple: start with existing, stable integration: Home Assistant running on Raspberry PI, explore and use Scala on top of that.

Home Assistant has a fantastic ecosystem that reminds me of one we have in Scala. Everything I’ve done with Scala I could have achieved easier and faster with built-in automation, Node-Red or Python but this project was all about learning and fun!

So let me show how it works and how new features from Scala 3 can improve even such a small project.