This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-02
Channels
- # adventofcode (76)
- # announcements (1)
- # asami (1)
- # babashka (31)
- # beginners (302)
- # calva (3)
- # cider (1)
- # clj-kondo (1)
- # cljdoc (1)
- # cljfx (63)
- # cljsjs (2)
- # clojure (36)
- # clojure-europe (29)
- # clojure-gamedev (2)
- # clojure-nl (5)
- # clojure-sanfrancisco (2)
- # clojure-spec (2)
- # clojure-uk (71)
- # clojurescript (19)
- # conjure (21)
- # core-async (10)
- # core-matrix (1)
- # cryogen (4)
- # cursive (12)
- # datomic (22)
- # emacs (4)
- # events (1)
- # figwheel-main (7)
- # fulcro (9)
- # graalvm (1)
- # jobs (1)
- # kaocha (17)
- # lambdaisland (1)
- # meander (7)
- # mount (2)
- # nrepl (12)
- # off-topic (35)
- # re-frame (15)
- # reagent (17)
- # remote-jobs (1)
- # reveal (41)
- # shadow-cljs (13)
- # spacemacs (2)
- # tools-deps (24)
Are there general guidelines to determine if something should be implemented as a transducer or go-loop
?
It seems like if something has inputs from more than one independent processes, or if the output can be expressed by repeatedly applying a reducing function to inputs, it can not be a transducer. Is that basically it?
Is it generally worth avoiding the creation of intermediate go processes and channels just to subject values to transducers?
Like, if I have to receive inputs from a few channels in a go-loop
and merge them into a shared state, then do some computation on that shared state which can be expressed as a transducer, what factors influence if you should actually put it in a transducer on an output channel vs just coding that logic into the go-loop.
I know this might be extremely dependent on the particular situation, but are there any common guidelines/tips?
if it's on the channel, then it's not connected to the loop - that might be good or bad depending on the situation
if it's not connected and you take the channel then you're giving your producer/consumer the freedom to do more things
sometimes doing the transducer thing is "what you do" though and in that case you want it to be internal (whether it's on the channel or in a go loop)
keep in mind also that transducers on channels may be executed by either the producer or consumer thread of the channel so you have less control about where that's happening
if it's inside a go-loop, you know it's in the go pool
by "it" I meant a transducer
also consider pipeline[-blocking,-async] as another important option here with parallelism