Jsonnet – A data templating language
21–30 of 90 posts
Re: Jsonnet – A data templating language
#22Re: Jsonnet – A data templating language
#23Why 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?
Re: Jsonnet – A data templating language
#24Re: Jsonnet – A data templating language
#25This looks like a public version of gcl/borgcfg... But with JavaScript mixed in (so even worse, if that was possible)
Re: Jsonnet – A data templating language
#26No thanks I'll just write JavaScript
Exactly my thoughts. I don’t see how it’s better than JS or TypeScript. I can render any object into JSON. This is in fact how I manage Kubernetes manifests. I use this package: https://www.npmjs.com/package/kubernetes-models Then I write normal TypeScript code to create Kubernetes objects/resources. Then I render it to JSON and feed to kubectl. The beauty of this solution is that it’s OOP and DRY.
Re: Jsonnet – A data templating language
#27jsonnet /dev/stdin {"x":10,"y":10}
Re: Jsonnet – A data templating language
#28For example, here's a config for NER with ELMo:
https://github.com/allenai/allennlp/blob/master/training_con...
I guess the only really jsonnet-specific thing here is std.extVar() call, but generally speaking it's just a more flexible JSON file that doesn't cost much more to use (brainpower or physical resources). I use it to mix and match configs while debugging sometimes as you can do things like if statements and adding dicts together.
It's also nice for modularization, you can do things like having a function that returns a dict, so if your config needs two slightly different datareaders you can just pull out all the common parts and call the function twice instead of having two copies of the entire datareader config (with only minor differences).
Re: Jsonnet – A data templating language
#29Re: Jsonnet – A data templating language
#30Earlier quoted context omitted.
Exactly my thoughts. I don’t see how it’s better than JS or TypeScript. I can render any object into JSON. This is in fact how I manage Kubernetes manifests. I use this package: https://www.npmjs.com/package/kubernetes-models Then I write normal TypeScript code to create Kubernetes objects/resources. Then I render it to JSON and feed to kubectl. The beauty of this solution is that it’s OOP and DRY.
You're assuming that all code can be trusted. Jsonnet is much easier to make secure than JS, since it can be statically guaranteed to be safe and side-effect-free (e.g. can't access the file system). This permits evaluating arbitrary untrusted data, which can be a boon to systems like CI servers, databases, or even Kubernetes (think Helm charts).
He has a TS script that outputs JSON, which he is using as config.