-
Notifications
You must be signed in to change notification settings - Fork 2
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
Remove moment as a dependency #71
Comments
Chiming in with an opinion here. I suggest using date objects, not strings. If date manipulation is needed, I can recommend using date-fns. |
We went back and forth on this a lot, and landed in ISO strings primarily for wanting the result to be serializable to ease client-server integrations. When we looked at other similar libraries, we noticed that a few (which I cannot find at the moment) had gone in this direction as well for this reason. |
Okay. I guess I'll have to wait and see how it "feels", but as a consumer of the API, I don't enjoy strings a lot. Especially because the format always gets me. I'm always confused if I need to provide ISO strings, or whatever. It's not always clear. |
Totally understand this, I found a discussion that talks about this in a prisma context: In general ISO strings are very well supported in all date libraries, and easily converted to ISO strings again with You can already now try it out in your apps by passing |
Yeah that makes sense. But I still think there's value in not having to go look at some documentation first to see what format it's in. Often I dont trust to just use ISO. What are the arguments against date objects? Because right now I can only see benefits. |
There are some benefits we see with using ISO date strings instead of the date objects:
The main disadvantages we see are:
|
Interesting. In the end, it's your decision (and I will of course respect it), but I will just chime in with a couple of thoughts:
True, but is this a real bottleneck? I feel like the Ftrack backend and other IO will always be the primary cause of performance issues. If I do this on around 10.000 JSON objects, I still think it's doable to perform in less than 10 milliseconds. And if that's the case, then I think it is safe to assume that the execution time of a query itself on Ftrack will always take longer. To me, it's kind of like arguing that Rust is faster than Node or whatever. But if you then end up using making a database call anyway, that single millisecond you saved means nothing when the database takes 1 second to execute. Would it make sense to try to make some real-world measurements of this? If we get strong-typed queries (see #143), we could generate deserialization functions that don't need to do a check, but can always serialize and deserialize at the right time. Many OpenAPI or Swagger implementations do this today. They emit a function for parsing a particular response or request.
This is a fair point I guess. I have never seen React Server Components been used at all in my entire career yet, and if I've seen somebody else use it, it has definitely only been a fraction. Maybe I should "get out" more. I don't know 😄 But I am typically in touch with what's moving around me, and what's also happening within the organisations I work for. I could be totally wrong about this since it's just based on my own observation, but I could fear that it's too early to say whether or not React Server Components will take off. There are countless alternatives right now such as how Next.js and Qwik is doing it, and the "winner" might end up being some third option. I will eat my own words if I end up being wrong, but just raising a flag here. And assuming reality right now is that 95% of users are either web or node users, wouldn't it make sense to optimize for that? Then React Server Component users would have to stringify their dates beforehand (by using
Didn't know about Your arguments here are also really good. However, I do not see the issue of providing a little flexibility. Why not support both And waiting for Temporal would require us to wait for Node to officially support it, but also for non-supporting Node versions to reach end-of-life, right? At least if you follow the same logic of not wanting to support both.
Strong-typing the literal string (as we are doing) does not catch common mistakes. For instance, the date "2022-05-06" is valid. That means the 6th of May, 2022. However, in Danish (for instance) that same date is written as "2022-06-05". We'd love if the typings could catch those mistakes. But in the above example, it won't (both are valid). You could argue that the same would happen for |
The ftrack javascript API today uses moment extensively for date instances. Given that moment has been in maintenance mode for a few years now, and the community has moved on to other date libraries (or none at all), we are to remove it as a dependency from ftrack-javascript in our next major version.
What we are to use for date representation instead is still under investigation, but we will likely end up in either using ISO 8601 string representations, or the native date object.
The text was updated successfully, but these errors were encountered: