I want to do parallel computations over collection...
# getting-started
f
I want to do parallel computations over collections and do parallel for loops. Java Streams with parallel for the first case? And the second case?
g
Depends what kind operation you want to do in parallel, CPU heavy are work perfectly on Java parallel streams and you can use it from Kotlin too If your operations are async, coroutines is the way to go (of course you can use it for CPU heavy too, just do not expect better results than with ForkJoin from parallel streams)
f
CPU intensive tasks
g
If you target only JVM and you fine with blocking nature of this API, I would just use parallel streams
f
When you say: “target only JVM,” are you excluding libraries with native dependencies for numerical computations? It will have many loops with numerical operations using nd4j (intensive linear algebra) and simple stuff. I think I could do parallel processes over a Java Stream with the nd4j for the numerical comp inside.
g
are you excluding libraries with native dependencies for numerical computations?
No I mean that you do not write library for Kotlin MPP (JS/native)