-
Notifications
You must be signed in to change notification settings - Fork 3
js.Array[JValue]
vs Array[JValue]
#13
Comments
Here my workaround, which does not feel right at all: |
This is something that I am sought on the fence for. I also had a look at this in broader context, in the sense that its far more likely that someone will construct I am open for suggestions, but for now, you would probably have to explicitly deal with the construction of a |
Also note that there are |
IMO you should aim for a single
I think this would be worth a benchmark. Looking at the output of a example.scala:
Relevant example-fastopt.js part:
If I where you I would even get ride of the safe/fast separation, and provide a single shared AST with every interface duplicated. For instance, |
Originally the intention was to provide a single AST, but it turned out that it was impossible to make anyone happy with any resulting design. Some people needed ordering, some people needed speed, some people needed safety, some people needed the library to use minimal memory, etc etc. You can't make a JSON library that satisfies all of those requirements decently
Agreed, I need to set up a javascript benchmarking suite. Note that the idea of
As mentioned before, this was tried before. There wasn't a single datastructure that is both high performance/memory efficient and is safe.
This would use a huge amount of memory, and its not something you can opt out of. I think the easiest way to think about it, is that For the same reason, we expect some libraries to implement |
Hi, sorry for the late reply. I shouldn't have included the last paragraph about the safe/fast separation, that was just me thinking out loud about the possibility of a compromise that would be both safe and fast. Please ignore it for this issue. The original point I wanted to make was about the differences between the jvm and js versions, in particular in their fast vast variants. In my opinion both jvm/fast and js/fast ADT should have identical type signatures, that is using scala.Array in both places instead of scala.Array in one place and js.Array in the other. Obviously benchmarks would help settle on this, but my intuition is that you can achieve consistency, and maybe even share most of (if not all) the implementations between the js and jvm versions without trading off performances. I also back my request with one of point made in the "Principles for Modular, Functional, Approachable Libraries" by Erik Osheim, which goes into this direction: https://www.youtube.com/watch?v=iKyIKozv8a8&t=62m11s. |
Ideally yes, there is however a conflicting aim of
One thing to node, is that I am happy to have my stance on this changed if the performance between |
Great, looking forward to seeing the benchmarks then! I didn't notice that |
Note that it is still possible to use There might be a nicer way to fix this, like using some sought of union type? I have been doing some research into a benchmarking facility for Scala.js, but I am not getting anything promising. There is however work to get scalameter working for Scala.js (scalameter/scalameter#154 (comment)) |
If you need some tests cases for a POC benchmark you might be interested in the test suite of the library I'm working on : https://github.com/OlivierBlanvillain/validation/tree/scala-js-squashed/validation-json4s/src/test/scala (still wip). It uses ScalaTest to run the tests in both js and jvm, and outputs the execution time for both platform. |
The difference on the type signature on
case class JArray(value: js.Array[JValue] = js.Array())
andcase class JArray(value: Array[JValue] = Array.empty
prevents from writing generic code onorg.json4s.ast.fast
.My question is the following: how much do we lose if we cross compile jvm/fast/JValue.scala?
The text was updated successfully, but these errors were encountered: