That's super fast. Great. Thank you for all the guidance... :) On Mon, Aug 24, 2020 at 4:21 PM Adam Lancaster <[email protected]> wrote:
> That book is great and explains some nice functional data structures. In > short the key to it is to use persistent data structures: > > https://en.wikipedia.org/wiki/Persistent_data_structure > > The crux of the idea is to only copy the parts that change, sort of like a > diff. > > You can read about clojure’s persistent vectors here too. > > https://hypirion.com/musings/understanding-persistent-vector-pt-1 > > And see this stack overflow post from Jose: > > > https://stackoverflow.com/questions/30203227/does-elixir-have-persistent-data-structures-similar-to-clojure > > Best > > Adam > > > > On 24 Aug 2020, at 14:08, 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/17F9FEEE-AFEB-4C24-A8C1-CCFA6D37F87C%40a-corp.co.uk > <https://groups.google.com/d/msgid/elixir-lang-core/17F9FEEE-AFEB-4C24-A8C1-CCFA6D37F87C%40a-corp.co.uk?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%2BQBBE-prH-RZf8SFBq%3D1AC3%3DWxW77ATdibC_0kF6ZNVEw%40mail.gmail.com.
