[Melbourne-pm] I <3 map & grep too :)

Daniel Pittman daniel at rimspace.net
Thu Oct 27 08:22:16 PDT 2011


On Thu, Oct 27, 2011 at 00:23, Sam Watkins <sam at nipl.net> wrote:
>> I picked up this style of programming from Scala, which does do those
>> operations in parallel - in both senses.  It can start running the later
>> operations before the early ones have finished - and it can use multiple CPUs
>> to process each stage in parallel.
>
> That's nifty indeed, I had no idea Scala could do that.  Can you point me at
> some little example or web page about that kind of capability in Scala?  I had
> a little google at it but didn't find.

It is (well, was) actually pretty hard to find, because parallel is so
deeply baked into Scala; it is much more a core feature, as in lazy,
so unlike the normal "threads" model where you have all sorts of
ceremony, Scala keeps it pretty quiet.  However,
http://debasishg.blogspot.com/2008/06/playing-around-with-parallel-maps-in.html
is a pretty good guide to how you would build out a tool at the low
level.

At the gross level?  s/map/pmap/, and you are done.  (No, literally,
one extra letter maps to using all cores. :)

Because Scala strongly encourages functional programming, most things
can be spread across cores with roughly linear improvement.

All this is true also of Clojure, which seems to be the other solid
competitor in the JVM hosted language space.

Daniel
-- 
♲ Made with 100 percent post-consumer electrons


More information about the Melbourne-pm mailing list