Disclaimer: The statements and opinions expressed in this article are those of the author(s) and do not necessarily reflect the positions of Thoughtworks.
Pooja and I have been working on a large scale Scala project at Thoughtworks for more than a year now, and have been using Scala, Play, and a teensy bit of Akka successfully. We have been using future-based concurrency, which is what this talk was about.
Concurrency and parallelism are distinct ideas, often confused with each other. We illustrated how the two ideas are orthogonal, and asserted that concurrency is a great enabler of parallelism.
We then looked at what futures and promises are, and how they can help in achieving end-to-end non-blocking architecture. Now futures and promises aren’t exactly a new idea, and pretty much everyone who has some experience with Javascript or Java is familiar with them. This abstraction is typically dreaded for its callback-based APIs. We demonstrated how Scala, with its great support for functional programming and some advanced abstractions, improves in this respect. We used a running code example to illustrate our point. We began by introducing a callback based solution, and rewrote it with a number of abstractions which incrementally improve its interface. The abstractions were, viz., combinators, for-comprehensions, and Akka’s dataflow DSL (based on delimited continuations).
We also briefly talked about error recovery techniques, bulk operations, and some patterns that we discovered ourselves over past year and a half. Towards the end, we also went over some pitfalls and limitations of futures, and emphasized the fact that even though futures are awesome (which we hope to have convinced the audience of!), there are no silver bullets.
Disclaimer: The statements and opinions expressed in this article are those of the author(s) and do not necessarily reflect the positions of Thoughtworks.
Thoughtworks acknowledges the Traditional Owners of the land where we work and live, and their continued connection to Country. We pay our respects to Elders past and present. Aboriginal and Torres Strait Islander peoples were the world's first scientists, technologists, engineers and mathematicians. We celebrate the stories, culture and traditions of Aboriginal and Torres Strait Islander Elders of all communities who also work and live on this land.
As a company, we invite Thoughtworkers to be actively engaged in advancing reconciliation and strengthen their solidarity with the First Peoples of Australia. Since 2019, we have been working with Reconciliation Australia to formalize our commitment and take meaningful action to advance reconciliation. We invite you to review our Reconciliation Action Plan.