14 ms·
I think it comes down to expressing your intent in terms of that intent rather than confining it to imperative constructs. Pretty much any work on collections
by edgyswingset 11y ago
I think it comes down to expressing your intent in terms of that intent rather than confining it to imperative constructs. Pretty much any work on collections of items is generally simpler and more in line with the semantics of your intentions when working with Clojure or other functional languages or structures, especially when parallel code is involved.
I'd say a specific example would be pmap. It's very difficult to parallelize code as simply as pmap does without functional programming constructs.
- erikpukinskis 11y agoHm. I'm looking at the implementation[1] of pmap.... I don't fully understand the implementation (can anyone point me to something that explains what rets is? Googling "clojure rets" doesn't return anything useful) but it appears to just be looping through the list and parcelling work out to multiple processors. That seems like something simple enough to do in any language with threads and function references, no? I'll dig in some more though. Thanks for the reference. [1] https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L6709 https://github.com/clojure/clojure/blob/master/src/clj/cloju...
- hellofunk 11y agoin this code, "rets" is a local variable used in that function, which is why it wouldn't show up anywhere in google. it's just a variable name.
- edgyswingset 11y agoTo me it comes down to what my intent with the code is. I could write a few simple routines in Go that certain get the job done without much code, but when I read the code I have to perform more mental translation from how the code is written to what my intent was. In contrast, pmap or other constructs such as PLINQ get the same work done with less code that expresses my intent more clearly.