TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Elixir Gotchas

105 pointsby lobo_tuerto11 months ago

5 comments

sph11 months ago
This would be more helpful if it dove into the Erlang side, as many of these &quot;gotchas&quot; 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.<p>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.<p>I haven&#x27;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.<p>---<p>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 &quot;string&quot; content.<p>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.
评论 #40799047 未加载
评论 #40798649 未加载
评论 #40798689 未加载
arrowsmith11 months ago
This is slightly out of date:<p>&gt; The other mystery here are the 2 different syntaxes in use for charlists – single quotes (&#x27;charlist&#x27;) vs. the ~c&quot;charlist&quot; sigil. That’s a rather recent development, it was changed in Elixir 1.15, after some discussion … &gt; &gt; So, it’s now less confusing but still confusing – which is why it made this list.<p>Charlists with single quotes are deprecated since Elixir 1.17 - the ~c[…] sigil should always be preferred.<p>So hopefully that will reduce the confusion!
评论 #40771765 未加载
fredwu11 months ago
Are these even gotchas if they are all very well documented in the official documentation already? I was expecting to see some unusual or undocumented behaviours...
评论 #40798345 未加载
评论 #40798551 未加载
robxorb11 months ago
Unless you are fine letting old homebrew work its &quot;magic&quot; - the installation is too lengthy and involved for a new language. It should just be click, download:<p><a href="https:&#x2F;&#x2F;elixir-lang.org&#x2F;install.html" rel="nofollow">https:&#x2F;&#x2F;elixir-lang.org&#x2F;install.html</a><p>That is the biggest gotcha for me. There doesn&#x27;t seem to be a simple installer or binary you just get up and running unlike other major languages. Is it a distribution issue with erlang or something? I&#x27;d have thought it&#x27;d be easy to package it up.
评论 #40798888 未加载
评论 #40798625 未加载
评论 #40799517 未加载
cutler11 months ago
Elixir also doesn&#x27;t have arrays so you have to fall back on Erlang&#x27;s extremely clunky variant or, worse, shoehorn a map.
评论 #40798540 未加载
评论 #40798965 未加载
评论 #40798616 未加载
评论 #40802078 未加载
评论 #40802156 未加载
评论 #40799020 未加载