Considering then abandoning JSX for structured YAML config
kirbysayshi.com
kirbysayshi.com
I’ve been completely explicit that if there is some other language or process they want to use then I’m more than happy to assist.
Avoiding YAML is this way has saved my sanity on more than one occasion.
People like YAML because it doesn’t require double quotes in the simple case of adding some text to a key. And people don’t like adding trailing commas to array items.
The problem is the insanity of parsing values like “true” or “off” or “123”.
“template”
multiline string values back into valid yaml for proper indenting.
Works great, the issue is explaining to anybody why it was necessary, they understand it works but plead for a better way.
It’s one of those clever solutions that seems overcomplicated until you try to replace it and realize it’s actually quite elegant.
Consider this pseudocode expression:
:Div{Hello :Span(style='bold'){world}} # expression type: HTMLDOMNode.Div
This is immensely powerful and saves a ton of time/bugs especially when compared to the alternative of string interpolation.
I know somebody once did XHP on Python, but regrettably this work was abandoned.
I read it if only to glean why anyone would do this. I learned nothing of the sort of person who would use Javascript to structure a YAML config.
10 years ago this article would have been "Used PHP for structured YAML config" and there would have been a minor riot of people poking fun at the article writer for attempting such sillyness. (And I say this someone who still made my money on PHP 10 years ago).
We got soft somewhere along the way and stopped calling out silliness.
nindent makes me yell especially.
What‘s wrong with configuring our platforms with a real, perfectly working programming language? I think the author had a great point with the schema being disconnected from the configuration file, but he missed the big picture with JSX: JavaScript (or TypeScript) can be perfectly used to emit JSON. JS tooling works with .config.js files.
Why must I experience the living hell of helm charts and kubernetes configuration file templates, when I could just emit my config with my favorite programming language?
Python's "you must execute arbitrary code to find out a packages dependencies", and the hell that makes working with their packaging ecosystem as a whole, is what's wrong with using a general purpose programming language for configuration (not that I'm a fan of YAML either)
But now, almost all packages are specified using plain text files. You still need to execute code to compile a sdist that has native code, but that’s a separate thing.
Candidly I think python is going to be forever stunted after the python 2 to python 3 multi year fiasco.
Every user reporting a problem incurs in a lot of cognitive load for you because the user has the freedom to go crazy with a real programming language.. or not but it's just different enough from the previous bug report that you can't generalize your troubleshooting.
I think our best hope right now is to have jsonnet be more widely adopted.
Good luck with that. You'll be teaching your users (especially the paying ones) how to use the language.
Nobody stops you from creating the configs right now using your own serialiser, but having a common understanding of what's being read by the app and mostly talking about that format helps the ecosystem.
It's often quite hard to know what kind of problems need an API and what kind of problems need configuration. It's sometimes only obvious in retrospect - the same point when you also get held back from changing things by backwards compatibility and culture.
The reverse problem (no configuration, only turing complete code) carries its own set of problems and can be just as infuriating. Getting the balance just right is hard and often only clear in retrospect.
Kubernetes really should have done something about the templating horrors by now though.