logoalt Hacker News

strenholme • today at 6:35 AM • 1 reply • view on HN

Wanting things like native JSON support goes against the Lua spirit. Something like that belongs in a library, and lo and behold, there are several:

https://luarocks.org/modules/luarocks/json4lua - https://luarocks.org/modules/winterstream/wjson - https://luarocks.org/modules/xpol/rapidjson - etc.

Lua supports arrays; it has optimizations when all of a table’s keys are integers. Keep in mind that AWK is the same way: There’s no numeric array in AWK per se either, just AWK’s version of a “table”, but it works just fine when all of the keys are integers.

Keep in mind that I have a fork of Lua which is 116,224 bytes in size (security hardened Lua 5.1 with `lfs` support); Lua is tiny and that’s why it does not have a built in JSON library nor will it wash the dishes for you.

Versions of Lua after Lua 5.1 introduced changes which broke backward compatibility. Lua 5.1 is smaller than newer versions of Lua, runs great, and is incredibly fast. I see Lua 5.5 as a different language than Lua 5.1, even though one can make a polyglot program which can run in both. Lua 5.1 is also the point from which a bunch of offshoots were made: luau (Roblox Lua), LuaJIT, etc.


Replies

rdtsc • today at 3:31 PM

> Wanting things like native JSON support goes against the Lua spirit. Something like that belongs in a library, and lo and behold, there are several:

I guess my point is that why it's not picked as large of a support. I can see that being a good reason for Lua in 2006 when JSON was still not as popular but for better or worser, it's taken over so having built in JSON support would help, especially for a language geared for configuration and data representation.

> Keep in mind that I have a fork of Lua which is 116,224 bytes in size (security hardened Lua 5.1 with `lfs` support); Lua is tiny and that’s why it does not have a built in JSON library nor will it wash the dishes for you.

Agree, that's where it really shines, it's small and embeddable.

> Lua 5.1 is also the point from which a bunch of offshoots were made: luau (Roblox Lua), LuaJIT, etc.

But you see how the official site doesn't seem to issue bug fixes for anything lower than 5.4 yet everyone says 5.1 is the version to stick with. And there is luau and LuaJIT as well, that I think explains a bit why people are embracing it as eagerly any longer.

➕ show 1 reply