[Haskell-beginners] Doubts about functional programming paradigm

Darren Grant dedgrant at gmail.com
Fri Dec 11 21:13:50 UTC 2015


Regarding concurrency+immutability with respect to both reliability and
performance:

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.

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.

Regarding the discourse on purely functional programs not having side
effects:

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?)

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.

Cheers,
Darren
On Dec 11, 2015 07:07, "Abhishek Kumar" <abhishekkmr18 at gmail.com> wrote:

> 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)?
> Any links or references will be a great help.
> Thanks
> Abhishek Kumar
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151212/0c44f73d/attachment.html>


More information about the Beginners mailing list