Lua for Data Representation

(citrons.xyz)

42 points | by vinhnx 4 hours ago ago

9 comments

  • TheCycoONE 2 hours ago

    For better or worse CorsixTH makes extensive use of these techniques, as the config format [1], the translation format [2], and even the format for the update check [3]

    [1] https://github.com/CorsixTH/CorsixTH/blob/master/CorsixTH/Lu...

    [2] https://github.com/CorsixTH/CorsixTH/blob/master/CorsixTH/Lu...

    [3] https://github.com/CorsixTH/CorsixTH/blob/gh-pages/check-for...

  • gilber an hour ago

    Lua as a whole is incredibly underrated, especially given things like LuaJIT - I don't understand why it felt out of popularity with most people. Maybe related to Roblox.

    • edfsadfer an hour ago

      I myself have gone almost all-in on Lua Lapis (running in OpenResty) and Lua Fullmoon (running in RedBean) for anything server related.

    • jeffreyrogers an hour ago

      It doesn't have a good standard library since it was designed to be embedded in C/C++ programs for scripting rather than being a standalone scripting language and the package management ecosystem never fully took off.

    • altilunium 21 minutes ago

      when i was still involved in wikipedia template and module development, i was quite surprised that it mainly used lua.

    • fithisux 22 minutes ago

      It hasn't. Luau comes with two runtimes. Lua distros are many.

    • rdtsc 40 minutes ago

      Most developers don’t care about Roblox. Lua is cute but awkward.

      Let’s see, no native json support. This day and age it should be built in. No array support: is {} an empty json object or empty json array? Just add the dang arrays already.

      LuaJIT is very awesome! Amazingly fast. Does it support the latest Lua? Nope it doesn’t. Lua is at 5.5 or something, LuaJIT at 5.2 maybe.

      Default global vars? Nope. More awkward than cute. Maybe introduce some profile / pragma to invert that. Everything should be local by default not global.

      Speaking of Roblox, they liked Lua so much they forked it and created a new language altogether! Luau which is only fully compatible with 5.1

      I mean it’s still a nice language for a configuration format but otherwise I think that summarizes why people might not be reaching for it as much, in other cases.

      • strenholme 5 minutes ago

        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 have a 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.

  • binary132 2 hours ago

    It’s also pretty nice that a verb plus a table is implicitly a function call. This means you can easily do things that seem to be types:

      m = Menagerie {
        Dog { tail, ears, snout=long },
        Cat { you, get, the=idea },
        table.unpack(ark),
      }