Conventional wisdom has it that using too many functional abstractions in Scala is detrimental to overall program performance. Yet, these abstractions are an immense help if you want to write clean and abstract code. in depth article by Marcin Rzeźnicki.
The gut feeling every Scala developer has is that all the fancy monadic transformers add a lot of non-optimizable indirection (at the bytecode level) that throws JIT off and is slower than what your Java colleagues might have written. But how bad is it?
The article is divided into:
- Devising an Experiment
- EitherT vs Either
- Quirks
- The Use of Inliner
- Either vs Exceptions
- IO
- Either vs Exceptions vs Bifunctor
- Results and Analysis
Very detailed reading with loads of code and detailed analysis of the results for each run. Forget about exceptions. They do not seem to have any performance advantages (but they can have disadvantages if you throw them a lot. And unless you’re building a library, compile with inliner enabled. Great article!
[Read More]