For more research, the term you want to look for is "Persistent data
structures": https://en.wikipedia.org/wiki/Persistent_data_structure

There are also good talks on the topic, here is one from Rich Hickey:
https://www.youtube.com/watch?v=toD45DtVCFM

On Mon, Aug 24, 2020 at 3:08 PM Bulent Erdemir <[email protected]> wrote:

> Oh, that's it, then. :)
>
> Thank you for your quick reply. I'll follow up with the book and more
> research.
>
> On Mon, Aug 24, 2020 at 3:32 PM Derek Kraan <[email protected]> wrote:
>
>> The short answer is that the BEAM does not do a full copy of a map for
>> every update.
>>
>> For the long answer you could refer to this book:
>> https://www.amazon.com/Purely-Functional-Data-Structures-Okasaki/dp/0521663504
>>
>> On Mon, Aug 24, 2020, at 14:28, Bulent Erdemir wrote:
>>
>> Hi,
>>
>> Elixir applications, due to immutability principle, create a copy of a
>> data structure once that structure is modified (transformed) and if the
>> structure's new value is to be kept via assignment to a variable. Hence,
>> for example, when a Map is visited and some its members are modified , for
>> each modification a copy of the whole Map is created. I understand that
>> creating a new variable is as simple as bumping up a pointer in memory,
>> however, the whole Map is copied over and over again while it's being
>> modified in the application. In other languages without the immutability
>> principle, only the changed portion of the Map would be allocated in memory
>> during a similar operation.
>>
>> In such a situation where there's this copying overhead in almost all
>> data operations in an Elixir program, I would expect the system would run
>> much slower compared to other languages. Yet, I've not seen mention of this
>> problem anywhere on the web. So, probably, I'm missing something. Anyone
>> please would care to comment on this ?
>>
>> Regards,
>> Bülent Erdemir
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "elixir-lang-core" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/elixir-lang-core/CABgUW%2BQiD_Q8bKbe8hV5Q6Lh3PbgVxthOf7zRMASA4qiwqmbrA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/elixir-lang-core/CABgUW%2BQiD_Q8bKbe8hV5Q6Lh3PbgVxthOf7zRMASA4qiwqmbrA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "elixir-lang-core" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/elixir-lang-core/03738aa6-3665-4a4d-a6de-4475d0a0a228%40www.fastmail.com
>> <https://groups.google.com/d/msgid/elixir-lang-core/03738aa6-3665-4a4d-a6de-4475d0a0a228%40www.fastmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/CABgUW%2BRz7-yWu%2Bf3ZW%2BNjT7C%2BxHCnoAEA5eCFCnXPMfZpZ38kg%40mail.gmail.com
> <https://groups.google.com/d/msgid/elixir-lang-core/CABgUW%2BRz7-yWu%2Bf3ZW%2BNjT7C%2BxHCnoAEA5eCFCnXPMfZpZ38kg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KytOYyJ2qZKzZLhJ%2BA82hH%2BL8yOPCa%2B4OcEVRcV9k37Q%40mail.gmail.com.

Reply via email to