[erlang-questions] maps or records?
Jesper Louis Andersen
Mon Feb 29 12:40:25 CET 2016
On Sun, Feb 28, 2016 at 2:17 AM, Michael Truog <mjtruog@REDACTED> wrote:
> Records are preprocessing syntax (sweet syntactic sugar) for tuples and I
> am just going based on my benchmarking of tuples. I know tuples are
> generally ok for 100 elements and less (not trying to encourage making
> large records with tons of values).
The tipping point will vary on how many updates you are doing, the given
machine architecture, and if you are looking at the added GC pressure as
well in your benchmarks. Updating a tuple will copy the tuple as a whole,
so if you update a single field only, this is a lot of work to do which has
I often tend to use a map as a monovariant construction: all the keys have
the same type and all the values have the same type. In contrast, I use
records as product types: they have static finite size and every key
encompasses a specific different type.
But of course, the neat thing is you can have polyvariant maps, in Erlang
should you need them.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions