Fork me on GitHub
#funcool
<
2022-11-18
>
TC21:11:03

The new CSP features are pretty exciting — I had mostly stayed away from core async because of things like needing to worry about accidentally blocking inside a go loop. A couple questions: • It looks like JDK 19 vthreads are not required, since there’s a fallback to p/thread, is that right? (Obviously the latter is not as lightweight) • The docs say “The promesa channel and csp patterns implementation do not intend to be a replacement for core.async; and there are cases where https://github.com/clojure/core.async is preferable” ◦ Are these cases only where the vthreads are not available? • WRT to CLJS not currently being supported, is the recommendation there just to stick with core.async?

niwinz09:11:40

Hello @U02SPB5Q6A3 Lets try to answert your questions: 1. Yep, the vthread is not hard requirement, but is a nice-to-have, the standard platform threads are used as fallback. 2. core.async right now has more patterns and helpers than promesa, and promesa does not intends to have solution for all the user cases of core.async. 2b: i gues noup, I mean, the promesa csp module is pretty usable in real world without vthreads. I have tested (and greatly surprised) that I have been able have 15k real platform threads running without blowing the memory; so there are cases where the absence of vthreads is not real problem. Obviously if you want to have 1M of them, or is latency sensitive on spawning a huge amount of short living real platform threads, probably you will need to stick with core async.. 3. cljs is not supported because of two main reasons: cljs does not benefit of using blocking operations so you will be limited to the already existing syntax helping macros that promesa provide for working with asyncronous code; and the second reason is because I don't really need it, personally I think channel implementation is not very usefull on frontend code (i will explain and put better references on the upcoming blogpost). It can be implemeted, but depends in the real interest on having it, and with the obvious first limitation that I have comented... I have developed it with initial target on using it on backend (my own first use case is replace all the websocket realted core.async code with more simpler approach using vthreads on penpot project where core.async is used right now extensivelly on the background tasks and websockets code)

niwinz09:11:45

In any case, just for redundancy, the promesa csp impl is very experimental and is still not very hard tested in real environments, it will change over time and we will test it on real production environments, and some missing features will be added.

niwinz09:11:31

And yes, promesa csp impl intend to be less error prone, removing the need to have thinking on differentiation on parking and blocking, unifying all under blocking operation and leaving the JVM to handle it for us.

👍 1