Lua is a viable alternative for JSON
So json parsing comes in all sizes - from being implemented in the host lang or being in C - from being blazingly fast™ to simply being slow. What is indeed comical is that json is just half arsed js with none of the benefits of the host language. Every time a new lang is invented, someone reinvents the wheel in both c and the host lang.
I think lua's portability is great over here. I think that using lua C api for parsing data and then plugging into the host lang by remapping lua tables into serializable objects. You can also spawn several lua_threads and parallelize the conversion with all the benefits of lua and none of the restrictions. Is it possible that web servers run one or several long-running lua threads and perform table conversions on the fly and get better performance?
(
13 comments
| 2 points
| on HN
)
But if you like it: nothing is stopping you. Let your frontend send Lua and let your backend parse it.
Kubernetes objects can be defined in JSON or in YAML. Helm added a template language on top of YAML (based on Go's template system). It has always been an ugly thing, though it functions.
One thing we really wanted to do in the Version 3 release a few years ago was make it possible to write Kubernetes definitions in Lua instead of YAML. Then we wouldn't need a template language. Additionally, we got all the benefits of a procedural language and a way to do inheritance (which would have been profoundly powerful as an alternative to literally hundreds of lines of boilerplate YAML). And it made extending other people's work nearly trivial. All in all, it looked like a far superior path to YAML with text templating.
We produced a POC, defined a specification, and went a good way down the implementation path before a few people in the Helm community voiced such noisy objections that we walked it back.
Their primary objection was simply that they didn't want the procedural logic and the definition to be "the same thing." It was better, in their minds, to have a static file format with a template language layered on top, because that was an appropriate separation of concerns.
I've had a few years now to reflect. And I do think Helm would have been better with Lua.
Do you have links or anything else you can share on the Lua specification work? I'd be interested to see what a Lua-based chart would look like.
Lua is nice in many ways but unless you have a pressing need for it I'd recommend sticking with JSON. If you really want executable configurations please consider a newer language like https://dascript.org or https://cuelang.org which provide better type safety.
1- https://news.ycombinator.com/item?id=38030778