[erlang-questions] maps or records?

Sergej Jurečko <>
Fri Feb 26 17:21:20 CET 2016


> 
> When keys are defined statically (i.e. they do not change at run time), such as process state, a tuple (such as an Erlang record) is the semantically-correct choice.

On the other hand when debugging maps can be much more helpful. Crash logs produced with maps are so much clearer and printing a map is much easier as well. 

Nothing stops you from having a schema for maps. Use creator functions that return a map with predefined keys and default values. If you're replacing records for maps, this is pretty important. Otherwise it is difficult to find out what the actual state is.

Sergej


More information about the erlang-questions mailing list