by franciscop · 4y ago · 0 comments
This is the same with the pipe operator, we already have arrow functions, thenables, and TWO different types of .pipe(), which makes syntax a lot cleaner when needed. IMHO adding this pipe operator "|>" would be a mistake, it only complicates the language making:
- Browser competition harder, when the language is really broad and difficult it makes it harder to create a new engine.
- Mastering Javascript harder, there's a lot broader amount of concepts there which are not really useful except.
- No real benefit as I explained. For some people's worldview it's better, but for us the rest of mortals[1] it's just overhead.
A really good indicator of whether something is useful in core JS is: has someone made it into a library or sublanguage[2] that is widely used? Or a language feature? Promises and events def passes that test, while Symbols, classes, generators and this new pipe operator definitely don't. Bigint is arguable, since it passes the test but remains fairly fringe use-case in JS.
[1] Note that I'm the first one to experiment with JS and try weird things! I'm just saying that these should remain broken experiments on my computer, or nice libraries in npm, but not part of the specification that no one uses.
[2] Coffescript, JSX, Typescript, etc.
1) Advanced features that cannot be replicated without runtime support
2) Syntax sugar
Symbols, BigInt, and generators are the former. Pipes and classes are the latter. (1) gives library authors access to low-level primitives that can allow them to do things that were literally impossible before (I've gotten a lot of use out of Symbols, personally), but they aren't often used directly in application code. (2) are usually more application-facing, and may or may not be a big enough quality of life improvement to justify their existence.
I guess what I'm saying is: just because you haven't seen lots of Symbols or generators in the wild doesn't mean they aren't having an impact, or weren't worth adding.
It’s probably getting to the point where it’s no longer necessary in a lot of cases, but these constructs that “nobody uses” were able to implement the newer and more widely features long before they were available in browsers.
> they aren't often used directly in application code
The problem for me with this is that abstractions leak, and suddenly you are wondering why you cannot add two simple numbers or why there's a 3rd level of hidden properties in objects.
(1) Adds more possibilities, performance improvements, operational shortcuts.
(2) Adds redundant way to do one thing. IOften confuse more than help in the long run.
The former also should not be excluded from application code. Application coder should also be familiar with what those are for.
Also, JavaScript has some rather quirky behavior. I'd rather see a stricter JavaScript without the quirky stuff take it's place.
FYI, symbols are incredibly useful!
Regarding classes, intuitively I agree, but I'm curious about your reasoning.