A Hitchhiker's Guide to the Functional Exception Handling in Java
summary
Shows how Java borrows functional patterns to replace try/catch with composable results: Try and Either for success/failure, Optionals for absence, flatMap to avoid nested wrappers, and left/right projections for Either. Uses the waiver library to implement these types and demonstrates they compose cleanly in real code. Notes performance: creating and filling exception stack traces can collapse throughput to near zero versus ~60K ops when reusing exceptions. Warns it doesn’t eliminate exceptions or typing overhead — use common sense.
AI-written summary · about
chapters (20)
- 0:00Introduction
- 1:15Problems with Java exceptions
- 6:15Go’s error handling approach
- 8:44Benefits of static typing
- 11:14Type-driven development
- 12:58Introducing Try in Java
- 16:10Using Try as return type
- 18:21Producer side with Try
- 20:13Nested Try and flatMap
- 21:43Pattern matching with Try
- 22:46Simulating multiple returns
- 23:26Introducing Either
- 27:56Real-world Either usage
- 29:22Either for alternative paths
- 30:51Absence modeling with Optionals
- 32:16Overuse of exceptions in code
- 33:42Vavr library overview
- 34:25Influencing Java evolution
- 35:31Key takeaways
- 37:18Q&A session
related talks
48mA Hitchhiker's Guide to the Functional Exception Handling
51mHitchhiker's Guide to Functional Programming
55mPain-free Functional Programming with Java 21
49mTen Common Mistakes Made in Functional Java 1
50mHandling exceptions, the functional way
57mTen Common mistakes made in Functional Java
46mDesigning Functional Programs
34mPrinciples of functional programming with examples in Java and Haskell
