unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: John Cowan <cowan@ccil.org>
To: dthompson2@worcester.edu
Cc: guile-user@gnu.org
Subject: Re: guile-json 2.0.0 released
Date: Thu, 13 Dec 2018 11:35:22 -0500	[thread overview]
Message-ID: <CAD2gp_RySU8xCYferq9WGmFmRXDjn6YVjTEASk2eP+jtAvzX-g@mail.gmail.com> (raw)
In-Reply-To: <CAJ=RwfZgUg6-bCoYJR-v48ywCROEMu94NrSGrNKjzJB0foCfTQ@mail.gmail.com>

On Thu, Dec 13, 2018 at 9:31 AM Thompson, David <dthompson2@worcester.edu>
wrote:

* 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
>

I agree with these objections.


> Why not do something like Racket does and use vectors for JSON arrays
> and alists for JSON objects?


In fact Racket uses hash tables, but it provides a (non-standard) lexical
syntax for them: #hasheq followed by an a-list.


> 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.
>

My objection to using vectors for JSON arrays is that they are often built
up
element by element, which JavaScript arrays support but Scheme vectors
do not.  So in practice you would create a list and then convert it to a
vector.

While the same thing is sometimes done with objects, it is more common
for an object to have a reasonably fixed structure, which can be well
represented as a vector of pairs, the vector equivalent of an alist.
When the elements of the object are variable, they can be built up
as an alist and then converted with list->vector.

So given that we are changing the structure anyhow, I recommend this
approach.

-- 
John Cowan          http://vrici.lojban.org/~cowan        cowan@ccil.org
Even a refrigerator can conform to the XML Infoset, as long as it has
a door sticker saying "No information items inside".  --Eve Maler


  reply	other threads:[~2018-12-13 16:35 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 [this message]
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é
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=CAD2gp_RySU8xCYferq9WGmFmRXDjn6YVjTEASk2eP+jtAvzX-g@mail.gmail.com \
    --to=cowan@ccil.org \
    --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).