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

Aaron Sherber aaron at sherber.com
Thu Mar 23 13:52:30 CET 2023


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20230323/0959a1bd/attachment.html>


More information about the JWLua mailing list