Taking a look at the proposed pipeline operator in JavaScript, seeing why it is useful, and comparing the Hack vs F# proposals. Plus getting both side

Pipeline operator: Hack vs F#

submited by
Style Pass
2021-09-17 15:00:15

Taking a look at the proposed pipeline operator in JavaScript, seeing why it is useful, and comparing the Hack vs F# proposals. Plus getting both sides of the argument.

Last week the Hack proposal for the pipeline operator has advanced to stage 2. The competing F# proposal is still in stage 1. This has caused quite a stir in some corners of the JavaScript ecosystem.

In this post I will try to explain the differences between the two approaches. I'll do so in a way which is more friendly for beginners, as the documents you'll find on GitHub are quite technical.

In the example we are an HR manager. We are responsible for doing the yearly salary rounds at our company. Instead of using Excel we program this routine in JavaScript.

The performance is a number from 0 to 10, which indicates how well an employee did this year. It will determine how much of an increase the employee will get.

The reason our helpers copy instead of mutate, is that we, as the HR manager, want to compare the old and previous wages. We like to use the developer console to interactively run some simulations. When the employee is not actually mutated we can call our helper functions safely, without fear of mutating the data.

Leave a Comment