Re: [Json] Generators

Tatu Saloranta <tsaloranta@gmail.com> Mon, 10 June 2013 17:39 UTC

Return-Path: <tsaloranta@gmail.com>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 43A2521F8BE6 for <json@ietfa.amsl.com>; Mon, 10 Jun 2013 10:39:16 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.405
X-Spam-Level:
X-Spam-Status: No, score=-2.405 tagged_above=-999 required=5 tests=[AWL=0.194, BAYES_00=-2.599, HTML_MESSAGE=0.001, NO_RELAYS=-0.001]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FWHeNFflUtrB for <json@ietfa.amsl.com>; Mon, 10 Jun 2013 10:39:15 -0700 (PDT)
Received: from mail-we0-x22d.google.com (mail-we0-x22d.google.com [IPv6:2a00:1450:400c:c03::22d]) by ietfa.amsl.com (Postfix) with ESMTP id B576D21F8ECB for <json@ietf.org>; Mon, 10 Jun 2013 10:39:14 -0700 (PDT)
Received: by mail-we0-f173.google.com with SMTP id x54so4303483wes.32 for <json@ietf.org>; Mon, 10 Jun 2013 10:39:13 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Abp+mPalt1/bbYHtL5LlNjuPgxJtqmVJf1XIXiAfQgY=; b=WnanS3WPK51MZQGdaE2uV+1rIXnG3HEheVudig3pEVOqGDOBYQXCfdNOanU5XwNXdr O/9DH0xWqx8LV6KtBFJLLBnMJbcoNepapJGGpHX3H8/kzIytAl5vjcV4T48SMo9qG5Vs bOGAvj3p4LQrFRKMxmRQzYHT/eioGGBvjulz5Q6pHsg6Q4HDmByEmBLxGhIK5TV4cEyF RFAIB6AN25HEYoynB8fcD/FqCkENSOC1xT91xtCi3CCI35MzX5PLkOWDAdlitlZn+oaf Z9hafYHWHgj1bYxkK9TF1TdyFhuVJPoV5SiiBRgANcxuQmxB78qtaZSPJs8Jfve6L7yG Qfbw==
MIME-Version: 1.0
X-Received: by 10.180.11.194 with SMTP id s2mr3590624wib.7.1370885953718; Mon, 10 Jun 2013 10:39:13 -0700 (PDT)
Received: by 10.227.72.74 with HTTP; Mon, 10 Jun 2013 10:39:13 -0700 (PDT)
In-Reply-To: <ED155A5427A54EDB9AA8B716BDEDBBFF@marcosc.com>
References: <51B58261.5040808@drees.name> <51b5a11d.0881440a.629d.68d4SMTPIN_ADDED_BROKEN@mx.google.com> <60EAB36FA95E40A180330B3D7F8377F5@marcosc.com> <51B5B17E.5030706@drees.name> <ED155A5427A54EDB9AA8B716BDEDBBFF@marcosc.com>
Date: Mon, 10 Jun 2013 10:39:13 -0700
Message-ID: <CAGrxA27YabqQCTO9mzmYQeJPCK6WmocqQxX0E6-=H+aNfnN47w@mail.gmail.com>
From: Tatu Saloranta <tsaloranta@gmail.com>
To: Marcos Caceres <w3c@marcosc.com>
Content-Type: multipart/alternative; boundary="001a11c355a24c914c04ded04281"
Cc: stefan@drees.name, "json@ietf.org" <json@ietf.org>
Subject: Re: [Json] Generators
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <json.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/json>, <mailto:json-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/json>
List-Post: <mailto:json@ietf.org>
List-Help: <mailto:json-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/json>, <mailto:json-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 10 Jun 2013 17:39:16 -0000

On Mon, Jun 10, 2013 at 5:20 AM, Marcos Caceres <w3c@marcosc.com> wrote:

> Hi Stefan,
>
> On Monday, June 10, 2013 at 11:59 AM, Stefan Drees wrote:
>
> > On 2013-06-10 12:10 CEST, Marcos Caceres wrote:
> > > On Monday, 10 June 2013 at 10:49, Markus Lanthaler wrote:
> > > > On Monday, June 10, 2013 9:38 AM, Stefan Drees wrote:
> > > > > 5. Generators
> > > > >
> > > > > A JSON generator produces JSON text that MUST strictly conform to
> > > > > the JSON grammar.
> > > >
> > >
> > >
> > >
> > > Please try to avoid "wish list" style conformance requirements. If you
> > > want "strictly" conforming documents generated (whatever that may
> mean),
> > > then please write the algorithm to produce such documents. For example:
> > >
> > > "When generating JSON, as JSON generator MUST run the steps to
> generate JSON text.
> > >
> > > The steps to generate JSON text are given by the following algorithm:
> > > 1. …
> > > 2. …
> > > "
> >
> >
> >
> > if I only once had the power to write my wish lists that strong and
> > concise, I would be a very happy man I guess :-)
> >
> > We will not have a conformance section and we had until now no step by
> > step description but only an "integral" check, where the result had to
> > conform to the ABNF grammar of JSON.
> > So the following message is the best we can state:
> > If you are a wannabe X generator, ensure your output strictly conforms
> > to our X grammar.
> >
> > Retro-inventing of stepwise solutions/recipes simply not having been
> > around for all these years and then acting as if they had, to me
> > personally gives a strong smell and is far off the charter, isn't it?
>
> I haven't read the charter, tbh … I literally stumbled onto this list
> yesterday :)


Make sure you then read preceding discussions. Many of the concerns have
been discussed in considerable length. It appears bit arrogant to start
commenting on "should leave all these loopholes" when there are solid
reasons for not mandating things that various implementation can not
support in practice. Practice based on existing significant use cases, as
discussed on the list.


> However, I'm worried that overly simplistic or optimistic conformance
> requirements will just force people to go and look at ES6 to actually write
> the parsing and generation algorithms (or worst, they will just find some
> other random implementation out there and copy that). That could greatly
> diminish the value of this specification as it will leave implementers
> scratching their heads about how to implement either a parser or a
> generator.
>
> Also, given the legacy of JSON, it should be possible to see which parser
> behavior "won" (e.g., Doug's original JSON.js?) - and model this spec off
> that.
>
>
Which is what has been discussed in detail as well; and is what lead to
current proposal of "if only one of duplicate values used, it shall be the
last one".


> Additionally, I suspect few people actually implement an ABNF parser -
> whatever is expressed in ABNF will have to be translated into code for a
> specific implementation. You can essentially shortcut that by specifying
> the algorithm and making implementer's lives easier.  That's not to say
> that the ABNF should not be there (it helps the reader understand
> components of the JSON grammar) - but the reality of the situation should
> be acknowledged (ABNF is an editorial aid, but rarely, AFAIK, a tool used
> in implementations in it's pure form to do syntactical checking).
>
> > > > > Generators MUST NOT duplicate names in objects if they can avoid or
> > > > > detect such duplication.
> > > > >
> > > > > """
> > > > [...]
> > > > > This "MUST NOT duplicate ... if" reads pretty soft for
> implementers,
> > > > > but should be the only consensual non-breaking way out of the
> > > > > historical dilemma of not enforcing it for generators in the first
> place.
> > > >
> > >
> > >
> > >
> > > I agree. The above "if they can avoid [it]" if pretty lousy spec text.
> > > Please define the algorithm instead to produce the results you want.
> >
> >
> >
> > I might be tempted to change the sequence to a more natural looking one
> > "detect before avoid" but then, if an implementation is not able to
> > avoid it, why should it bother to detect or not detect? So the strongest
> > excemption is noted first: A policy or a use case hinders me in ensuring
> > the "uniqueness wish" for names in objects.
> >
> > On a personal note: If we avoid wordings like "pretty lousy spec text"
> > in situations where many people are trying to retrofit best possible
> > constraints into an area where these completely missed for years, to
> > avoid further future "leakage" and without breaking reality that would
> > be surely helpful, wouldn't it?
>
> Yes, I'm sorry; I didn't mean any offense. I just meant that it was a
> conditional MUST, and that's not how MUST should be used (as it means one
> parser can do one thing and another can do another thing … which is an
> interoperability anti-pattern). This would, obviously, be bad if I'm
> sending one JSON representation from the client and it gets transformed
> into a different one on the server and the spec says that this behavior is
> ok.
>


But this is reality: the only way to guarantee, for example, uniqueness of
keys leads to constraints that make it impossible to process JSON content
without tracking all names of currently open JSON objects in memory. In
worst case this is comparable to just holding on to the whole logical JSON
tree representation.


>
> On the other hand, if the spec has to say, "well, that's the reality right
> now… and here are some guidance on how to avoid that problem without
> breaking clients and servers:" that might have to do.
>
>
which is what I understand specification tries to say.

-+ Tatu +-