logoalt Hacker News

Lua for data representation (2025)

84 points • by vinhnx • today at 3:04 AM • 39 comments • view on HN

Comments

tylerneylon • today at 6:56 AM

It's not a coincidence that Lua's good at representing data -- the language started life as a data-specification syntax called Simple Object Language. Or SOL (sun), which evolved into Lua (moon). If you've used BibTeX, then SOL will look familiar -- also not a coincidence! (BibTeX was first.)

The article indirectly nods to that history by linking here: https://www.lua.org/history.html#:~:text=All%20this%20config...

gilber • today at 5:18 AM

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.

➕ show 9 replies
virtualritz • today at 1:53 PM

The 3Delight|NSI offline 3D renderer has supported Lua as scene description (essentially data) since about 15 years.

It was their answer to the old VFX industry default, RIB (or custom scene description) files (i.e. data) manipulated with "filters" or inline-expanded Python inside the "pipeline".

Didn't get traction but it was the right idea and they never discontinued support for it.

If you watch movies/series containing VFX you have seen CGI rendered with 3Delight. But most of it will have been intermediate .nsi files, not .lua.

gonzus • today at 8:00 AM

In my experience, tying your data format to a programming language is a mistake you most likely will pay for later. For example, when you need access to that data from a different programming language.

➕ show 1 reply
TheCycoONE • today at 4:43 AM

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

computerfriend • today at 9:13 AM

Unrelated to the content: the ad at the bottom is from a very delightful ad network https://john.citrons.xyz/.

Mikhail_Edoshin • today at 9:04 AM

I'd say a tool-command format is a distinct and very good syntax for arbitrary data representation. The input consists of lines; each line starts with a command name, followed by optional arguments. There is some continuation syntax to wrap long arguments. The order of lines matters because each line is executed with its argument by some handler; the handler may modify the execution context. Aside from the command name there is no syntax other than whitespace. And since it quietly accumulates the context it gets very compact too.

binary132 • today at 4:43 AM

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),
  }
➕ show 1 reply
flaburgana • today at 9:28 AM

[dead]