malvinbozniak

malvinbozniak

Do piped functions run in parallel

Hi there !
I’m Malvin and I’m new to FP in general.
I’ve started reading about FP and Elixir, and I found them so exciting :slight_smile:

Well, my first question for you is what the subject states.
When I chain functions in a pipe, do them run in parallel (like Unix piped commands do) ?
Or do I need to use specific syntax to do it so ?

Thanks & regards !

Most Liked

NobbZ

NobbZ

The functions are called sequentially, they might trigger computations that happen concurrently or lazily…

Always remember that a |> f() just is a macro that expands into f(a).

david_ex

david_ex

As @NobbZ said, piping in Elixir is just syntactic sugar for readability. If you want to distribute work across CPU cores, you’ll want to look at something like GitHub - dashbitco/flow: Computational parallel flows on top of GenStage · GitHub (there’s a video presentation linked in the README there).

Fl4m3Ph03n1x

Fl4m3Ph03n1x

And flow (as recommended by @david_ex) builds on top of GenStage. Depending on the complexity of what you are trying to achieve, a more barebones approach (using GenStage) may be worthwhile when compared to the more nuclear one using Flow… or Broadway which is also really nice but attacks a different use case (more focused on metrics rather than pure data).

And if you really enjoy concurrent programming, you may want to keep your heads up for Hastega’s successor.

Overall, there are a multitude of options when you want concurrency in Elixir. But since you are starting (welcome, btw!) perhaps a concurrent map elixir recipe will be more suited for your needs:

I still remember when Joe (God rest his soul in peace) introduced pmap in his erlang classes. I was blown away by it’s simplicity, I hope you are too :stuck_out_tongue:

Last Post!

malvinbozniak

malvinbozniak

Very valuable answers :slight_smile:
Thank you all partners !

Where Next?

Popular in Questions Top

New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

Other popular topics Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44608 311
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

We're in Beta

About us Mission Statement