Back to JetBrains

If you had a superpower to make a single change to JavaScript – what would it be?

JetBrainsSeptember 22, 20261m
In a Nutshell

Pipeline operator would let JavaScript favor static module functions over class methods, enabling reliable dead-code elimination across all bundlers and delivering smaller, faster bundles. The feature is stalled in committee over syntax debates, so shipping any variant would immediately improve web performance.

AI-Generated Notes

These notes were generated by AI and may contain inaccuracies.

Right now it is pipeline operator. We are heavily dependent on class architecture for everything essentially a bunch of classes with a bunch of methods in them that can't be properly dead code eliminated. If I have a class and it has a foo method and a bar method and I only ever call the foo bar is going to be shipped into my client code no matter what because there's only one current bundler that is advanced enough to actually do dead code elimination for this closure compiler and it's not widely used with pipeline operator.

Pipeline operator encourages more static level like module level function usage. You pass in data objects as one of your parameters but you're calling a static function. Static functions go into a different path for dead code elimination called lexical analysis. It is extremely trivial in order to dead code eliminate everything every static function that is not currently being used in your entire module graph everywhere. This is implemented by every single bundler every minifier everything essentially.

If we have pipeline operator it encourages the use of static functions and moves us away from using class level methods for everything. Because of that, I think we're going to get considerably smaller bundle sizes to end users, which speeds up the web. It's also faster to call a static level function. So we're going to get better performance because of it.

The problem is it's stuck in committee right now. There's a whole bunch of debate about which one is the correct implementation to use for pipeline operator, which token to use if we choose to hack the current proposal, and it's essentially gone nowhere for several years. If I had a superpower, it would be to immediately ship one of the variants. I don't particularly like the hack variant that the current implementation is. There's a different variant called call this or a different variant which is elixir style which would be my preferred. Either would be great, but any of the pipeline operators actually solves a huge class of problem I think.

Keep JetBrains in your library

Save the videos and channels worth coming back to, and find them again in one place.