10 tips to write fast stack-safe functional code in Scala: the automatic-batch…
summary
A hands-on report about building Auto-Batch, a pure FP Scala library that automatically batches API calls and ships to production; it lists 10 concrete tips: implement a free applicative to collect unitary calls, use smart constructors and inlining, transform problematic recursion with CPS and trampolining plus defunctionalization, and profile hot paths with VisualVM. Benchmarks show millisecond savings at the cost of CPU in places, real StackOverflowError failures drive these changes, and the library largely works in production with measured tradeoffs.
AI-written summary · about
chapters (13)
- 0:00Intro
- 1:23The Context: Logistics
- 2:02The Problem: Going from A to Z.
- 7:23Benefits / Drawbacks
- 8:29Do not choose! Take benefits, leave drawbacks.
- 12:59Abstraction Implementation Abstractions must be Abstract
- 13:29Write your own Dedicated Abstractions
- 15:39Write your own Dedicated Data Types
- 15:57How does AutoBatch work? With Lots of Magic!
- 18:37Profile on Production Data!
- 22:13Make your functions tailrec via CPS
- 27:41Defunctionalization: Functions As Data
- 36:45Fibonacci: Final Version
related talks
53mFunctional Async on the JVM
52mBake Real-life Apps with a Handful of Free, Coproducts & Types
33mApplying Functional Programming Patterns
21mFP for Data Science For Loops Considered Harmful
33mThe state of Scala as a platform for statistical computing
01h 12mAsynchronous and Concurrent Programming in Scala Part 3
01h 28mAsynchronous and Concurrent Programming in Scala Part 1
14mAchieving High-Performance the Functional Way - A Functional Pearl on Expressing High...
