-
Notifications
You must be signed in to change notification settings - Fork 19
Conversation
What percentage of sites does this affect? |
What is this word? |
How about |
See also IRC #tc39 from today. |
I think we should rename flatMap to smooshMap in this case. (Not kidding.) |
We should rename object to dictionary too... |
Swift recently renamed flatMap to compactMap, for clarity. How about Array#compact and Array#compactMap? |
I know |
In this case, |
|
(Sure, MooTools used mainly in ancient sites, but I had many issues about compatibility with also ancient PrototypeJS.) |
Please let's not add We can use a gitbub bot to search and create an issue on all affected repositories, for example. Flatten is the intuitive name for the feature? So that's what should be used. |
What’s the incompatibility between the two implementations? Is it just the default value for the depth parameter? If so, how about aligning with Mootools? |
I've opened up an issue with Mootools: mootools/mootools-core#2797 - however, they have not had a release in more than 2 years (which should hint at it's usage/adoption level), so I'm not too optimistic that they might change their implementation. |
What about importing native prototypes? As in |
I'm also in favor of squash, as smoosh isn't intuitive for many non-native English speakers. |
@callmevlad unless you could get all sites using older mootools to upgrade, it wouldn't make a difference. @Haroenv that would conflict with https://npmjs.com/web |
@ljharb, I meant the idea, syntax could be different to avoid conflict. For example |
Other name for flatMap are chain, join, bind |
@Haroenv for this case, we already have bind syntax: import flatten from 'Array';
array::flatten(); but it's not very convenient. Real prototype method without any imports / extensions much better. |
I get your point, but it would avoid the conflict. I would assume that build tooling can be set up to add the binding of prototypes by default to the native ones, which would avoid the hassle. Seeing as how many times we see conflicts, having a way to definitely avoid them, rather than trying to find the least breaking name would be interesting IMO |
// edited from author. |
@gkatsanos this is the second comment you've made on this thread that's inappropriate. I'll point you to our code of conduct - if you continue to be hostile, further moderation steps will be taken. To answer your question, browsers care about Mootools (and users of sites that use Mootools), and thus so too must everyone. |
Seriously? prototype polution has been frowned on for years with warnings that if you do, your site may break... Are we really backing down from that warning and letting these old sites dictate our future? What’s the point of warning and cautioning developers if don’t honor our warnings? |
@ljharb My wording was inappropriate but judging from other comments, and on twitter, the core of my message is the popular opinion. I urge anyone who is against not using "flatten" in the official spec in order to accomodate an anti-pattern of "Mootools" to upvote this comment. Was this thread opened in order to see what the popular opinion is? In that case the native JavaScript language should not change it's upcoming new specs in order to accomodate obsolete libraries. I don't even understand why we're discussing it. Aren't there IE6,7,8,9 quirks that the new JS spec doesn't support and the opposite? Definitely so. So why all this talk about a library not in use since years? Is there interest because one of its' creators is involved in TC39 or something? |
@aluanhaddad sorry, but I don't understand what you mean :) I don't want compile to another version of JS. Even if website will crash - it's ok. Fine. It's uses old library. If authors of library extending prototype of standard object without checking existing value - why this should be a problem? In general, problem is in conflicts of names between old library and new standard. There is a lot of libraries. With a lot of names. |
I've been in the business of attempting that working for 2 browsers over the past 8 years. Don't hold your breath. :/ |
Please decline this PR :( |
(Apologies if I should take this elsewhere)
This is concerning and incompatible with what I feel is the fundamental idea of the web, which is to provide a network of information. You don't expect to go to a library and be unable to read a book because it was published ten years ago. Why should we punish users just to make our APIs a bit more pleasant?
Telling a user to use an older browser to view the site requires the following to be true, each of which is more difficult than the last:
Your user was just trying to do a report on the 2008 coup in Guinea, and now they have to know how to get IE 6 to run on their 2032 hardware. This isn't an acceptable burden to push on anyone. |
@rimunroe as a developer it's your job to stay on top of changes you can't expect language to accommodate everyone. Otherwise we'll be stuck and not moving forward it's a terrible idea. As a professional you should take responsibility in code you ship if breaking change occurs it's up to you to fix it not language to accommodate your poor choices. |
You should be logging issue with all those library github accounts not here. |
This is a pretty simplistic view on business realities. Do you have access to sites you maintained 5 years ago, 2 jobs back? Will your manager even let you take the time to work on a site where there's no client paying for your hours? There are so many more constraints than "take responsibility in code you ship." |
Not everyone is a developer. Sometimes you're just a person who wanted to write your diary, which just happened to be hosted online. Why should we force those people to maintain their work forever? Alternatively, I feel like the more obvious response might be, "People aren't immortal." Sometimes humans die after writing something. |
I wonder which version of MooTools are we talking about. I've made a simple test where I'm trying to override |
A couple ideas:
|
@rimunroe when you take such decision, you must operate with concrete information, not with idea of ideal web itself. As I said - there is a lot of libraries, with a lot of used names. Basically, you asking to prevent making changes in alphabet, because < 1% of readers will not understand your book. This is false point of view. Saying, that web is about information is one thing. Creating artificial obstacles - is another. Publisher must update his own book, not stopping to change language itself. Also, I want to agree with @Jerczu - it's our, developers, job, to avoid such problems. This is what we are payed for. |
Also, about concrete information - I see not the first time in this discussion, that #56 (comment) And over, and over, and over... |
@zonzujiro These commenters don't understand the bug. If you implement a native method and MooTools defers to it, but the site expected a different method signature or different semantics... 💣 💥. |
@michaelficarra @littledan @ljharb I've verified this by changing this line to use |
@anba to clarify; are you saying that if flatten is enumerable, sites using all versions of Mootools will unconditionally override Array.prototype.flatten? |
@ljharb No. At least for this specific case at wetteronline.de, Array.prototype.flatten is always overridden with Mootools' version of flatten, but some part of this site (or of Mootools, I haven't investigated further), relies on Array.prototype.flatten being enumerable. |
We seem to be hearing a bit of skepticism here about whether web compatibility should be a goal in the evolution of JavaScript. Overall, maintaining compatibility is very important for TC39, and I don't think we'll be able to overcome that as a design constraint in this thread. |
I think a lot of people are assuming that this process is done. It's not. We've yet to fully understand the scope of the breakage and exactly what patterns are broken and how we might fix them. I hope we'll learn more over the coming days. Also what @littledan said is important: every change is, pedantically, a breaking change. Flatten is concerning because current signals and past experience with exactly this issue (Array#contains) suggests the problem will run too deep to fix easily. As we learn more this may change. Everyone can rest easy knowing that TC39, being filled with developers, wants this great new functionality. We worked really hard on this proposal for many months! But developers are not our only "customers" and we owe it to all internet users to evolve their platform responsibly. |
Thanks, @anba. The original webcompat thread points to a very similar issue with contains and MooTools, which strongly implies that this is not about the difference in behavior of the method itself (though I imagine the difference in behavior would also cause breakage). The specific problem with
That's unfortunate. I don't think there's a fix short of renaming a la |
+1 to both. I'm choosing to look at this as a "fun" way to resolve an unfortunate problem. |
Strongly against |
Playing around with it a bit, we can actually "fix" this be defining an overridable setter: Object.defineProperty(Array.prototype, 'flatten', {
configurable: true,
get() {
return flatten;
},
set(v) {
// A overridable setter, this acts like a normal property after first set.
Object.defineProperty(Array.prototype, 'flatten', {
configurable: true,
enumerable: true,
writable: true,
value: v,
});
}
}); /cc @domenic, who mentioned something similar in the last committee meeting with |
If we are taking suggestions for alternative names to consider, I would chip in with |
Since this thread is linked from a few external places and getting thousands of views, I want to make a process note: This proposal to add The name |
As a followup to my comment above, I said
It turns out that non-idiosyncratic usage can easily so depend. For example,
is using
This is precisely what the website this change broke was doing. So I expect this to break many more sites, as spec'd. |
Resolved by 093eacc. |
As reported in Bugzilla bug 1443630, 8+year old versions of MooTools conditionally define an incompatible version of
Array.prototype.flatten
. See mootools/mootools-core/Source/Core/Core.js for the responsible code. In an attempt to turn a negative situation into a positive one, I am taking this opportunity to renameflatten
tosmoosh
.