Re: [apps-discuss] JSON Hypertext Application Language

Martin Thomson <martin.thomson@gmail.com> Fri, 08 June 2012 19:02 UTC

Return-Path: <martin.thomson@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 E886A11E8115 for <apps-discuss@ietfa.amsl.com>; Fri, 8 Jun 2012 12:02:00 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.329
X-Spam-Level:
X-Spam-Status: No, score=-4.329 tagged_above=-999 required=5 tests=[AWL=-0.730, 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 1kd3YOygrFJk for <apps-discuss@ietfa.amsl.com>; Fri, 8 Jun 2012 12:02:00 -0700 (PDT)
Received: from mail-bk0-f44.google.com (mail-bk0-f44.google.com [209.85.214.44]) by ietfa.amsl.com (Postfix) with ESMTP id 42EB411E80F2 for <apps-discuss@ietf.org>; Fri, 8 Jun 2012 12:01:44 -0700 (PDT)
Received: by bkty8 with SMTP id y8so2395480bkt.31 for <apps-discuss@ietf.org>; Fri, 08 Jun 2012 12:01:43 -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=h4n/Dxw+c0wBQVqWqy+M4hvFxyHxD+RLkiCZqI/faFA=; b=k7V45SsQ6qXxyzS92KOWTlH5Ry4DC/EgyuQpcZj4W3Ieo3SX7nJV4Pkt4bY6XFmSuQ GZC2PJsHOUwQV6+/tegxnXfTSEnpABUUNxB2lqeP2mkQv4j9UO6BjgYk5uCtmcBto0dU ED7WoEZaqzOMIOq1ixGPlqcMBaiJgH7dMxkT6BUoMWVB9HZJH6RMV6kk6kXASSTs7Icn Im7p/m0BQrY8TA5QIHQXDEBnYv9awoVZaEZ34hu+tfAQYsn3tQtRkPgSdQ5tU8zaQke+ lxJs++xgcmA9LgyO6fN3GzTmmV6BMvKua9UUlvgSPEgo2xcBLk78PRnWKP5yGDhtDy+z IqTQ==
MIME-Version: 1.0
Received: by 10.204.152.73 with SMTP id f9mr6897511bkw.3.1339182103807; Fri, 08 Jun 2012 12:01:43 -0700 (PDT)
Received: by 10.204.66.4 with HTTP; Fri, 8 Jun 2012 12:01:43 -0700 (PDT)
In-Reply-To: <CANqiZJa7GrBRbiV8X=o3Xkv-WcBEdKEntiZSFhMj4efQiNPEaQ@mail.gmail.com>
References: <CANqiZJa7GrBRbiV8X=o3Xkv-WcBEdKEntiZSFhMj4efQiNPEaQ@mail.gmail.com>
Date: Fri, 08 Jun 2012 12:01:43 -0700
Message-ID: <CABkgnnXVFqEhS5oympA7E_GHhzYB+P5TQh1PugK5p16qNWSBVQ@mail.gmail.com>
From: Martin Thomson <martin.thomson@gmail.com>
To: Mike Kelly <mikekelly321@gmail.com>
Content-Type: text/plain; charset="UTF-8"
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:02:01 -0000

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.

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.

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.  There are better solutions; c.f. httpbis discussion on server
push.

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?

--Martin

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.