TC39 - Pipe operator proposal

Let's bring that FP sweetness to EcmaScript

In my opinion, a good developer is a developer who's always curious about learning new technologies, frameworks, languages, paradigms..

That's why, even though I am working as a node.js developer, I have recently started learning about Elixir, a functional programming language, that runs on the Erlang VM and with a syntax inspired by that of Ruby. It is a whole new way of thinking programming, and Elixir as a language is one of the most fault-tolerant. Not surprising when you know that Erlang was built for telephony applications, to have a 99.99% availability.

Something wonderful in this language is the pipe operator. Let's imagine a function that takes to argument, for example String.split(string, pattern). We can either call it with

def splitString do 
  String.split("It will split", "")
end

but it is also possible to do

def splitString do 
  "It will split"
  |> String.split("")
end

Or even shorter

def splitString do 
  "It will split"
  |> String.split
end

What's that magical |> operator ? It is called the pipe operator and allows for chaining functions in an extremely readable way. When using the pipe operator, there is no need to provide a first argument, as the one preceeding the pipe will automatically be passed.

While searching about it, I've seen there is a TC39 proposal for the pipeline operator. It would pretty much be the same syntax as that of Elixir.

Not much to say here, apart from the fact that I instantly starred the proposal and really hope it will be in one of the next EcmaScript versions !