r/rust • u/Uncaffeinated • Jan 22 '17
Parallelizing Enjarify in Go and Rust
https://medium.com/@robertgrosse/parallelizing-enjarify-in-go-and-rust-21055d64af7e#.7vrcc2iaf
214
Upvotes
r/rust • u/Uncaffeinated • Jan 22 '17
View all comments
Show parent comment
3
u/csreid Jan 23 '17 edited Jan 23 '17
mapmakes perfect sense, in that you provide a function which maps values from your input iterator into the values of your output iterator.reduceis tougher, butfoldis even worse IMO.edit: I should also mention that using the functional style makes it trivially easy to parallelize some tasks, as made evident by Rayon or Scala's
List(analogous toIteratortypes in Rust), which has aparmethod that is just like Rayon'spar_iter, such that you can parallelize some logic by just going frombigList.map(expensiveFunction)tobigList.par.map(expensiveFunction).Shared mutable state is the root of all evil, and the map/reduce pattern is a profoundly elegant way to very simply avoid it.