When To Use Elixir’s String.to_atom/1
TL;DR: Use String.to_atom/1 at compile time only.
In the Erlang VM, atoms are not garbage-collected. Because of that, unchecked creation of atoms can lead to memory leaks at best, and a crashed VM at worse. This has been widely discussed on the internet.
Both String.to_atom/1 and the :"string" expression generate arbitrary atoms from strings. Using these two techniques for converting a string to an atom can lead to the above-mentioned problem.