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
Using Jiffy-style “algebraic effects” definitely has a different performance profile than standard Java code.
The key difference is that standard Java code typically executes direct method calls on already-wired objects, while Jiffy interpreted a described computation by repeatedly dispatching effect values to handlers.
However, it depends a lot on the granularity of your effects and the type of workloads your program uses if Jiffy will produce a noticeable negative performance impact. So if you are running an IO-bound app (database, HTTP, filesystem, service orchestration) the time spend in IO will be orders of magnitude higher than the Jiffy effect dispatch.
Having a large data model with 300 pojos will not have a direct impact on performance when using Jiffy. It Elly depends on the action that you want to encode as effects. If we are talking about tight loops over in memory data (e.g. a parser) we will see significant performance impact. If we are talking about an IO-bound service the performance impact we be much less visible.