Live data from Hacker News

Jsonnet – A data templating language

jsonnet.org

51–60 of 90 posts

Re: Jsonnet – A data templating language

#51
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?

With a deep enough JSON structure with similar enough items, the jq expressions are hard to make or maintain. This is a real world example: jq '.sourceSelectionTrees[].rootNode.children[].children' | jq '.[]? | .action.attributeMapping.attributeSources' | jq -r '.[]? | select(.type == "XYZ") | .dataRef.id'

Re: Jsonnet – A data templating language

#52
post #50

There's a real need for JSON templating languages not targeting developers. Tools like Zapier, Customer.io's webhooks, etc. allow integration with arbitrary APIs and have become a standard part of many marketing/sales stacks. These apps use things like Jinja, Mustache, or Liquid which are great for text but not JSON templates. Curly braces as primary delimiters, not allowing trailing commas on final elements, and oth…

What is it about "curly braces as primary delimiters" that you think is a hassle? What would you suggest instead?

Curly braces on US Layout keyboards are fine, they just need to be balanced. On keyboards with German layout curly braces are really hard to type and on Mac keyboards with German layout they are not even marked. So I don’t think any programmer can work with such a layout, yet many people do exactly that.

Re: Jsonnet – A data templating language

#53
The Lua language was originally a data templateing language [0], and is still very good for that, but like all such things, it grew. Contrary to Greenspun's Tenth Rule [1], Lua's implementation of Lisp is not at all ad-hoc, informally-specified, bug-ridden, or slow.

[0] https://www.lua.org/history.html

[1] https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule

Re: Jsonnet – A data templating language

#54

Also check out https://dhall-lang.org It's GCL but with a strong type system and termination guarantees. I personally like the syntax a bit more than jsonnet. It's a bit less noisy. I'm also a bit biased because I work on https://github.com/dhall-lang/dhall-kubernetes . We're currently working on a 2.0 release so the current state of the repo is a bit in turmoil. Programmable configuration language like dhall an json…

Just my two cents but I would go against the first interaction with the user being find the bug, I didn't didn't find it and missed the point, granted I didn't take much time and I'm on mobile, but I guess that's the reality for many people if not most :)

Re: Jsonnet – A data templating language

#55
post #54

Also check out https://dhall-lang.org It's GCL but with a strong type system and termination guarantees. I personally like the syntax a bit more than jsonnet. It's a bit less noisy. I'm also a bit biased because I work on https://github.com/dhall-lang/dhall-kubernetes . We're currently working on a 2.0 release so the current state of the repo is a bit in turmoil. Programmable configuration language like dhall an json…

Just my two cents but I would go against the first interaction with the user being find the bug, I didn't didn't find it and missed the point, granted I didn't take much time and I'm on mobile, but I guess that's the reality for many people if not most :)

The bug is that your SSH keys are in /home/bill/.ssh/. But I agree the first page really don't help sell the idea.

Re: Jsonnet – A data templating language

#56
post #36

All the people suggesting to use JS instead of Jsonnet are completely missing the point. Jsonnet is a functional lazy evaluated language that supports powerful referential concepts. Unfortunately the website sucks at getting this across. JS on the other hand is an imperative programming language. If you say "use JS" you may as well say "use Python", the 2 are equivalent in this context and neither are in the same cla…

JS is a lot closer to Scheme and Lisps than an imperative language. In fact, it used to have a lispy syntax before Brenden Eich was forced to change it to make it more approachable.

Re: Jsonnet – A data templating language

#58
post #39

Finally a public version of GCL/Borgcfg :-) For people who doesn't know, GCL (Generic/Google Config Language) is a language that uses dynamic scope. You can define a `template` object with a variable defined as `external`. This way you can create similar objects by providing a concrete value for those `external`s at the time of instantiating. The following paper was referenced in Google's borg paper and gives a good…

Maybe it’s because I’m not a top 1% intelligence that I don’t get this but under what circumstances would configurations become complex enough to where this becomes necessary?

I don't think it's an intelligence thing just what problems one's come across. Generating configs for various deployments where resources change? Generating configs for developer set up? If you start having a lot of environmental variables or private keys it might be more manageable to get them from another secure source.

Re: Jsonnet – A data templating language

#59
I needed a templated language recently (couldn’t do with Mustache methods). Looked at jsonnet but it looked quite abandoned. Ended up finding Json-E [0]. Pretty powerful, and give you the option to pass in methods to the context as to expose them. No support for Async methods, but I wrapped around it with some Promises and did the trick.

[0] https://github.com/taskcluster/json-e

Post reply on HN