4 ms·
Considering then abandoning JSX for structured YAML config
- taspeotis 3y agoYAML = Yelling At My Laptop nindent makes me yell especially.
- zamalek 3y agoSo long as you use only string keys you can completely replace YAML with JSON (i.e. you can write JSON to a YAML file). Just make a .d.ts for your config schema and you're done. Avoiding YAML is this way has saved my sanity on more than one occasion.
- pipes 3y agoI've considered just converting to JSON , editing, then converting back to yaml. Yaml is a nightmare and I've no idea why it ever caught on.
- matthews2 3y agoYou don’t need to convert back to yaml. Your json is valid yaml.
- koolba 3y ago> … I've no idea why it ever caught on. 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”.
- viraptor 3y agoAlso multiline string blocks, comments, type tags, real datetimes.
- twic 3y agoIME, YAML appeals to people who like Ruby. I find both of them a nightmare, but it's clear that there is a kind of mine quite different to mine that sees something in them that i don't.
- salamander014 3y agoI’ve done this to automate and… err… “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.
- selfmodruntime 3y agoI am baffled that we as an industry landed on the concept of „code over configuration“, then went on to choose text based formats like yaml or json and consider it perfectly normal to write these by hand? Or even worse, we use bastardized in-file template strings to generate hopefully valid YAML in the end. 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?
- deleted 3y ago[deleted]
- hitchstory 3y agoThis pattern keeps repeating because the creators of an app think they need a configuration language (which some users do) and then when eventually other users end up needing an API or some feature the config language doesnt have. They both dont exist so they hack it with templating. 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.
- dwattttt 3y ago> What‘s wrong with configuring our platforms with a real, perfectly working 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)
- pointlessone 3y agoMaybe a silly question, but if you have a programming language available why can’t you buld a native structure, validate it and serialise it to YAML/JSON/whatever completely skipping templating part?
- blipvert 3y agoThis seems entirely reasonable to me. I built an application which gets used by the network team and consumes a JSON config file. The team edits a simple YAML file which is then heavily processed/checked and emitted as JSON. 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.
- yen223 3y agoFunnily, that's what JSON is for Javascript.
- YouWhy 3y agoThe most useful construct I am aware of that I wish became more popular in backend languages is strongly typed tree literals. (Introduced by Meta in Hack as "XHP") 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.
- deleted 3y ago[deleted]
- zer00eyz 3y agoI read this. 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.