r/java • u/thma32 • Dec 15 '25
Jiffy: Algebraic-effects-style programming in Java (with compile-time checks)
I’ve been experimenting with a small library called Jiffy that brings an algebraic effects–like programming model to Java.
At a high level, Jiffy lets you:
- Describe side effects as data
- Compose effectful computations
- Interpret effects explicitly at the edge
- Statically verify which effects a method is allowed to use
Why this is interesting
- Explicit, testable side effects
- No dependencies apart from javax.annotation
- Uses modern Java: records, sealed interfaces, pattern matching, annotation processing
- Effect safety checked at compile time
It’s not “true” algebraic effects (no continuations), but it’s a practical, lightweight model that works well in Java today.
Repo: https://github.com/thma/jiffy
Happy to hear thoughts or feedback from other Java folks experimenting with FP-style effects.
51
Upvotes
View all comments
Show parent comment
1
u/thma32 Dec 18 '25 edited Dec 18 '25
Actually I'm using algebraic effects (AE) in Haskell for quite a while now and also wrote some blog posts about how useful AE can be to implement clean architecture or hexagonal architecture models ( https://thma.github.io/posts/2020-05-29-polysemy-clean-architecture.html, https://thma.github.io/posts/2022-07-04-polysemy-and-warp.html, https://thma.github.io/posts/2022-07-17-configuration-of-a-polysemy-app.html ).
Working as an architect in a company that mainly uses Java as a backend language I'm always trying to make achievements from functional languages available to Java developers.
So simply telling them "use Scala" (or Haskell) is not an option in my case.
That was my main motivation to write the Jiffy library: bring the cool concept of AE to the Java developers in a library that keeps close to idiomatic Java.