[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Is Lua used as a data representation language?
- From: William Ahern <william@...>
- Date: Sat, 5 Jan 2013 12:01:33 -0800
On Sat, Jan 05, 2013 at 11:03:22AM +0100, Marc Balmer wrote:
> There is an ongoing discussion in the NetBSD community about the "right"
> language for data representation. The idea is to replace an older system
> called "proplib". The discussion rotaes a bit around JSON and Lua as
> possible candidates, with probably a majority leaning towards JSON because
> it is smaller (some say a factor of ~16 compared to Lua).
I presume they meant in terms of size of the library. But I consider this a
specious argument. The biggest reason, IME, why people end up messing around
with configuration languages isn't the representation, its the API.
Specifically, how well the representation can match a convenient API in the
application. A tiny JSON library is going to be a headache and a hurdle when
manipulating complex configurations. Libraries like proplib are very
inelegent. They make the simple stuff take more work than necessary and the
hard stuff excruciating.
I wrote a JSON library that supports XPath-like syntax and autovivification:
http://25thandclement.com/~william/projects/json.c.html
It's still 3k LoC. Bigger than many other JSON libraries, but that's because
it's useful.
I still prefer using Lua where I can, of course. Although, autovivification
is very nice in a configuration language, and Lua can't quite manage it,
unfortunately. But with Lua at least you can script accessor routines. This
is what I do in some other projects.
> One statement by a colleague is: "Now for the data transfer
> representation, as in D.'s proposal, JSON is an option, but LUA is not,
> simply because we have no (and there can not be any) small C binding to
> it."
>
> I'd like to do a quick poll to see whether Lua is used as a language for
> data representation. If you know of such uses, please mail me some
> details.
We use it at my work, Barracuda Networks. We have more projects and products
than I can count. Lua is one among several, although I don't know of any
that use JSON to store configurations; just for exchange.