Live data from Hacker News

Jsonnet – A data templating language

jsonnet.org

71–80 of 90 posts

Re: Jsonnet – A data templating language

#71

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…

It's just my gut feeling but for nondevelopers, the config storage doesn't matter as long as there is a good GUI to generate what they need to save or paste into another system.

Re: Jsonnet – A data templating language

#72
post #63

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…

Can dhall be compiled for Windows?

I don't see why not. Though I haven't tried it myself.

Re: Jsonnet – A data templating language

#73
post #44
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…

We tried jsonnet for several months to generate config, but eventually abandoned it because the templates got too hairy. Plus rendering is slow. We ended making the effort to simplify config of all our app’s components to just read from one large yaml file. Far happier with this solution.

I think databricks recently released an alternative jsonnet compiler/renderer written in Scala that's faster than the standard Google one (including a workaround for the slowness of JVM startup/shutdown) but compatible with it: https://databricks.com/blog/2018/10/12/writing-a-faster-json...

It was discussed on HN though I don't have the link handy.

But sure, if you are okay with a single yaml file, that's certainly simpler.

Re: Jsonnet – A data templating language

#74
post #68
post #56

Earlier quoted context omitted.

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.

It's not. http://journal.stuffwithstuff.com/2013/07/18/javascript-isnt...

I have no dog in this fight but saying JS isn't scheme because it isn't a True Scotsman (plus a bunch a appeal to emotion) doesn't make for a compelling counter-argument.

Re: Jsonnet – A data templating language

#75
post #50

Earlier quoted context omitted.

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

It is easy to get confused whether a brace is part of the json or part of the mustache/handlebars/etc. { "hello": {"{{place}}":{{{#items}}"{{thing}}":{{n}},{{/items}}}}, "urls": [{{#items}}"{{url}}",{{/items}}] } It's unambigious and can be reasoned through, but it's certainly hard to tell what structure the template is building at a glance. This is not a complex or contrived example. Syntax highlighting, linters, pr…

I hacked together a asdl parser in boost::spirit a while back that used mustache to generate the C++ AST (which was then used to generate its own AST to make sure it all worked) and can attest the curly braces in the templates were a righteous PITA to get right.

If I had to do it all over again I'd probably use the config option and change them to something like '(.', '.)' that doesn't naturally occur in the output language.

Re: Jsonnet – A data templating language

#78
I would be interested to hear what heavy lispers think of this. The whole mixing code and data together feels very lispy, albeit with a heavier syntax here... is this sort of a step off from s-expressions, or does it occupy a fundamentally different place?

Re: Jsonnet – A data templating language

#79
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…

If you are suggesting using Python is same as using JavaScript, you missed the point too.

In this case, JavaScript's syntax is very similar to Jsonnet. Or at least what is shown in the example can be accomplished in a very similar way. (maybe except anchors, which can be replaced by variables)

Post reply on HN