Re: [Json] JSON Schema Language: int53

Ulysse Carion <ulysse@segment.com> Thu, 22 August 2019 21:54 UTC

Return-Path: <ulysse@segment.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 747E912012E for <json@ietfa.amsl.com>; Thu, 22 Aug 2019 14:54:14 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.999
X-Spam-Level:
X-Spam-Status: No, score=-1.999 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=segment.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JR0_3YEYuAzk for <json@ietfa.amsl.com>; Thu, 22 Aug 2019 14:54:12 -0700 (PDT)
Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 09B211200B1 for <json@ietf.org>; Thu, 22 Aug 2019 14:54:11 -0700 (PDT)
Received: by mail-io1-xd34.google.com with SMTP id p12so15337623iog.5 for <json@ietf.org>; Thu, 22 Aug 2019 14:54:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=segment.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=9OHaDoMg1pJnYEKZIieELS5VqkAXsIJKyxm1eYRsRKw=; b=myjiVL2rXaaem3X6BkSwW9mDJ4KYqXNm7E/dCfZe8ZtKW2xkOutsi2HRRhfqwg/O61 1p9s6mYjoTQDrbXwGCS7MpjsrvtwTn5scqnnY9IoYQjWVQt9H9isq7/iV2/6jgwdFz6c YrmSQnIEK9rys/4VfaWoBkBD8ZltZmTnCQAyA=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=9OHaDoMg1pJnYEKZIieELS5VqkAXsIJKyxm1eYRsRKw=; b=h60/DJIuwalxCoXck8iok+qi66qWbsBzKzl37QFgdl9vaf6GamTkobGJwT31HSHE6A VU2wj98HQtgCZWqtuJyI3PqpWDEE/kHgjKuanFJlavdfmUfa1X4nr/gXuI8g2pRMt8lH ve6xIfypaguptt2w1oeVgiJIPETVpAxwQEn8lUmvzfsyGT7t+NPVt9ibRw9ixXSvbfd/ t6RNyoQB9SR+HC4Pc3tz4UQahD24Z5/xMwTyB0E8MjdOZAHGy6gAmLH0ksNfeJBWlm1+ 1yyHEvGPF73zx3zITNjC5Y6f1ISpAHeJv5Pf8VhBvT4kOOhxyMTn811ZLNmSfCglqRkm m4qg==
X-Gm-Message-State: APjAAAV1oKttBeOTGtBKBpocejcl6yb49C82F0XaSe8CpCShoYrEdnrV UeesTRZxkXJlK6jefnGDT1BFm9d8qJCMVsnZ7LbYjw==
X-Google-Smtp-Source: APXvYqwKrpsxmOJ3tp13PORP+F/PA2INURHCnCbvqk0KMo+LkxREYn+pxXCarYr3zU0VBhm+iFC2iUGgOZLyjdspMIM=
X-Received: by 2002:a5e:a502:: with SMTP id 2mr2496775iog.269.1566510851084; Thu, 22 Aug 2019 14:54:11 -0700 (PDT)
MIME-Version: 1.0
References: <SY2PR01MB2764698C2B0DE6811B9FDAFBE5AA0@SY2PR01MB2764.ausprd01.prod.outlook.com>
In-Reply-To: <SY2PR01MB2764698C2B0DE6811B9FDAFBE5AA0@SY2PR01MB2764.ausprd01.prod.outlook.com>
From: Ulysse Carion <ulysse@segment.com>
Date: Thu, 22 Aug 2019 14:54:00 -0700
Message-ID: <CAJK=1RiDf6SpWEad4w05ihHCAXviprzS_EXTv+aGmCWpkkoRGg@mail.gmail.com>
To: "Manger, James" <James.H.Manger@team.telstra.com>
Cc: JSON WG <json@ietf.org>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/CbD-HUvDSXECYfAbz1DigO3yaAU>
Subject: Re: [Json] JSON Schema Language: int53
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.29
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: <https://mailarchive.ietf.org/arch/browse/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: Thu, 22 Aug 2019 21:54:15 -0000

> If you omit int53, then your code generation will never create a long despite this being a widely available & useful type.

The issue, in my view, is that int64/uint64 is the widely-available
and useful type. Not int53. To support int53 would require that code
generators implement this psuedo-type at runtime.

Consider that gRPC, which has a canonical representation in JSON and
which also has int64/uint64, unconditionally renders these types as
strings. I feel that this approach is more reasonable, as it removes
the footgun of a datatype that most users will assume is equivalent to
the familiar int64, but is not.



On Tue, Aug 20, 2019 at 9:56 PM Manger, James
<James.H.Manger@team.telstra.com> wrote:
>
> Surely int53 is fine for code generation. When you see int53 in a schema, generate a field of type long (in Java).
> That alone will not enforce a 2^53 limit, but so what.
>
> When a schema has:
>   "numberOfSiblings": "int8"
>   "dayOfWeek" : "int8"
> It doesn't mean that 120 is a sensible number of brothers & sisters, or -55 can be a day of the week. It just means that the valid values for these fields can be represented with the range offered by int8. Apps still need to do their own validation beyond that.
>
> If you omit int53, then your code generation will never create a long despite this being a widely available & useful type.
>
> --
> James Manger
>
> -----Original Message-----
> From: json <json-bounces@ietf.org> On Behalf Of Ulysse Carion
> Sent: Wednesday, 21 August 2019 5:06 AM
> To: Richard Gibson <richard.gibson@gmail.com>
> Cc: Carsten Bormann <cabo@tzi.org>; Pete Cordell <petejson@codalogic.com>; JSON WG <json@ietf.org>
> Subject: Re: [Json] JSON Schema Language: extensibility and unspecified properties
>
> [External Email] This email was sent from outside the organisation – be cautious, particularly with links and attachments.
>
> > IMO, the schema should be about representing what the protocol needs
> > rather than how it is represented on a target machine.
>
> This is a reasonable stance. But I don't think it's what I'm trying to
> solve for. My focus has continually been on code generation from
> schemas; the spec's expressive power is intentionally limited
> specifically to enable code generation. Optimizing for code generation
> is why I *am* concerning myself with how things are represented on
> target machines.
>
> There are lots of good options for schemas languages that are focused
> on being as expressive as protocols are complex -- you've written one
> of these good options, Pete -- but I've been concerned with making a
> schema language as inexpressive as mainstream type systems are simple.
>
> I'm not debating whether there are ways of representing int53 in many
> languages. My objection is that I would be making up a type that
> doesn't exist in existing programming languages natively or
> idiomatically. If someone wants to do int53 bounds checks, they can
> always use the float64 type, and then do bounds checking after schema
> validation. Or they can write an extension.
>