https://github.com/simm-is/partial-cps is a continuation passing style transform for Clojure & ClojureScript that only induces callbacks at desired breakpoints. An async-await implementation is provided, including a sequence abstraction with transducer support. It is currently used to implement high performance async persistent data structure implementations for Datahike. Compared to other frameworks it provides more transparency and much better performance, because it transforms the code less and avoids scheduling overheads that could reach 10-15x in our experiments. Feedback is very welcome.
Fascinating. Any opportunity to make use of JVM’s new VirtualThreads here?
VirtualThreads are integrated in the underlying runtime and provide a similar ability to pause execution with a continuation for all code in the JVM, if you have them you don't need to implement transformations like this because you can pause your normal execution (It is stunning that JS doesn't have them yet). Once you have CPS though you can implement almost any control flow primitives yourself, including virtual threads, and add a few more compiler passes such as closure conversion (like in Chez scheme), and then run in an environment without any functional primitives, e.g. native code. This is not my current priority, but in a different way I have compiled a subset of Clojure to CUDA here https://github.com/plai-group/daphne for example. I plan to make more use of CPS in simulations for the simmis project, see #simmis.
https://github.com/ring-clojure/ring has been released. Included in this release:
• wrap-content-length middleware has been added that automatically sets the content-length for strings and files
• :acceptor-threads and :selector-threads options have been added to the Jetty adapter for better tuning
• Jetty has been updated to version 12.1.0
And Ring 1.15.1 hot on its heels because of course I'd discover a bug just after the release.