3 ms·
Cool writeup. A little ironic, since Erlang's `digraphs` are also mutable!
by elbasti 3y ago
Cool writeup. A little ironic, since Erlang's `digraphs` are also mutable!
- Miner49er 3y agoErlang's digraphs are stored in an ETS table, so aren't they only mutable in the same way that ETS tables are mutable? I don't normally see people consider (D)ETS tables as mutable, however.
- h0l0cube 3y agoYeah. I think even though the article doesn’t use it as an example, what’s really desirable about escape hatching to a systems language is the ability to in-place mutate lots of data. Specifically sparse mutations of a large chunk of data where a copy penalty would be wasteful. ETS is basically just swapping pointers (which I hope is mutation under the hood)
- filmor 3y agoETS tables are absolutely mutable, they even have specific functions to iterate over them while being mutated (https://www.erlang.org/doc/man/ets#safe_fixtable-2 https://www.erlang.org/doc/man/ets#safe_fixtable-2). I use them extensively to share data in a "lock-free" fashion with other processes (a `gen_server` that gets all messages and aggregates data in ETS tables, retrieval via direct reads on a known table name instead of gen_server:call). Mnesia is also (usually) ETS down below.