[erlang-questions] Re: Shared/Hybrid Heap

Ryan Zezeski rzezeski@REDACTED
Thu Nov 4 00:35:08 CET 2010


On Mon, Oct 18, 2010 at 7:28 AM, Morten Krogh <mk@REDACTED> wrote:
>
>
> On practical terms, I feel that Erlang some times gives up performance for
> unnecessary reasons. I am especially thinking about mutability.
> There is no reason to give up mutation within a process which is already a
> serializer.
>
> code like this
>
> loop(Dict)
>    receive
>    {put, K, V} ->
>        Dict2 = dict:store(K, V, Dict),
>        loop(Dict2)
>    end.
>
>
> is just a performance wise inefficient way of doing
>
> loop(Mut) ->
>    receive
>    {put, K, V} ->
>        put(K,V, Mut),
>        loop(Mut)
>    end.
>
> where Mut is a mutable data structure.
> In the dict exampe, there is a unncecessary work and garbage collection for
> the functional data structure Dict.
> And you gain nothing, since it is sequential code.
>
>
I think this is a good point.  If you are simply creating a data structure
in _one_ process it should be mutable.  Then when you publish it it becomes
immutable.  I have Clojure's transients in mind.

http://clojure.org/transients

*If a tree falls in the woods, does it make a sound?**If a pure function
mutates some local data in order to produce an immutable return value, is
that ok?*
*
*
*
*


More information about the erlang-questions mailing list