[erlang-questions] Why should you ever use atoms?

Thomas Gebert <>
Mon Oct 12 01:13:05 CEST 2015


I understood for the most part how to use atoms and what they were used 
for, I was just curious what technical advantages they had over a string 
(or binary string) considering that they aren't garbage collected.  The 
O(1) comparison is a valid enough reason that I hadn't thought about, 
and the idea that they are limited by design actually kind of makes 
valid sense.

On 10/11/2015 05:27 PM, Max Lapshin wrote:
> You can think about atoms as of a predefined words of your domain logic.
>
> Each domain description has a limited amount of words that describe 
> it, so number of atoms is also limited by design.
>
> In a properly designed program you should never meet dynamic creation 
> by  list_to_atom, only if you know that it is a
> string representation of already described atom.
>
> In other words, atoms are always written by hands by some human as a 
> part of described functionality.
>
>
> Maybe this will help you.
>
>



More information about the erlang-questions mailing list