Hacker News new | ask | show | jobs
by elbasti 857 days ago
Cool writeup. A little ironic, since Erlang's `digraphs` are also mutable!
1 comments

Erlang'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.

ETS 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). 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.
Yeah. 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)