Hacker News new | ask | show | jobs
by plainOldText 2338 days ago
If you really want to learn Elixir, you should learn enough Erlang prior, to get a better understanding of how Erlang/OTP all fits together. Thus, I would recommend the following structure:

1. Read Joe Armstrong's Book: Programming Erlang to learn the basics and the philosophy behind Erlang from one of its creators. [1]

2. Read Erlang and OTP in Action to learn more about the OTP (Open Telecom Platform), applications and gen_servers (which btw, you will find them all over).

3. Learn Elixir, perhaps from one of the books Elixir in Action [3] or Programming Elixir. [4]

4. Finally, start implementing your cool personal project.

Ah, one more thing: Elixir School is also a wonderful resource with tons of information and examples [5] and of course the official Elixir website with its excellent docs. [6]

–––

[1] https://www.amazon.com/Programming-Erlang-Concurrent-Pragmat...

[2] https://www.amazon.com/Erlang-OTP-Action-Martin-Logan/dp/193...

[3] https://www.amazon.com/Elixir-Action-Sa%C5%A1a-Juri-cacute/d...

[4] https://www.amazon.com/Programming-Elixir-1-6-Functional-Con...

[5] https://elixirschool.com/

[6] https://elixir-lang.org/

4 comments

I completely disagree. You don’t need to learn Erlang to learn elixir.

Learn elixir use it, you can be very productive with it. If later for whatever reason you want to dive deeper into Erlang you can.

I’ve used elixir for 5 years now. And I’ve never had to Erlang, the most I’ve done is use some Erlang libraries in elixir.

Elixir can stand on its own

I guess is depends on what you're working on. There are a ton of things I've needed to understand about Erlang. gen_statem, gen_tcp, gen_udp, gen_event, crypto, ssl, etc.
Yes I agree, depending on the project you might need to dip into some Erlang libraries. But that's a far cry from needing to learn Erlang first.

I remember reading things like "you should learn Erlang before learning Elixir to be really effective" scared me off learning Elixir for a little bit as well.

Also, I find the more familiar you get with Elixir, the easier it becomes to read Erlang code.

I've happily dipped into Erlang libs when I need to. I'm also increasingly capable of reading Erlang code though I only write Elixir. I would not recommend starting with all of Erlang before doing Elixir but it may work better for some folks.
I'll briefly weigh in with others that you don't need to know Erlang, at least not Erlang syntax, to be effective in Elixir, and the semantics are identical. I think it's useful at some point to learn that all Elixir modules are just Erlang atoms, and to learn about OTP and that using anything built into Erlang is as simple as calling a function on an Atom instead of on an Elixir module. OTP is awesome, and so is Erlang, but I've been doing Elixir professionally for almost 3 years now and I've still never written a line of Erlang (though I did Prolog in college, on which its syntax is based, and I can generally manage to read most code in Erlang, but I've not found the need to often). Even Erlang libraries can be used from Elixir without any special interop, as long as they're published on hex.pm via rebar3. You just add them as a normal dependency in your mix.exs file, and it just works.
This makes me not want to learn elixir. Learning one language and becoming masterful at it is hard enough. There's too many "learn this language, but also this other language and platform"'s in my life (JVM-based work, and anything in the front-end JavaScript world it feels like these days). It just feels like you are telling people "Here, learn this language, but also learn the assembly instruction set for your architecture as well" -- that's not the reason I choose to use higher level language.
What does it mean for you “learning one language and becoming masterful”?

You can learn the syntax of Elixir, Python, Go, whatever very fast, but becoming a master is much less about its syntax - that is usually a trivial part. It is more about underlying standard library, concurrency, collection, execution model, GC, patterns, and caveats.

yeah probably it's not expressed very well. You don't need to learn the syntax of erlang to understand Elixir. You can call any erlang code from within Elixir in a format that almost completely looks like elixir (the difference is that Erlang modules have a colon and start with a lower case and Elixir modules are upper case).

You might need to learn to read erlang documentation. But I've done quite a bit in Elixir, from standing up websites to writing a VM orchestration engine, and the only things I've needed to read the erlang docs for were:

1) writing an Elixir library that wraps the builtin erlang :ssh module with a more elixirish syntax

2) writing an Elixir library that wraps the builtin erlang :gen_statem module with a more elixirish structure and syntax

3) writing an Elixir library that fixes and wraps the builting :tftp module with a more elixirish syntax

4) figuring out how erlang uses SSL so that I could write a two-way encrypted SSL rpc library.

I did them for fun, but all of these are either in prod or used to make production artifacts, and all of these are of course open source and available, so you can use them and not have to do what I did.

Also FWIW, I have read exactly zero of those books.

Don't be so easily discouraged!

I think there's a distinction between understanding and learning a language. In this case, it helps to understand Erlang in order to learn Elixir. Just like you're eventually going to need to be able to read some C if you dive really deep into Ruby.

Difference is that C is probably considered basic knowledge for a working programmer, Erlang isn't. Professional programming eventually leads to being a polygot anyway.

What if it saved you from having to learn kubernetes though?
You don't need to learn Erlang to learn Elixir. You can just use some what Erlang provides when you need it. Some people want to approach things very ground-up but I've taught people Elixir. It's fine to learn Elixir and you'll get to OTP and all the good stuff.
Thank you for making me know there was an Erlang book by Mr. Armstrong, I will take a look to it.