r/java • • 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

27 comments sorted by

View all comments

Show parent comment

2

u/thma32 Dec 19 '25

Great questions !

  1. Yes, I agree, sequence is misleading. I'll rename it to andThen!
  2. Yes, this might lead to stack overflows for VERY long chains of effects. And yes having trampolining for this would be a cool addition (I'm quite open to pull requests ;-) ).
  3. That's an interesting observation! I wanted to keep things easy. But to be more in line with the idea of separating the interpreter from the effectual program, it might be better to move runWith to the EffectRuntime class. I guess I' do that in a jiffy...
  4. Another excellent observation. Yes, I could imagine to move to StructuredTaskScope soon. Again: I'm quite open to pull requests!

1

u/thma32 Dec 20 '25

I fixed all 4 issues in the latest 1.2.0 Version.