<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 18 May 2011, at 02:25, Todd wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">3. How does one easily multithread an app? For instance, there's pmap in clojure and something similar in akka that lets you map a function across a list, and it allocates threads accordingly...<br><br>literally something like: "pmap(myfun, mylist);"</span></blockquote><br></div><div>The thing that makes Erlang a bit different here is that it is concurrency-oriented from the start. That is, you approach the concurrency model as a fundamental part of your functional design. From that perspective, the "multithreading" of an app might be exploiting in-process concurrency, or otherwise tweaking the "ideal" concurrency model for speed.</div><div><br></div><div>For this, there is no easy answer, but surprisingly often, an application using textbook Erlang techniques for its concurrency model will get very good utilisation of multicore hardware.</div><div><br></div><div>I gave a presentation in 2009 about how writing a generic "one-size-fits-all" pmap in Erlang is less than straightforward.</div><div><br></div><div><a href="http://www.infoq.com/presentations/wiger-multicore-erlang">http://www.infoq.com/presentations/wiger-multicore-erlang</a></div><div><br></div><div>The good news is that it is not that hard to write a custom pmap that suits your particular needs, and this echoes the sentiments expressed in a recent thread about behaviours here on the list: learn the basic patterns, and their intrinsic semantics. Once you understand the mechanics, you can use behaviours where they are a good fit.</div><div><br></div><div>BR,</div><div>Ulf W</div><br><div>
<div>Ulf Wiger, CTO, Erlang Solutions, Ltd.</div><div><a href="http://erlang-solutions.com">http://erlang-solutions.com</a></div><div><br></div><br class="Apple-interchange-newline">
</div>
<br></body></html>