[JW Lua] Embed a JSON interpreter (cjson? dkjson?)

Aaron Sherber aaron at sherber.com
Thu Mar 23 14:48:52 CET 2023


I guess I would say that I don't see a good reason for changing the current
setup.

There's a larger question about where to draw the line between RGP Lua,
user scripts, and the includes that are currently in the repo. For
instance, there are more user scripts that use mixins than ones that use
json, but I don't think we're considering including mixins in RGP Lua.

If the json library is included with RGP Lua, then user scripts that use
json will also have to decide whether to specify a minimum version of RGP
Lua or include a fallback to lunajson (in which case I think there's no
advantage to the embedded encoder, since lunajson would still need to be
bundled with the script).

Keep in mind also that my "Document Options as JSON" script has a
particular need to emit formatted JSON in alphabetical order, which is why
I rolled my own encoder. So from a personal perspective, an embedded json
library would only have value to me if it included both of those bits of
functionality.

Aaron.





On Thu, Mar 23, 2023 at 9:27 AM Robert Patterson <
robert at robertgpatterson.com> wrote:

> I'd say the biggest practical advantage of embedding it is that it removes
> friction from using it and facilitates platform independence. I'm guessing
> that's why Exasol embedded it as well. It was the same motivation as for
> Luasocket. Plus it is possible that speed matters more in a database engine.
>
>
> On Thu, Mar 23, 2023 at 7:54 AM Aaron Sherber <aaron at sherber.com> wrote:
>
>> I find speed comparisons not highly relevant in situations like this,
>> because we're talking about at most a handful of operations at a time. For
>> example, look at the speed comparisons at the bottom of the page here:
>> http://lua-users.org/wiki/JsonModules  Speeds range from 0.5 sec to 122
>> sec -- for 100000 iterations. That means even the slowest time was just
>> over 1 millisec per iteration. Make it an order of magnitude or two slower,
>> and a human being can't tell the difference.
>>
>> I'm not saying I'd be opposed to embedding a JSON encoder -- I'm just
>> trying to understand what the practical advantages might be.
>>
>> I'm also curious: How do you see Finale interacting with web services?
>>
>> Aaron.
>>
>>
>>
>>
>>
>>
>> On Wed, Mar 22, 2023 at 11:26 PM Robert Patterson <
>> robert at robertgpatterson.com> wrote:
>>
>>> There are two main reasons for CJSON in particular. One leads to the
>>> other:
>>>
>>> 1. CJSON is a pure C implementation, which means it is more than an
>>> order of magnitude faster than dkjson
>>> <https://kyne.com.au/~mark/software/lua-json-performance.html>.
>>> 2. Once we are talking about a C implementation, the dependencies start
>>> to magnify. I embedded Luasocket and Luaosutils for the same reason.
>>> Embedding means there is no extra cruft outside your script, and the same
>>> script is usable on either platform.
>>>
>>> I see JSON as potentially becoming more important to Finale Lua since I
>>> have added https post to luaosutils. (It's already available in the
>>> experimental version of RGP Lua I released, called internet.post.) If
>>> we start integrating Finale with web services, which is a capability I have
>>> in mind, JSON is likely to be a critical component of it.
>>>
>>> BTW: I desperately wanted to use Luasocket for http, but for https it
>>> requires LuaSec, and LuaSec has exploding dependencies. By contrast,
>>> Luaosutils is lightweight and uses os-level services on Mac and Win to
>>> send/receive data.
>>>
>>>
>>> On Wed, Mar 22, 2023 at 7:28 PM Aaron Sherber <aaron at sherber.com> wrote:
>>>
>>>> What would be the advantages of embedding it with Lua as opposed to the
>>>> current method of requiring it (from src/lunajson) when it's needed?
>>>>
>>>> Aaron.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Wed, Mar 22, 2023 at 8:05 PM Robert Patterson <
>>>> robert at robertgpatterson.com> wrote:
>>>>
>>>>> I just discovered that the Exasol database engine has an embedded Lua
>>>>> interpreter similar to ours. I found a series of blog posts about their
>>>>> efforts to upgrade from Lua 5.1 to Lua 5.4 (written last November.)
>>>>>
>>>>> Like us, they embed LuaSocket. Another thing they do is embed cjson.
>>>>> Is that something we should think about doing for our embedded Lua? I
>>>>> already know of three Finale Lua scripts that use a json formatter, and
>>>>> there will probably be more.
>>>>>
>>>>> Robert
>>>>>
>>>>> _______________________________________________
>>>>> JWLua mailing list
>>>>> JWLua at jwmusic.nu
>>>>> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>>>>
>>>> _______________________________________________
>>>> JWLua mailing list
>>>> JWLua at jwmusic.nu
>>>> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>>>
>>> _______________________________________________
>>> JWLua mailing list
>>> JWLua at jwmusic.nu
>>> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>>
>> _______________________________________________
>> JWLua mailing list
>> JWLua at jwmusic.nu
>> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20230323/afa05e83/attachment.htm>


More information about the JWLua mailing list