-
Notifications
You must be signed in to change notification settings - Fork 15
Adding standard Json AST - https://github.com/mdedetrich/scala-json-ast #28
Conversation
-1 |
? |
@sjrd want to weigh in on the Scala.js aspects of this, and/or call the Scala.js community's attention to it? |
Sure, I already did a surface reading of the proposal. I will have a deeper look at it later. |
This question about key ordering in objects is interesting. In the proposal If it's possible to preserve key order and still get good performance, great! But then I would expect I imagine this will be the subject of further discussion... |
I believe Scala stdlib does not need json library. |
@xuwei-k We see that sort comments a lot from the scalaz people. I must admit it is getting annoying. If you have serious concerns about a proposal let's hear them. But I am not interested in the commonly voiced opinion that no improvements should be made to the standard library. That's just obstructionism. It's like me telling you there should be no scalaz, I guess you would not like that either. |
I think a standard way to work with json would be great,there are so many json there in the scala community,and look at the https://github.com/tminglei/slick-pg,it write extends for |
-1. This is downright damaging when the FOSS community already contains several first class implementations, each with its own particular emphases and design goals, and all in use in production in systems large and small. If you want to promote Scala for Json processing, get behind those libraries. By all means fork or create another one if none of the existing ones exactly meet your needs, but then recognize that you're doing this because one size doesn't fit all, which is precisely why promoting one as a so-called "standard" is harmful. |
+1. It's totally unconstructive, and adds nothing to discussion. It's even more annoying because oftentimes the objections come out before the exact thing being proposed has even been decided, which is totally ridiculous because by that point you clearly haven't even considered the proposal (because there isn't any yet!) @hepin1989 OTOH this won't actually solve your use case. This is purely for interop in JSON ASTs, and doesn't provide any facilities for parsing or serializing. IMHO that makes it considerably less useful. I don't find myself passing around parsed but un-converted JSON ASTs around enough for it to be a hassle; most of my work involves going straight from String -> case class or case class -> string, but maybe other people have different usage patterns. Do people find themselves mangling, passing around and transforming parsed-by-untyped JSON ASTs between different libraries often? |
As the maintainer of Argonaut I don't see a huge benefit to Scala itself in there being an inbuilt JSON library, mostly because it runs the usual risk of not changing once first created. Which means it can be a bit of a lowest common denominator implementation that gets rusty really quickly. I agree with @lihaoyi that it's very rare to need to convert between implementations of ASTs, even to the point where I can't recall a time where I've actually had to do that. It's also worth mentioning that the JSON standard as I think it stands now calls for arbitrary precision numbers which was a serious piece of work in Argonaut to support in an efficient way, which is why some of this gets hard really quickly. |
@milessabin You are making a political argument, not a technical one. By [Some more thoughts] On Wed, Nov 4, 2015 at 7:12 PM, Sean Parsons notifications@github.com
Martin Odersky |
Here's a few more opinions:
|
@odersky the very idea of a "standard" is a political one. This whole enterprise is political and it's appropriate to respond to it in kind. |
The code in this SLIP will literally be behind those libraries...! |
I wholeheartedly agree. It's way too young for getting into committed relationship with standard library. |
@SethTisue no, it will be a competitor with code which already exists in those libraries. I know you've see the relevant xkcd cartoon. |
Why not just pick one that already works well? spray-json in really good. Importantly it uses arbitrary precision for numbers and reminds us all that JSON maps do not preserve ordering. If you really must create a new AST (replacing this one tiny file of awesome) then please do not forget these points. The only change I would ask of spray-json is to remove the Root* traits, and it the marshalling layer to perhaps move all implicits to the companion of JsonFormat. Also it has a super fast parser. And years of production usage with lots of tiny performance tweaks along the way. Plus it has spray-json-shapeless ;-) Let's just get everybody to standardise on spray-json |
(Actually if the marshallers returned Either instead of throwing exceptions, it would significantly speed up Option marshalling, but that's a rather minor technical point). |
@fommil There's no need to "pick one" and give it an official stamp ... if you want to use or advocate for spray-json, that's fine, but there's no grounds for your (or anyone else's) preferences being legislated for. |
BTW is this just about the AST or an entire JSON framework? Parsing/marshalling/querying/validation/etc? I don't believe the standard library even has the power to provide what is needed for a proper marshalling framework. We need shapeless for that. |
It's good to know how you feel about it. My "politics" is to make Scala more accessible for newcomers and people who do not want to spend a lot of time trying out different alternatives. I stand by that. I am very happy co-opting a best of breed library that's out there; no need to reinvent the wheel. But I am deadset against leaving stdlib with the crippled JSON parser it has, and also leaving it without one. |
Unless I'm missing the point of this SLIP, this is just a proposal for a unified JSON AST and its goal is to allow different JSON libraries to interop between them; that is... no improvements to the existing JSON parser in the scala standard library. If the whole purpose of this SLIP is just that, I don't thing it belongs to the standard library, not even as a module. If anything it's a library that the authors of the different JSON libraries might or might not want to use. As an user I can't even imagine a use case where I would want to have two different JSON libraries in my classpath and rely on a unified JSON AST to interop between them. |
This SLIP is about the ASTs only. I suggest any broader discussion happen on scala-debate instead, but maybe those cows are already out of the barn. |
Do you want to issue a separate call for a SLIP that addresses that? This one doesn't. |
-1. I'm in agreement with @milessabin, and agree with @fommil that a proper JSON framework should provide parsing/marshalling/validation/etc (which, as he points out, would require something like shapeless...Circe, eg, is making excellent progress on this front). I simply don't see this as something that needs to be (or should be) in the standard library. |
@SethTisue Yes, I think the current JSON parser is overdue for a replacement. It would be good to call for proposals. |
I don't think the current proposal is useful enough to warrant inclusion, but I think a good AST + a fast parser + a serializer, with the useful knobs (e.g. serialize with proper indentation) would be useful enough to put in there. |
As an sbt maintainer, I'd like the new JSON AST to be designed with long-term binary compatibility in mind. One way to do this might be to declare support window like 24 months and/or putting the major version number in the package name like Another requirement the AST should go for, I think, is literal round trip ability from a legal JSON string -> AST -> JSON string. Having more requirements on AST than the JSON spec doesn't interfere with the interop of JSON strings. If not the round trip (aka insertion order), at least we should aim for idempotency from the input type (I was away from internet when this discussion was active, but I figured I'd put my 2 cents) |
Definitely agreed. It kind of kills the point if the library is not stable. Regarding versioning, I am not sure if versioning by packages is needed, especially if the release cycle will be so long.
The current design does deal with this problem Just letting you guys know, that I have been incredibly busy lately, however I will have a lot more free time in the holiday period to work on this |
@jeffmay Huge +1, build-in language support of JSON is the common expectation of programmers with a dynamic language background (python, javascript, Ruby, etc). |
Hey guys, thought I would give a little bit of an update from my side regarding whats going on. In regards to time I am about to move overseas, so I don't have as much time as I used to, I should be more free around march/april. I am also helping write a Scala book. @SethTisue , @Ichoran would it be possible to give an update on the progress of this issue. As it currently stands
Should I re-namespace the current proposal, "submit" it to the community and see what they say? |
I think we covered this in the scala/slip room on Gitter? Perhaps you'd like to summarize for this audience? |
@SethTisue Sure thing The current proposed AST at https://github.com/json4s/json4s-ast is going to be repackaged so its under the Again to be clear, this is not going to be released as part of Scala stdlib. Its going to be a seperate module which uses the scala namespace, which is the exact same situation as scala-xml. It will also only contain a There are going to be some minor modifications to the AST, which include the following. Hopefully this will be submitted by next week
@travisbrown has raised an issue with One solution would be to document this, another would be to remove the . |
Really expensive conversions: Just to clarify, my concern specifically is that library users working with If my library includes a method that allows valid user input to result in computations that run forever and consume lots of resources (both processing and memory), I'd want that to be painfully clear in the documentation, in the method name, etc. circe addresses this problem by having Representing structure vs. decoding: More generally (and probably more importantly), I think the presence of the Other clunky number stuff: I have a number of other complaints about the representation of JSON values—e.g. scala> org.json4s.ast.fast.JNumber("1e2147483648").toSafe
java.lang.NumberFormatException
at java.math.BigDecimal.<init>(BigDecimal.java:491)
... In my view this kind of thing should be hidden from the library user (which is not that difficult to do). Fast vs. safe: I'm also just not convinced that the Lastly, there's no reason a "strictly adhering" JSON object representation can't preserve field order. What I want is a fast, safe AST that holds on to a few useful facts that aren't strictly mandated by the spec (like field order, the sign of zeroes, etc.). circe has that now, and adopting this AST representation seems like it would be a step backward in every respect. |
I don't disagree with this at all, and I wouldn't have an issue in removing it (although if we end up using something like I made an issue about this and didn't get an overwhelming response to remove it json4s/json4s-ast#3 (comment). I think if we leave
Can you point to the source in your code where you do this. I may end up implementing it if there isn't too much ceremony in how it works
Fast takes up much less memory (uses mutable arrays under the hood). More importantly though, it doesn't do any runtime checking and it uses the minimal available datastructure (i.e. String for a JNumber). |
Hey guys, just letting you know that a git repo has been set up at https://github.com/mdedetrich/scala-json-ast, it also includes a gitter room, so feel free to ask questions/file issues! |
Just giving everyone an update, the final design of the scala json AST is now out, the main change is that Unless there are major objections to this last change, this will probably be the latest revision. The only thing that needs to be updated is to add some tests/benchmarks. Hashcode for the new @SethTisue As far as I am concerned, from a design perspective the AST is pretty much done, I just want to add some tests/benchmarks to provide some greater confidence. When that is done, I think its a good time for a release? |
Great work ! Rao Fu
|
sure — ideally in tandem with an updated version of the SLIP itself, reflecting the latest discussions and design thinking? |
@SethTisue The final design is now pretty much complete, I am going to update the SLIP itself to reflect the most recent changes (amongst other things). There may be more to be done (documentation, some more tests for confidence?) but I think its at a point where it can get a good looking at |
How can I find a URL to the SLIP?
|
@chaotic3quilibrium Its in the SLIP, but for reference its located at https://github.com/mdedetrich/scala-json-ast I will edit the title so its easier for people to spot |
What's the status of this proposal? |
@akkie Afaik, the proposal has been accepted however we are waiting for the Scala center to release their plans for the SLIP process in order for this to proceed @SethTisue @jvican Correct me if I am wrong or if something else needs to be added |
@mdedetrich Thanks, great news!
|
@akkie I am not sure if this specific SLIP will be discussed in those meetings, those are for sips afaik |
@mdedetrich Yes, correct, once the new Scala Platform process we will discuss this. |
@mdedetrich @jvican Thanks for the info! |
Can't wait to see the SPP process kick-off, we have a strong interest and would back this proposal as the combination of Lightbend's libraries (as we discussed across the Play/Lagom/Akka/Spray teams internally). Awaiting the new process then :-) |
@ktoso Likewise! Note that there is already a reference implementation if you want something to code against if you find that helpful. Its highly unlikely that it will change in the future, but I don't have a complete guarantee in this area |
The SLIP process has been replaced by the new Scala Platform Process. Matthew has moved this proposal there: https://contributors.scala-lang.org/t/scala-json-ast-sp-proposal/175 |
READ THIS FIRST
This discussion is about designing a library for a representation of JSON that can be shared between many different implementations of JSON parsing/pretty printing/transformation/.... As it's a SLIP (and not a SIP, so no language changes!), this shared API may eventually ship as a module that's included in the standard set of Scala libraries (e.g., it would be like a modern, minimalist scala-xml without the language support).
Everyone's welcome to join the discussion, provided your contribution is truly a contribution to the precise topic of this SLIP, as I tried to capture it above. This SLIP is not trying to solve the general problem of how to modularize the standard library, for example. I'm happy to refine my summary if needed. As always, there are plenty of other channels to discuss other (related) topics.
To ensure a productive discussion, please be kind to each other, stay as focussed as possible, and refrain from comments with very little technical content. As we are still refining this SLIP, it's too early to vote.
Thanks,
@adriaanm