Live data from Hacker News

The Elixir of concurrency

cfenollosa.com

21–30 of 40 posts

Re: The Elixir of concurrency

#21
post #12

Great article thanks. One of the things that helped me learn Elixir was to play Elixir golf - it gives you a feel for the language and strengthans your thinking in a functional way. Anyway check out http://elixirgolf.com Disclaimer I wrote a Udemy course on Elixir too, so if anyone wants a 30% here you go... https://www.udemy.com/elixir-for-beginners/?couponCode=Save3...

Thanks, added to the post!

Re: The Elixir of concurrency

#22

1. Bring everything down? 2. Try to capture the error and recover? 3. Kill the crashed process and launch another one in its place? For example, C uses approach 1. Most modern languages with Exceptions like Java and Python use 2. No, in Java and C the "let it crash" (aka the "failstop principle") is also used.

In C the OS process takes place of the Erlang "process". C is designed for multi-process systems (Unix), where a task is often implemented by a number of processes. Upon error the process is terminated, but the system (OS) is never "brought down" by a single failure, remains fully operational and you can retry your command again.

Re: The Elixir of concurrency

#23
post #10

I'm sorry you had such a hard time getting into Elixir. Dave Thomas's book on Elixir is a very good introduction and there are a few other Elixir books out there that can get you started really quickly. The issue really starts when you start writing web servers. I always advise that anyone who wants to start using Phoenix learns how to use Plug first. Phoenix is very macro heavy which can give that magic-is-happening…

I'm sorry if it looked like I had a hard time. It wasn't hard, just long. I consider writing production code of a new language with a different paradigm in just two weeks a success!

I agree with web servers, check my reply below. Plug + Router is enough for most things, and even though everybody recommends Phoenix (maybe because many want to move from Rails to Phoenix?) I found it too complicated since I've never used an MVP framework, I'm more of a devops guy.

Finally, I didn't mention Elixir tests, but they are great. The lack of mutable objects helps a great deal too

Re: The Elixir of concurrency

#24
post #17
post #2

Hi, author here, I’d appreciate any feedback, I always try to update blog posts with new info and fixes :)

Hello. Really nice write up. To follow up on your list of useful learning references, that talk from Chris is a bit old, but it covers all the basics. Nearly everything is still up to date. It is a bit long, but it takes time, cover everything and is not hard to follow. https://www.youtube.com/watch?v=5kYmOyJjGDM It was a workshop to teach the basics of Elixir at a Ruby conference. 3Hours long, but really great :)

Thanks! Added to the post :)

Re: The Elixir of concurrency

#25
> Elixir's novelty, the pipe operator, is a fantastic approach to working with state in a functional manner. Instead of running readlines(fopen(user_input(), "r")).uppercase().split(), try the more readable user_input |> fopen("r") |> readlines |> uppercase |> split.

The pipe operator isn't Elixir's "novelty". Also, why is it better than the '.' syntax:

> fromFile(userInput).getLines.map(_.toUpperCase)

Do you get code completion for it as in an oop-ish language?

Re: The Elixir of concurrency

#26

I just started a new project in Elixir (aimed at systems administrators), and am very excited about using it for what it is good at, and breaking out to system for what it's not good at. To the author, this is one of the best summary writeups I have seen on it, and I read every elixir thing that comes across hn or elixir radar. I think there should be more emphasis that just because elixir doesn't necessarily do comp…

Rustler looks quite nice for embedding native code in Elixir btw: https://github.com/hansihe/Rustler - I had some issues getting it running at first, but the author was very responsive.

Re: The Elixir of concurrency

#27

1. Bring everything down? 2. Try to capture the error and recover? 3. Kill the crashed process and launch another one in its place? For example, C uses approach 1. Most modern languages with Exceptions like Java and Python use 2. No, in Java and C the "let it crash" (aka the "failstop principle") is also used.

In C the OS process takes place of the Erlang "process". C is designed for multi-process systems (Unix), where a task is often implemented by a number of processes. Upon error the process is terminated, but the system (OS) is never "brought down" by a single failure, remains fully operational and you can retry your command again.

While similar, it's not the same. Erlang/OTP/Elixir provides baked in tools to watch, restart, etc. processes. In C you'd need to do this yourself.

Re: The Elixir of concurrency

#28
post #27

Earlier quoted context omitted.

In C the OS process takes place of the Erlang "process". C is designed for multi-process systems (Unix), where a task is often implemented by a number of processes. Upon error the process is terminated, but the system (OS) is never "brought down" by a single failure, remains fully operational and you can retry your command again.

While similar, it's not the same. Erlang/OTP/Elixir provides baked in tools to watch, restart, etc. processes. In C you'd need to do this yourself.

The tools to watch, restart, etc are bash, ps, top, etc

Re: The Elixir of concurrency

#29
Making the jump from Java to Python, and from Python to Elixir is similar to how I feel going from Common Lisp/Scheme to LFE, Lisp Flavored Erlang. The Lisp part is friendly, but learning the really useful OTP is the harder part for me. Even the funcional nature is familiar to me. I need to spend more time on the OTP.

Re: The Elixir of concurrency

#30
post #25

> Elixir's novelty, the pipe operator, is a fantastic approach to working with state in a functional manner. Instead of running readlines(fopen(user_input(), "r")).uppercase().split(), try the more readable user_input |> fopen("r") |> readlines |> uppercase |> split. The pipe operator isn't Elixir's "novelty". Also, why is it better than the '.' syntax: > fromFile(userInput).getLines.map(_.toUpperCase) Do you get cod…

    A |> B |> C second_param
Is the same as:

    C(B(A()), second_param)
It's much more powerful than that because you can create chains of functions that pipe their output i.e.

   Some_data
   |> fetch_reports
   |> email_users
   |> setup_notifications
   |> IO.inspect
   |> affirm_elixir_pipes
It's 100% not the same as dot or arrow! IO.inspect allows you to print details of any data being passed but also returns the first argument passed.

Hope this is a clear explanation of what is happening.

Post reply on HN