by justthistime_ · 11y ago · 0 comments
Your last point is not the only thing that matters though. If the runtime already ships with packages X, there is no point in shipping your own implementation.
(Which is exactly what Scala/Scala.js does with math stuff: it reuses BigInteger from the runtime on the JVM, but ships its own implementation with Scala.js.)
That's why I'd rather have a single implementation for anything non-trivial and just retarget that to each backend using more low-level primitives. After all you're using a different language -- using a different date/time API shouldn't be much of a problem.
I'm not saying it'll be bug-free. My point is that it'll have exactly the same bugs on either platform. This may be preferable to having different bugs on different platforms.
Different bugs on different platforms are like an early Christmas present:
You don't even need to write tests which include your "expectations" of the result anymore.
Just call the code with randomized inputs for both platforms, and if there is a difference, you found a bug.