Live data from Hacker News

Jsonnet – A data templating language

jsonnet.org

11–20 of 90 posts

Re: Jsonnet – A data templating language

#12
post #5

We have just had an article hitting nearly the top on not to use JSON for config https://arp242.net/weblog/json_as_configuration_files-_pleas...

That's the reason I posted this, since this is kind of using, without the drawbacks (of not having comments etc) I wonder if folks had had experience using it for kubernetes configs like https://jsonnet.org/articles/kubernetes.html

Pretty sure stripe built skycfg for this very purpose, but it uses starlark for the language, which is quite a lot nicer IMHO.

Re: Jsonnet – A data templating language

#13
post #10

Why would I use this over, say, Jinja? Do I really want imperative code in my config files? And if so, why not just use vanilla JS?

Jinja is a text templating language. A valid ninja template may not produce valid JSON/YAML/etc. Sometimes you need more power than a config language gives you, specifically when you want reuse. Helm uses something like jinja, but the template files are often complex and messy (and they are looking into supporting Lua to deal with these problems). CloudFormation built function semantics on top of JSON/YAML twice: once in the form of templates and again in the form of its intrinsic functions. Skycfg uses the starlark language to output YAML, and this is the best approach since it has the right semantics and uses a familiar language (starlark is stripped down Python).

Re: Jsonnet – A data templating language

#15
post #13
post #10

Why would I use this over, say, Jinja? Do I really want imperative code in my config files? And if so, why not just use vanilla JS?

Jinja is a text templating language. A valid ninja template may not produce valid JSON/YAML/etc. Sometimes you need more power than a config language gives you, specifically when you want reuse. Helm uses something like jinja, but the template files are often complex and messy (and they are looking into supporting Lua to deal with these problems). CloudFormation built function semantics on top of JSON/YAML twice: onc…

Why not jq, then?

Re: Jsonnet – A data templating language

#16
post #15
post #13

Earlier quoted context omitted.

Jinja is a text templating language. A valid ninja template may not produce valid JSON/YAML/etc. Sometimes you need more power than a config language gives you, specifically when you want reuse. Helm uses something like jinja, but the template files are often complex and messy (and they are looking into supporting Lua to deal with these problems). CloudFormation built function semantics on top of JSON/YAML twice: onc…

Why not jq, then?

jq is a json parsing tool, no?

Re: Jsonnet – A data templating language

#17
post #10

Why would I use this over, say, Jinja? Do I really want imperative code in my config files? And if so, why not just use vanilla JS?

Why don't you take a look at the link? It has a page specifically addressing these questions: https://jsonnet.org/articles/comparisons.html

Re: Jsonnet – A data templating language

#18
post #9

Some devs from my company just recently published https://jkcfg.github.io/ , building on lessons learned from many years of configuring Kubernetes. Since we are discussing JS for config management.

That logo is so cool. Extremely simple but elegant.

Re: Jsonnet – A data templating language

#19
post #17
post #10

Why would I use this over, say, Jinja? Do I really want imperative code in my config files? And if so, why not just use vanilla JS?

Why don't you take a look at the link? It has a page specifically addressing these questions: https://jsonnet.org/articles/comparisons.html

The link doesn’t specifically address the question “why not use vanilla JS?”

Re: Jsonnet – A data templating language

#20
post #19
post #17

Earlier quoted context omitted.

Why don't you take a look at the link? It has a page specifically addressing these questions: https://jsonnet.org/articles/comparisons.html

The link doesn’t specifically address the question “why not use vanilla JS?”

see "Comparison With Other Scripting Languages"
Post reply on HN