This can be a fancified excerpt of Carl M. Johnson’s unpopular opinion on the Go Time podcast. Click on right here to pay attention alongside when you learn or watch the video on YouTube. Bounce to the top for the ballot outcomes. 📊
My spicy take is that XML is best than YAML, as a result of there are conditions the place XML is acceptable, however there’s no scenario the place YAML is acceptable.
Johnny Boursiquot: Dang. Pictures fired! 🤣
Let’s speak about XML first
So, XML acquired a extremely dangerous popularity. The rationale it acquired a extremely dangerous popularity is as a result of folks had been utilizing it for issues that it ought to by no means have been used for. XML stands for Extensible Markup Language. And for those who’re utilizing it as an extensible markup language, it’s really actually nice.
Let’s say you’re engaged on one thing and also you’re like:
“I’m making a brand new form of e-book, and I have to annotate all the verses within the Bible, and have the chapter headings and stuff.”
It’s nice for that.
It’s actually good for when you’ve a doc, and a few issues are italicized, and a few issues are in a international language, and subtitles, and all that stuff. It’s actually good for that. It’s not good if it’s like:
“I have to configure this server and the server must know if this worth is true or false.”
No, that’s dangerous. Don’t try this. That’s not use for XML.
However XML does have some makes use of for which it’s acceptable. And I believe the truth that now all people is writing React… and so they’re writing it with JSX… and JSX is principally simply inline XML… I believe that exhibits that there are instances the place really XML is fairly good.
YAML then again
YAML then again I believe is rarely good. There’s all the time one thing higher than YAML!
We’ve lastly made it to Go 1.21 and I’m very glad about this. And you realize why? As a result of YAML repeatedly bit me within the behind on Go 1.20. Ask me why.
Johnny Boursiquot: Why?
Effectively, while you say in your check file:
“check this in opposition to Go 1.20”
It interprets that as Go 1.2. 😭🤣
So it was like two or three totally different occasions I had a repo the place I’m like:
“These exams aren’t passing. Why are my exams not passing?! I’ve simply upgraded to Go 1.20.”
And it was like:
“Oh, no. I’ve determined that that is Go 1.2”
And so YAML is all the time going to try this to you…
Higher selections
Now, I perceive why folks do YAML, however there are higher selections. You should utilize TOML. You should utilize CUE. You should utilize numerous issues.
I like how Caddy does it. With Caddy, the canonical language that Caddy understands is JSON, however they’ve adapters.
So if you wish to write YAML, you possibly can. But it surely’ll simply take that YAML and switch it into JSON behind the scenes. Then in addition they have a selected Caddy language. So that you can provide it the Caddy language after which it turns that into JSON behind the scenes. And you’ll give it an NGINX config and it’ll flip that into JSON behind the scenes. When you’ve got the cycles and time to spare, that’s in all probability one of the best answer for most individuals…
However when the one technique to do it’s YAML, it’s like:
“No…!”
It’s simply too error-prone, there’s too many issues… You simply need to all the time quote every thing.
Additionally…
Additionally the YAML specification has all these options that no person ever makes use of, as a result of they’re actually complicated, and onerous, and you’ll embody paperwork within different paperwork, with references and stuff… And it’s like
“Oh, man, I don’t wish to have to know any of these items.”
After which for those who’re not cautious, it’d be like:
“Oh yeah, the primary three issues I fed it to understood that, however then the third one was similar to utilizing some parser that they discovered on the again of a truck, and it doesn’t perceive it”
and it’s like:
“Oh, man…”
YAML… by no means acceptable. XML is usually acceptable.
The polls are open 🗳️
There you’ve it. Carl’s reasoning for why XML is best than YAML. Do you agree or disagree? Let your opinion be heard by voting on Mastodon and X!
Or simply duke it out within the feedback under … we’re listening! 👇