{"componentChunkName":"component---src-templates-blog-post-js","path":"/pipe-operator-proposal","result":{"data":{"markdownRemark":{"html":"<h1 class=\"font-sans font-bold break-normal text-gray-900 pt-2 pb-2\">Let's bring that FP sweetness to EcmaScript</h1>\n<p class=\"text-base test-grey-700 pt-4 pb-4\">In my opinion, a good developer is a developer who's always curious about learning new technologies, frameworks, languages, paradigms..</p>\n<p class=\"text-base test-grey-700 pt-4 pb-4\">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.\nIt 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.</p>\n<p class=\"text-base test-grey-700 pt-4 pb-4\">Something wonderful in this language is the pipe operator.\nLet's imagine a function that takes to argument, for example String.split(string, pattern).\nWe can either call it with </p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">def splitString do \n  String.split(&quot;It will split&quot;, &quot;&quot;)\nend</code></pre></div>\n<p class=\"text-base test-grey-700 pt-4 pb-4\">but it is also possible to do </p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">def splitString do \n  &quot;It will split&quot;\n  |&gt; String.split(&quot;&quot;)\nend</code></pre></div>\n<p class=\"text-base test-grey-700 pt-4 pb-4\">Or even shorter </p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">def splitString do \n  &quot;It will split&quot;\n  |&gt; String.split\nend</code></pre></div>\n<p class=\"text-base test-grey-700 pt-4 pb-4\">What's that magical |> operator ? It is called the pipe operator and allows for chaining functions in an extremely readable way.\nWhen using the pipe operator, there is no need to provide a first argument, as the one preceeding the pipe will automatically be passed.</p>\n<p class=\"text-base test-grey-700 pt-4 pb-4\">While searching about it, I've seen there is a <a href=\"https://github.com/tc39/proposal-pipeline-operator\">TC39 proposal for the pipeline operator</a>. It would pretty much be the same syntax as that of Elixir.</p>\n<p class=\"text-base test-grey-700 pt-4 pb-4\">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 !</p>","frontmatter":{"date":"October 14, 2017","path":"/pipe-operator-proposal","title":"TC39 - Pipe operator proposal"}}},"pageContext":{}},"staticQueryHashes":[]}