-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
size-suggestion: Consider removing subtract
in favor of add
#2844
Comments
Removing |
My origional suggestion is in https://docs.google.com/document/d/16Rd43XB8z6iLC2c9AfF--unDFg_t476tI1PFe7PbbcM |
Agreed with Richard on this one, |
I find |
My position matches Shane's. The workaround is intuitive and it'd be easy to add this in a follow-up proposal later. |
After talking to some users of Temporal this week I'm starting to come around on this point. Still would prefer not to do this, though. |
Meeting 2024-05-23: At the upcoming June 2024 TC39 plenary meeting, we'll propose removing the 7 We think that this is OK because users can negate the duration and use |
Removal of |
thanks Maybe also remove the "OrSubtractDurationFrom" part from the long AO name? |
@ptomato Can you give insight into why you've changed your mind? Which user of Temporal told you removing I realize I don't have any "say" in this matter and that I'm a bit late to the party, but I find the much faster faster than and I hope I'm not the only one. If I'm not, that alone should justify keeping Assuming const x = Temporal.PlainDate.from("2024-06-02");
const y = Temporal.Duration.from({days: 5}); compare x.subtract(y)
to x.add(y.negated())
Some statements from implementers also seem inconsistent. If the goal of removing these ergonomic features is to reduce size and complexity due to constraints of certain devices/systems, why would we expect them to be added later? If "it is also something really easy to add in a follow-on proposal", why remove it now? It seems more complicated to remove these features at this stage of the proposal, especially after so many users of Temporal polyfills/implementations have become accustomed to them. Not having Concrete metrics or benchmarks from the implementers would be very helpful to understand the actual problem with keeping simple operations like Disclaimer: I'm not a native English speaker, so my writing might come across as more impolite than I intend. |
you do not need to do that. Just put the - in front of the 5 is better.
|
If we add subtraction, should we add multiple or division to Duration too?
then? |
The context is that engines, especially V8 which powers Chrome and Node, incur a fairly large cost (relative to the overall size of V8) in both install size and memory consumption for each function in a built-in object. FWIW, this was also a suprise to the champions of the Temporal proposal. We didn't anticipate that adding functions would be such a challenge for JS engines. In a desktop browser rendering a simple web page, this isn't an issue. But there are cases where even a few tens of KB increase matters:
For this reason, Google (specifically the Android team) limits the size increase per year of browser components like V8. Apple and Mozilla had similar concerns. Thankfully, this gets better over time thanks to Moore's law. The low-end devices of 2 years from now will have a lot more storage, so this allows V8 to gradually get larger over time. So in the meantime, we're planning to strip out lower-priority parts of the Temporal proposal. These can be easily added back in the future if there is sufficient demand from the community. Also, ergonomic helpers like
You can learn more about how ECMAScript is extended here: https://github.com/tc39/proposals |
Which is still confusing though. Again, maybe it's "just me", but to me negative durations make no sense in the real world. For me and I think for most people, durations are always a positive span of time, that you can add to or subtract from a point in time to get to another point in time. Even ISO 8601-2:2019, which is a relatively new extension to the standard, doesn't specify if adding a negative duration to a date is the same as subtracting it (and how to handle that), it only specifies that adding negative durations to other durations is the same as subtraction - maybe because there could be differences?
That's just a slippery slope argument. No one said anything about adding a whole math suite to Temporal. But I find it weird you think adding the "opposite" of an operation like I see, thanks for the insight. I am still astonished how Here's also an informative issue thread about code size and memory impact of Temporal, in case anyone else is confused by the motivation behind all of this and wants to see actual metrics (however accurate they are): #2786
Where do you think I came from years ago before discovering this proposal? 😅 I rather meant if there is any effort to not lose years of work from this proposal, maybe by splitting all removed spec directly to a new proposal, or by advertising a Temporal "extensions" polyfill in the future, or even by investigating in how implementers could still add these removed featured behind some "experimental" flag, either in runtime or when building. But that's probably something ECMAscript shouldn't define. I remember there was some temporal extensions proposal out there, but I can't remember its name and couldn't find it. EDIT: There it is: https://github.com/js-temporal/proposal-temporal-v2 |
Temporal supports negative durations. #782
By having one way to do things, we make code that is less error-prone, and we leverage the opportunity to teach developers about negative durations, why they exist, how to use them. |
I know that Temporal supports negative durations. Why ISO 8601-2:2019 specifies and Temporal supports it, I don't know though. Why do they exist? My only guess is that when calculating with dynamic durations, it's better to introduce the concept of negative durations than just throwing an error. Which is fine and nice to have but it doesn't make the concept itself more intuitive and therefore, at least for me, invalid as an argument to remove the more intuitive
So, you too think that even if there were no code size or memory usage concerns, a I feel like it's too late for that anyway and to be fully honest I agree with @justingrant that "ergonomic helpers like |
@nnmrts Sure. I can answer the parts of your question that Justin didn't already answer.
Of course any individual conversations are just anecdotal evidence, but yes, I did hear from some Temporal users that they wouldn't be particularly fussed by the lack of The main reason I changed my mind is because its functionality is still present, it is trivially polyfillable, and could be re-added in the future in a web-compatible way in a small, simple, self-contained TC39 proposal. We discussed removing a number of methods that fit these criteria. Of those, I think I get what you said about negative durations and that's important feedback, thanks. Personally, I've had no trouble considering negative durations just like negative numbers. So while I had a hunch that About the general status of this issue. Certainly it's hard to articulate the range of opinions in the room while also trying to move forward a consensus position, but I think you'll have a more accurate understanding of the situation if you adjust this assumption:
Yes you heard this from Frank above, but I don't think it's accurate to assume it reflects a widely held view. I certainly don't think that the proposal is better without |
@nnmrts Currently, Temporal defines the following 7 subtract
Do you think all of them are useful and important and you will use all 7 of them? |
@FrankYFTang Yes, all of them. For example, I used
Here are some of the uses of it in our code base of that project, my colleague and I wrote: As you can see, we even implemented our own But yeah, just in those screenshots above you can observe:
and using our own quarter class of course:
|
This did not reach consensus at the TC39 meeting of 2024-06-12. |
We could remove all 7
subtract
prototype methods from Duration, Instant, PlainDate, PlainDateTime, PlainTime, PlainYearMonth, and ZonedDateTime. Users would useadd
with negative values instead.For duration literals, negation would mean using negative numbers. With Duration parameters, the
.negated()
method could be used.This issue is adapted from suggestions made by @FrankYFTang to help reduce the size of Temporal to address concerns from implementers (especially Android and Apple Watch) that Temporal's install size and/or in-memory size is too large.
The text was updated successfully, but these errors were encountered: