<p dir="ltr">Regarding concurrency+immutability with respect to both reliability and performance:</p>
<p dir="ltr">One way to think about synchronizing concurrent programs is by sharing memory. If the content of that memory changes, then there is a risk of race conditions arising in the affected programs. (A common source of vexing bugs, and complications for compilers.) But if the contents are somehow guaranteed not to change (ie. a specific definition of immutability), then no race conditions are possible for the lifetime of access to that memory.</p>
<p dir="ltr">Although this is a greatly simplified illustrative explanation, it is generally at the heart of arguments for immutability aiding performance. Unchanging regions of memory tend to permit simpler sorts of models since limitations are lifted on synchronization. This in turn allows both more freedom to pursue many otherwise tricky optimizations, such as ex. deciding when to duplicate based on cache geometry, trivially remembering old results, etc.</p>
<p dir="ltr">Regarding the discourse on purely functional programs not having side effects:</p>
<p dir="ltr">Writing pure programs without side effects is a little tricky to talk about, since this has some very precise technical meanings depending on whom you talk to. (What constitutes an effect? Where is the line between intentional and unintentional drawn?)</p>
<p dir="ltr">Maybe think of this statement as part of the continuum of arguments about languages that allow us to write simpler programs that more precisely state the intended effects.<br></p>
<p dir="ltr">Cheers,<br>
Darren<br>
</p>
<div class="gmail_quote">On Dec 11, 2015 07:07, "Abhishek Kumar" <<a href="mailto:abhishekkmr18@gmail.com">abhishekkmr18@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am a beginner in haskell.I have heard a lot about haskell being great for parallel programming and concurrency but couldn't understand why?Aren't iterative algorithms like MapReduce more suitable to run parallely?Also how immutable data structures add to speed?I'm having trouble understanding very philosophy of functional programming, how do we gain by writing everything as functions and pure code(without side effects)?<div>Any links or references will be a great help.</div><div>ThanksĀ </div><div>Abhishek Kumar</div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div>