[erlang-questions] Best Practice in Map keys: Atoms or Binaries (or Strings)?

Max Lapshin max.lapshin@REDACTED
Sun Oct 2 18:31:38 CEST 2016

I can tell about our experience.

We in Flussonic have disk format of config.  It is similar to nginx-like:

stream ort {
  url udp://;
  dvr /storage 10d;

This format is parsed to a map of maps of maps of maps. I tried to avoid
arrays (lists).  These maps mostly have atom as a key except stream names,
that must be binaries.

It is convenient to use from erlang, but we have to transform it to JSON.
When we read it back from JSON we need to translate binary keys to atoms
and so we have a special function that translates some keys from binary to
atom, and some keys are left as binary.  It is a bit tricky, but it is very
convenient to use.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20161002/aa1feeab/attachment.htm>

More information about the erlang-questions mailing list