[erlang-questions] maps or records?
Sun Feb 28 01:42:03 CET 2016
Whoa there ..
I just want to point out that you shouldn't have record sizes of upwards
100 elements. If the only thing you do is read them you are fine but
normally we do both reads and updates. I would say 50 is the limit but even
then you are pushing it. Above 30 I would consider splitting the array into
I think records has there place. There is some overlap between maps and
records for sure and I think I agree with most of the things that has
already been said.
The dialyzer support for maps could be stronger. It is pretty weak at the
moment. Data modeling with records is easier.
I would consider using records within a module, if it's never changed or
upgraded and never leaks out to any other modules. Maybe between modules
within an application. Maybe. But I think you are better off with maps in
2016-02-28 1:17 GMT+01:00 Michael Truog <mjtruog@REDACTED>:
> On 02/26/2016 06:50 AM, Benoit Chesneau wrote:
> Hi all,
> i tends these days to use maps instead of records, so you dont' have to
> include a file to retrieve the "schema" but I wonder if this is a good idea
> or not. Is there still some usage for records vs maps?
> - benoît
> erlang-questions mailing listerlang-questions@REDACTED://erlang.org/mailman/listinfo/erlang-questions
> Records allow you to specify type specification information, while maps do
> not. Records are basic and efficient with the number of elements 100 or
> less, while maps are great for dynamic use that doesn't depend on type
> specification information. So, for process state information, records
> provide more information when checking dialyzer for problems. Records can
> also provide more checking with dialyzer when storing database or protocol
> data (two places where types are generally important for development).
> For dynamic key/value data, dict can use type specification information
> while maps don't, so there can also be motivation to use dicts instead of
> maps, even if only switching between the two for running dialyzer. maps
> are great for efficient key/value access though.
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions