<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 02/27/2016 04:42 PM, Björn-Egil Dahlberg wrote:<br>
<blockquote
cite="mid:CAMjYFoOz8dW8bTh1n8FryOWcX38JJyAo8kzWBYO0F_3-7EMfZQ@mail.gmail.com"
type="cite">
<div dir="ltr">Whoa there ..
<div><br>
</div>
<div>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
a tree.</div>
</div>
</blockquote>
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). I also know
that record use can minimize tuple changes via
<a class="moz-txt-link-freetext" href="http://erlang.org/doc/efficiency_guide/commoncaveats.html#id57442">http://erlang.org/doc/efficiency_guide/commoncaveats.html#id57442</a>
which would not happen with small maps that are only using tuples
(i.e., a map that is not larger than 32 elements, <code>MAP_SMALL_MAP_LIMIT).</code><br>
<br>
<blockquote
cite="mid:CAMjYFoOz8dW8bTh1n8FryOWcX38JJyAo8kzWBYO0F_3-7EMfZQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><br>
</div>
<div>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.</div>
<div>The dialyzer support for maps could be stronger. It is
pretty weak at the moment. Data modeling with records is
easier.</div>
<div><br>
</div>
<div>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 that case.</div>
</div>
</blockquote>
Yes, records can cause maintenance and dependency problems. If the
code needs to be tied to changes of a database or protocol, it might
be worth it, but it depends on the situation.<br>
<br>
<blockquote
cite="mid:CAMjYFoOz8dW8bTh1n8FryOWcX38JJyAo8kzWBYO0F_3-7EMfZQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><br>
</div>
<div>// Björn-Egil</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2016-02-28 1:17 GMT+01:00 Michael Truog
<span dir="ltr"><<a moz-do-not-send="true"
href="mailto:mjtruog@gmail.com" target="_blank">mjtruog@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>
<div class="h5"> On 02/26/2016 06:50 AM, Benoit Chesneau
wrote:<br>
</div>
</div>
<blockquote type="cite">
<div>
<div class="h5">
<div dir="ltr">Hi all,
<div><br>
</div>
<div>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? </div>
<div><br>
</div>
<div>- benoît</div>
</div>
<br>
<fieldset></fieldset>
<br>
</div>
</div>
<span class="">
<pre>_______________________________________________
erlang-questions mailing list
<a moz-do-not-send="true" href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a>
<a moz-do-not-send="true" href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</span></blockquote>
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).<br>
<br>
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.<br>
</div>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a moz-do-not-send="true"
href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a moz-do-not-send="true"
href="http://erlang.org/mailman/listinfo/erlang-questions"
rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>