Northeast Scala Symposium

Luis Miguel Mejía Suárez

I'm a Software developer who graduated from Universidad EAFIT _(Medellín, Colombia)_, **Scala** lover, and currently works for Xebia Functional. I enjoy playing video games. Right now in a ~healthy~ addiction to FFXIV :sweat_smile: Current goal: Become a college professor. "Be the change that you wish to see in the world." - Mahatma Gandhi

Lessons learned from implementing an efficient functional Mutex

Abstract - 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”.