How Promesa Channels differ from core.async
masterPromesa provides a CSP (Communicating Sequential Processes) implementation for Clojure and ClojureScript that serves as an alternative to core.async.
Key differences include:
- No Macro Transformations: The
gomacro is a simple alias forp/vthread(orp/threadif virtual threads are unavailable). This means you can use standard blocking calls insidegoblocks without the limitations ofcore.async. - Virtual Threads (JVM only): On JDK 21+ (or JDK 19 with experimental features), Promesa leverages virtual threads for concurrency.
- No Callbacks: Functions return promises or block, allowing for standard promise composition or thread blocking.
- No Take/Put Limits: Channels can handle more than 1024 pending tasks.
- First-class Errors: Channels support error propagation.
- Cancellation Behavior: When a channel is closed, Promesa immediately cancels all pending
putoperations, unlikecore.asyncwhich allows them to succeed. - CLJS Support: While
gomacros are not available on ClojureScript, all operators (likealts) work using the Promesa API and syntactic abstractions likepromesa.core/loopandpromesa.core/recur.