Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
What's new with JavaScript – ECMAScript 2024 (ES15) (medium.com/yourfuse)
1 point by ingen0s on Nov 25, 2023 | hide | past | favorite | 3 comments


I fear that pipeline operators will be overused and eventually become a community best practice unnecessarily bloating code. Also I don't see how this

    const calculatedValue = -10
      |> (n => Math.max(0, n)) 
      |> (n => Math.pow(n, 1/3))
      |> Math.ceil; 
is easier to read / type than this

    let n = Math.max(0, -10);
    n = Math.pow(n, 1/3);
    n = Math.ceil(n);
...and I would bet the later is more performant.


Your point about code bloat is well-taken.

The main idea behind the pipeline operator isn't necessarily to shorten the code but to make it clearer and more maintainable, especially when we're dealing with a bunch of operations. But you're right, it's crucial to use it wisely and not just for the sake of it. On readability, it's really a matter of personal preference. Some folks find the pipeline operator more intuitive, especially those who are into functional programming. Kind of aligns with the way we'd describe the process out loud, like 'take this, then do that, followed by this.' But I can see how the more traditional approach might feel more straightforward to others.

As for the performance aspect, it's a valid concern. Generally, the performance difference between these styles is minimal for most use cases. The decision should ideally lean more towards how clear and maintainable the code is, rather than just on performance metrics, unless it's a critical part of the application.

It really come down to being just another tool in our toolbox. It's great for certain scenarios but not a one-size-fits-all solution.

Appreciate your input on this!


Exploring the new features of ES2024 is like unwrapping gifts at a party – each one brings its own surprise and excitement.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: