TC39 considers renaming flatten and flatMap to smoosh and smooshMap
github.com
github.com
No reason to start changing the spec for it now.
(And I say that as somebody that works at a company with what is likely one of the largest existing Mootools-based javascript codebases around)
Old MooTools is a huge problem child, and did a really bad job being forwards-compatible with their monkeypatching. They took the half measure of only monkeypatching things when there was no implementation.
MooTools eventually got it, and changed their monkeypatching behavior to be more aggressive, such that problem like what we have now wouldn't be a problem. And they kicked out a minor revision to the older libraries, to use this more aggressive monkeypatching behavior (at least for bind. dunno about others?).
Agreed fully: there is no reason to change the js spec for now. MooTools made forward-compatibility incredibly difficult for themselves, 8 years ago, but they spent a bunch of effort trying to un-dig themselves out of the hole since. It's unfortunate, but monkeypatching core JS in this manner was really un-advisable and irresponsible.
Also, assuming we can't use flatten, I am sure we will land on a reasonable name that is not smoosh.
I feel like TC39 is letting anyone with an interest in adding to the language do so. It may take a long long time, may require a lot of technical back and forth, but I feel like ultimately, once the proposal can meet the technical demands required, TC39 will approve the new feature.
A lot of really good things have happened. But I also worry that the language is out of control. Features like pipeline operator or the new smart pipeline operator are daunting and scary capabilities that would make JS vastly less approachable. I don't know if TC39 has the means or spirit to be able to say no.
And at some point, I feel like we need to have some cool-off time to experience what is. We've done so much, so fast. A moratorium on reinventing the language, giving everyone some time to get over the culture shock of it all, and time to practice and learn and experience, so we can collectively learn what the real issues are before carrying on the rapid, fast expansion- it seems in order to me that we have a moratorium, a break, at some point.
Question: "Does this mean that today I can create a new (non existing in the native spec) method, add it in the native object, using it in a certain percentage of websites and force TC39 to change it's future implementation thus essentially hijacking the language evolution process?"
Response: "What that means is that yes, you can create a new nonexistent method, use it in a certain percentage of websites, and actively destroy any proposal trying to add that method name. I hope you don't do that, because that would be pretty sociopathic, but that's absolutely how the process works, and will continue to work for the foreseeable future.
We've made tons of progress with this constraint, and we'll continue to make progress with it."
That does not seem like a sensible constraint for language design. Just say the method name is reserved for goodness sake, you are the ONLY people who get to exercise that power.
It becomes bad when the library checks for an existing implementation of that function, and then assumes compatible semantics
If enough people establish convention - why break it? A proposal that goes against convention is already under such scrutiny. I don't believe "smoosh" in this case is any better than "flatten" but I agree with the motivation and that's far more important than one function name.
If they try and declare a language addition that breaks a non-trivial number of websites, browsers will refuse to implement it. Anything this committee specs out only matters if it's actually implemented. Browsers care very strongly about not breaking websites, so the language committee must as well.
See:
end of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
https://github.com/tc39/Array.prototype.includes/#why-includ...
Why doesn't Javascript start doing something similar? One mechanism for it could be a magic comment at the top of the file (sort of like DOCTYPE or #!/usr/bin/env python3).
"use strict";
to enable language improvements in ES5. This type of string-command is a no-op command if the implementation doesn't recognize the string as special; you put the string-command in there to opt-in to any breaking changes, and then feature-detect to see if things are there in case you're running on an older implementation without those changes.User hrajchert suggested putting this change behind `"use es2019";`. However, in this case that would be tricky, as the change isn't in language semantics, but in the standard library's Array type. If there are multiple scripts on a page that interact, some of which "use es2019" and some of which don't, how do you handle an array being passed between them?
Do you know why the arguments object doesn’t even get to have the array prototype?
A bunch of js libraries - I can’t remember which anymore - detected arguments vs array by looking for .shift and .map or similar on an object and change there behavior accordingly - net result: a large number of major sites stopped working.
Similar for nodelist IIRC