3 ms·
Almost 200 comments as of now, but no one mentions Lua tables as an alternative to JSON? Yes, you have to include the runtime, but the size of it is all but gu
by krapp 8y ago
Almost 200 comments as of now, but no one mentions Lua tables as an alternative to JSON?
Yes, you have to include the runtime, but the size of it is all but guaranteed to be smaller than whatever library you need to parse YAML or TOML or XML (or JSON in many languages.) Smaller than some fonts.
The syntax is almost the same as JSON, but you can use comments and multiline strings. There are also APIs for just about every language imaginable.
You do sacrifice an enforced lack of programmability unless you're self disciplined, though, and Lua does index at 1 instead of 0, which is annoying and objectively wrong, but still less of a gotcha than some of the crazy stuff YAML does.
... that said, I do also feel like anything touching the web stack at all should probably be using JSON just because javascript engines already parse it.
- fit2rule 8y agoI came here looking for other lovers of Lua. Configuration is in Lua's roots. It is specifically designed for use as a self-documenting configuration language. I think the issue is that people just don't know how to use Lua to load config files. ;) But the fact is, there are few other better options than to include the Lua VM and then put all configuration management in .lua files on the target system.
- Dylan16807 8y agoLua's great, but if a thousand lines of C or 500 of python can parse TOML then I doubt the average parser gets anywhere near the size of the Lua runtime. Also you have to supply your own encode function.
- spc476 8y agoI use Lua for configuration (even at work---ops has no problem with it). It even allows trailing commas. You can even use semicolons if you want. As for the index issue, you might find it annoying, but I would argue the "objectively wrong" bit (there are other languages, like Fortran, that use 1-indexing).