Re: [apps-discuss] JSON Hypertext Application Language

Mike Kelly <mikekelly321@gmail.com> Fri, 08 June 2012 19:37 UTC

Return-Path: <mikekelly321@gmail.com>
X-Original-To: apps-discuss@ietfa.amsl.com
Delivered-To: apps-discuss@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 0536611E80F6 for <apps-discuss@ietfa.amsl.com>; Fri, 8 Jun 2012 12:37:14 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.599
X-Spam-Level:
X-Spam-Status: No, score=-3.599 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, RCVD_IN_DNSWL_LOW=-1]
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 clKjLEt4xfIz for <apps-discuss@ietfa.amsl.com>; Fri, 8 Jun 2012 12:37:13 -0700 (PDT)
Received: from mail-ob0-f172.google.com (mail-ob0-f172.google.com [209.85.214.172]) by ietfa.amsl.com (Postfix) with ESMTP id 7195711E8120 for <apps-discuss@ietf.org>; Fri, 8 Jun 2012 12:36:59 -0700 (PDT)
Received: by obbeh20 with SMTP id eh20so3584096obb.31 for <apps-discuss@ietf.org>; Fri, 08 Jun 2012 12:36:59 -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:content-transfer-encoding; bh=a9B7/yFC0AjRRy1R5eKj+69B53tqlNOlJEXQRYRR5DM=; b=ReOVYpCso6CFcHaUMAHGKbV71Vzkpmo6v1prUsnljgxxxwl6siYcKFa3gAnvEDLFPD 8CGoYtzMnoVRFmQQJhp6BLVDgovnK7CSTfE9ewsnl793u9Fx979U/GEGFxXBOL5XplZf lWie9qFhn07TNL4aejUzQSV1aXeds7APEL7pspoZf/TC+fJke+h78y70rKiUTlfTTvm0 PUSJVqQ2jSOVLYYgUy5FsmpmiZYUBhxIEzneVOxEkKZ32f0/BkGEsJojH33rBA2lzD0r 6MlO1Hu2Nm7KiXsVobqX+jFRgzY3tDR46+6ySv1pAkIkErlQCPlPnSdO7BqRhx6IIWh2 KYww==
MIME-Version: 1.0
Received: by 10.182.110.10 with SMTP id hw10mr8330664obb.61.1339184219092; Fri, 08 Jun 2012 12:36:59 -0700 (PDT)
Received: by 10.60.28.195 with HTTP; Fri, 8 Jun 2012 12:36:58 -0700 (PDT)
In-Reply-To: <CABkgnnXVFqEhS5oympA7E_GHhzYB+P5TQh1PugK5p16qNWSBVQ@mail.gmail.com>
References: <CANqiZJa7GrBRbiV8X=o3Xkv-WcBEdKEntiZSFhMj4efQiNPEaQ@mail.gmail.com> <CABkgnnXVFqEhS5oympA7E_GHhzYB+P5TQh1PugK5p16qNWSBVQ@mail.gmail.com>
Date: Fri, 08 Jun 2012 20:36:58 +0100
Message-ID: <CANqiZJbGMVzFrcsvuW2dZaq4pOEzi4x=iamxs_1etetKGeZz2A@mail.gmail.com>
From: Mike Kelly <mikekelly321@gmail.com>
To: Martin Thomson <martin.thomson@gmail.com>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
Cc: apps-discuss@ietf.org
Subject: Re: [apps-discuss] JSON Hypertext Application Language
X-BeenThere: apps-discuss@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: General discussion of application-layer protocols <apps-discuss.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/apps-discuss>, <mailto:apps-discuss-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/apps-discuss>
List-Post: <mailto:apps-discuss@ietf.org>
List-Help: <mailto:apps-discuss-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/apps-discuss>, <mailto:apps-discuss-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 08 Jun 2012 19:37:14 -0000

Hi Martin thanks for sharing your thoughts

The spec is a WIP and you can read the latest version here:
https://raw.github.com/mikekelly/hal-rfc/master/draft-kelly-json-hal-00.txt

further comments inline

On Fri, Jun 8, 2012 at 8:01 PM, Martin Thomson <martin.thomson@gmail.com> wrote:
> On 6 June 2012 18:50, Mike Kelly <mikekelly321@gmail.com> wrote:
>> http://www.ietf.org/id/draft-kelly-json-hal-00.txt
>>
>> Feedback welcome..
>
> Let's test that theory...
>
> I was initially inclined to call this an abomination, but that would
> require fairly strong substantiation.  Let's just go with unnecessary.
>
> Some colleagues gave me an overview of an API that uses something very
> much like this.  And aside from the initial aesthetic reaction, I have
> two complaints:
>
> - _links is almost useless
> - _embedded is an unnecessary optimization
>
> Let's first attack the concept of generic linking.  It didn't work for
> XML.  Reason: A user of a particular document needs to understand the
> semantics attached to a particular link in order to make sense of it
> and generic labels rarely work.

Technically, according to the Web Linking specification referenced a
link relation type should either be registered with IANA or a URI.
Exposing an HTML document describing the semantics of the link at its
URI provides an avenue for making sense of a link that clearly can
work. I've written a 'browser' for HAL which lets you surf a HAL API
and allows you to pull up documentation as-you-go for relations that
are URIs.

> For instance, I need to understand that a link labelled "fishCannery"
> leads to a resource that describes a fish cannery.  The value added by
> _links is limited to signaling to a generic application that the value
> of "fishCannery" is not just a string, but a URI.  In practice, none
> of the fields other than href are used.

There is value in that, it allows someone to build a generic link
traversal DSL which you could then apply out of the box to your app
like so:

follow the "fishCannery" link and then
  query the "search" link setting "fish" equal to "tuna"


> Now, the optimization.  Well, mostly, it's just an optimization.  The
> folks I was talking to who used it, used it because they wanted to
> save on HTTP requests (or they were using long polling and wanted to
> push multiple "events" at the same time).  They had decomposed their
> application into resources, then discovered that it was a little slow
> when you want to pull multiple linked resources because it added round
> trips.

Yes, this is exactly the purpose of _embedded. They are parts of a
representation that actually represent the state of some other,
related, resource rather. Data URIs in links are another way to
achieve something similar but (iirc) they have a size limit, and there
is the obvious issue of human-readability.

> There are better solutions; c.f. httpbis discussion on server
> push.

Don't know enough to comment, sounds dubious that HTTP can eliminate
need for embedding.

> In an HTTP context, embedding messes with caching, cannot be regarded
> as authoritative, and doesn't benefit from resource metadata.
>
> So, what's wrong with JSON?

It doesn't have these linking or embedding semantics. We have no
standard to build re-usable libraries and tooling around, this is an
attempt to establish a base standard without over-complicating the
issue.

> p.s. It should be application/<application-specific-name>+hal+json if
> you want to get super pedantic on media types, since hal is just
> another layer.  c.f. the profile link relation type for a discussion
> on why a media type (or subtype marking) might be unnecessary.

yes you could use a profile if you were so inclined. Personally, I am
happy to rely on a preceding relation to provide the context/meaning
of a given resource. I don't think this discussion is relevant here
though.

Cheers,
Mike