unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "Aleix Conchillo Flaqué" <aconchillo@gmail.com>
To: "Thompson, David" <dthompson2@worcester.edu>
Cc: guile-user <guile-user@gnu.org>
Subject: Re: guile-json 2.0.0 released
Date: Thu, 13 Dec 2018 14:48:03 -0800	[thread overview]
Message-ID: <CA+XASoWc32vNuQf8GQjzkf0R-m61R=YZPLakH_Nkm-U9eaLdfg@mail.gmail.com> (raw)
In-Reply-To: <CAJ=RwfZgUg6-bCoYJR-v48ywCROEMu94NrSGrNKjzJB0foCfTQ@mail.gmail.com>

On Thu, Dec 13, 2018 at 6:30 AM Thompson, David
<dthompson2@worcester.edu> wrote:
>
> On Thu, Dec 13, 2018 at 12:56 AM Aleix Conchillo Flaqué
> <aconchillo@gmail.com> wrote:
> >
> > Hi,
> >
> > I'm pleased to announce a new guile-json release 2.0.0. This is a
> > breaking change release. It is not possible anymore to specify a JSON
> > object using alists. Instead alist->hash-table needs to be explicitly
> > used (examples can be found on the github page). This makes the
> > bidirectional mapping between Guile hash-tables and JSON objects
> > consistent.
> >
> > https://github.com/aconchillo/guile-json
>
> I'm a little disappointed to see this change.

Sorry to hear that. Let's see if we can fix it :-).

>  There are a few major
> issues with using hash tables for this purpose:
>
> * They have no read syntax
> * They use a procedural, mutable API
> * They are slower than alists when the number of keys is small, which
> is 99% of the time when dealing with serializing objects
>

The reason I chose hash-tables back in 2013 was that I wanted to an
unordered data structure to strictly comply with the JSON spec.
Probably it doesn't really matter if an object is ordered or not but I
just wanted to stay as close to the spec as possible. Then, for JSON
arrays the obvious choice was to use lists. I didn't even think about
using vectors to represent arrays until jao (geiser's author) told me
a couple of days ago.

I agree with your points. My main concern is the one about the read
syntax, not too worried about performance (may be I should?). I have
to say I hate that users have to write alist->hash-table in guile-json
2.0.0, it's a pain in the butt. So I'm super open to make any changes
to the library that make it better for the users.

> For these reasons I do not use hash tables in my JSON
> parser/serializer that I submitted to Guile years ago (but was never
> merged) and use in many of my own projects.
>

Didn't know about that.

> Why not do something like Racket does and use vectors for JSON arrays
> and alists for JSON objects? It's not the ideal API IMO, but this way
> only core data types with read syntax are used and is an improvement
> over using hash tables.
>

That's one idea I was thinking to play with. That would really be a
breaking change all over the library. The current breaking change only
affects people building JSON (not sure how many of those are there),
my guess is that most people only use the parser, but then they have
to access the object through a hash-table. So, this would be a big
change for them.

I was also thinking to look at "reader macros", which was also a
suggestion from jao. I'm not sure if you can do that in Guile, but I
have found this:

https://lists.gnu.org/archive/html/guile-user/2016-03/msg00039.html

The idea would be to keep using hash-tables internally but allow the
user to do something like: {"foo" 1234} to represent an object.
Basically adding a bit of syntactic sugar.

Best,

Aleix



  parent reply	other threads:[~2018-12-13 22:48 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-13  5:18 guile-json 2.0.0 released Aleix Conchillo Flaqué
2018-12-13 14:30 ` Thompson, David
2018-12-13 16:35   ` John Cowan
2018-12-13 16:56     ` Thompson, David
2018-12-13 17:09       ` John Cowan
2018-12-13 17:33         ` Thompson, David
2018-12-13 18:28           ` John Cowan
2018-12-13 22:48   ` Aleix Conchillo Flaqué [this message]
2018-12-14  1:03     ` Aleix Conchillo Flaqué
2018-12-14  2:28     ` John Cowan
2018-12-18 16:45     ` Ludovic Courtès
2018-12-18 18:09       ` Aleix Conchillo Flaqué
2018-12-19 10:48         ` Ludovic Courtès
2018-12-19 18:14           ` Aleix Conchillo Flaqué
2018-12-19 19:17             ` rain1
2018-12-19 20:05             ` John Cowan
2018-12-19 21:13               ` Ludovic Courtès
2018-12-20  9:34             ` Aleix Conchillo Flaqué
2018-12-20 10:59               ` Ludovic Courtès
2018-12-20 18:09                 ` Aleix Conchillo Flaqué
2018-12-29 23:51                   ` Aleix Conchillo Flaqué
2018-12-18 23:48       ` rain1
2018-12-19 15:18         ` Arne Babenhauserheide

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+XASoWc32vNuQf8GQjzkf0R-m61R=YZPLakH_Nkm-U9eaLdfg@mail.gmail.com' \
    --to=aconchillo@gmail.com \
    --cc=dthompson2@worcester.edu \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).