Colombia Scala Meetup
Lessons Learned from Implementing an Efficient Functional Mutex
Have you ever heard the phrase “FP or Effect systems make writing concurrent code easier and less prone to bugs”? I painfully remembered that during my journey implementing a more efficient Mutex for cats-effect. Come and join me to revive the story and learn together the lessons from experience.
A `Mutex` is a fairly common concept in concurrent programming. Yet, despite that, cats-effect didn’t provide one until recently. The reason was that they are conceptually equivalent to a `Semaphore` of a single permit. And, actually, the original implementation was just that. However, that changed with the `3.5.0` release, which introduced a brand-new, roughly 20-25% more efficient implementation.
In this talk, we will cover the iterative process that we followed from the very original implementation up to the final one that was shipped. Yet, the main idea of the talk is not just to relate the story, but to share the insights that we learned from the experience. Ranging from pointing out how annoying race conditions can be, through highlighting the differences in the imperative VS functional mental models, up to the biggest cliche yet most valuable lesson from all-time science: “standing on the shoulders of giants”.