From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Aleix_Conchillo_Flaqu=C3=A9?= Newsgroups: gmane.lisp.guile.user Subject: Re: guile-json 2.0.0 released Date: Thu, 13 Dec 2018 14:48:03 -0800 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1544741208 12630 195.159.176.226 (13 Dec 2018 22:46:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 13 Dec 2018 22:46:48 +0000 (UTC) Cc: guile-user To: "Thompson, David" Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Dec 13 23:46:43 2018 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gXZkg-0003CN-Ql for guile-user@m.gmane.org; Thu, 13 Dec 2018 23:46:42 +0100 Original-Received: from localhost ([::1]:57262 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXZmn-0003J4-Ik for guile-user@m.gmane.org; Thu, 13 Dec 2018 17:48:53 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXZmI-0003Hz-Ey for guile-user@gnu.org; Thu, 13 Dec 2018 17:48:23 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXZmF-0001Ux-Cl for guile-user@gnu.org; Thu, 13 Dec 2018 17:48:22 -0500 Original-Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]:33934) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXZmE-0001Ku-QT for guile-user@gnu.org; Thu, 13 Dec 2018 17:48:19 -0500 Original-Received: by mail-lj1-x22b.google.com with SMTP id u6-v6so3275166ljd.1 for ; Thu, 13 Dec 2018 14:48:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=t6kFtdgubTi5OY7+KyDfY6QnzUHX4rlP9TWdzRNRloI=; b=BIb5bRZWtl8aB3cgWG/pS0ALgCFLZFitg37HohQQ/cuv8jGwA8E2evx13F9r/2PvIG +PobyoA7oAlx+H3HqGqcDMX1uYkGooVARBcSud8psPBDNibYqRYCtS2rKjvcE4lmdctG Ei1dP9iuz1MV2j3Ml5Hfy4xp426E+j5iec6SU42uBlbSm6zVV7XaVLAd3ua7XdY/YaGo YYtvk/hpCXBbB3u4ZS2xskS3l2w92UXHadn2m6GM+vtX5bhEJo7zPICXE8o5T2K6Egmq LNrfNOvgr6aMHbCf2FJlPoEobT008iUswec+SzeEBi7TZP+cvjOtkSvuqKRKXy3nCPZw aTIQ== 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=t6kFtdgubTi5OY7+KyDfY6QnzUHX4rlP9TWdzRNRloI=; b=DDW6XhrJXLlc8LWERN1hOLHuY04GgU7phHl1J7Qfuh+r2jL010S0XGlcmTkABtKnu8 XpYUfJMO+U9UEBfuAFaXg0nsnLrn/Vh/CQ5VuWJ5/qUBuexkGnjyg6BwGGVT0pbQHo6y tTzTHmfMUcytZ+TH1/AH4RcnWLSaEoabrnpqoO97eQL7qoYWPO09TGwcNDxtRK4Cda6Z nWJRYEaxWBbiAoSHp+5QPaDJL0nrsm8MaWaAP7L0HL4YRhwBwIu8U10tWWtglpmhDMEj IqNhzGid5MHckinkyxMlpi2Z46X+TemCmDm1iMU5kmNrLtDbZIdyYp1ZNX41BuOiwobo bFSw== X-Gm-Message-State: AA+aEWZEURmDiqqqzsDqCl7XLImcW7zlLH6usBEpXEe9O1ZwLu9wS4DY 7dRrjI398ioLP9q40tHG4xQNA4rr4vxR1Wv/G9A= X-Google-Smtp-Source: AFSGD/X8GeI2ml1XkZycR3gcI0ZVO0KCA9Ou+5KUR84i4GRlQo3iQwn/cEj7Wkch9IDWdL5WZm9OqfUe5WTZYzVVyqo= X-Received: by 2002:a2e:3e04:: with SMTP id l4-v6mr321270lja.148.1544741295229; Thu, 13 Dec 2018 14:48:15 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::22b X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:15081 Archived-At: On Thu, Dec 13, 2018 at 6:30 AM Thompson, David wrote: > > On Thu, Dec 13, 2018 at 12:56 AM Aleix Conchillo Flaqu=C3=A9 > 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