3 ms·
This would be more helpful if it dove into the Erlang side, as many of these "gotchas" are due to how Erlang and the BEAM work, and Elixir, being built on top o
by sph 2y ago
This would be more helpful if it dove into the Erlang side, as many of these "gotchas" are due to how Erlang and the BEAM work, and Elixir, being built on top of it and binary-compatible with the entire ecosystem, necessarily exhibits these behaviours.
Keyword lists, charlists vs strings (actually called binaries) [1], empty map matching all maps are obvious if you look at how they work in Erlang.
I haven't written a single line of Erlang though I can grok it pretty well by now. Knowing the entire platform is how you become a productive Elixir programmer, though it seems some devs refuse to look behind the curtains to understand the Erlang side of it, thus never truly understand the power of the BEAM platform.
---
1: I admit I still unsure about the separation of charlists and binaries. As far as I understand it, binaries are stored in their own heap to avoid copying when sending across processes, so are ideal for sharing large payloads, and charlists are not great for UTF-8 content, as they simply are a naive list of integers (hence one of the gotchas). Erlang uses charlists a lot for "string" content.
Elixir made the right choice to use binaries for strings, as they can ensure they are correctly encoded, provide high-level API to deal with the intricacies of Unicode, and still retain compatibility with Erlang by providing charlists and raw binaries for non-UTF-8 data.
- josefrichter 2y agoEveryone should read https://learnyousomeerlang.com https://learnyousomeerlang.com
- facundo_olano 2y ago+1 I'd say it's a great read even if you don't plan to do much Erlang or Elixir programming.
- josefrichter 2y agoexactly
- sph 2y agoThen, when you have code in production, https://www.erlang-in-anger.com/ https://www.erlang-in-anger.com/ (from the same author)
- out_of_protocol 2y agoAlso, elixir team decided to deprecate single-quotes for charlists. No more single quotes (charlist, only for erlang interop) vs double quotes (binary string, used everywhere in elixir) surprises
- pjmlp 2y ago> Knowing the entire platform is how you become a productive Elixir programmer, though it seems some devs refuse to look behind the curtains to understand the Erlang side of it, thus never truly understand the power of the BEAM platform. This should be a lesson learned by all that boost about Scala, Kotlin, Clojure, F#, C and C++ replacements, JavaScript replacement, without bothering to learn the underlying infrastructure they are build upon. Many times the X is going to replace Y advocacy, is a bit hard to achieve when the platform was designed for Y and will never go away from Y, for its whole lifetime.
- miloandmilk 2y agoAgreed, even with f# a first class citizen in the .net world, written, maintained and distributed by Microsoft, I still have needed to gain a working knowledge of c# to properly interact with the .net libs and third party libs (which I absolutely need to do as the f# ecosystem is tiny compared to c#). So at the end of the day I needed to learn two languages to atain my goal of learning one enough to be useful. Disclaimer - I am still learning both - I am no expert on either - and I am still strugling! (Calling erlang from elixir much eaiser!)
- travisgriggs 2y agoElixir is peculiar in this regard because Elixir adherents outweigh erlang adherents maybe 10:1. I really wish that someone would magically transpile all of ERTS so the documentation syntax was uniform. Elixir is almost more of a guest syntax than it is a diff language.