Hacker News new | ask | show | jobs
by x3haloed 994 days ago
I think I have a solution to keep the peace, if we can all universally respect one rule:

Never use YAML outside of the Python ecosystem.

That way, people who love esoteric scripting formats that prioritize legibility over correctness, durability, and maintainability can keep all their tab characters, loose typing, and cryptic syntax. And the rest of us never have to! Those of us who prefer C-style syntax can keep our sanity.

Edit: OK, I think I've finally got my finger on the crux of the issue here. I think I can't explain this whole thing without being spicy. For C-syntax devs like myself, syntactic whitespace is pure madness. Whitespace is not information or an instruction -- it's formatting. Good formatting is helpful and useful, and good C-syntax devs care about legible formatting. In Python (and YAML), the formatting is instructional information. This has the benefit of making all functional code legible. But why the blazes does code have to be legible to be functional? Imagine working with a YAML coworker. You send them a long message. They reply with, "What? This is nonsense." You suddenly realize your mistake. Without separating your paragraphs with an empty line, you've broken the meaning of what you sent. Adding the empty lines back in and re-sending the chat message, your co-worker can now read what you wrote. Without syntactically-accurate formatting, the information you sent was meaningless.

5 comments

Another purpose of code, as in software, is to be readable (aside from being executable). There's a million ways to do the formatting, and i would prefer people to use linter when they write code (hopefully, the same linter i'm using).

Those languages enforce a standard syntactic structure; there are less ways to write unreadable code, which is a good thing.

I prefer the middle ground taken by Go and others—have a standard formatter that is part of the language that everyone agrees to use, but don't make that syntactically relevant. That way you get readable code without individual coders ever having to manually fiddle with indentation levels, which is a source of endless problems when copy/pasting.
Agreed, top comments smacks of gatekeeping. I work in both Python(ic) languages and in C/C++, both have their strengths and weaknesses. No need to start flame wars.
Generally it's assumed that significant whitespace is a philosophical or even religious issue: some people love it, others hate it, and while both camps rationalize their preferences, it seems it's it: just a strong preference.

However, I came to think that the difference is not philosophical. It is just that some tools (text editors, e-mail programs, etc) support significant whitespace well, while other don't.

For example, the text editors I use are all set up to display space and tab characters, and to display them differently (usually as a faint dot and a faint mdash, or something). I am used to it, and this does not distract me at all.

From my point of view, code is not some random text. We use fixed-width fonts for it that we would not use in a book, we color-code it, I don't see why not make the white space visible.

I still have a "philosophical" preference for languages without significant whitespace, but I don't hate languages with it, they are not a problem for me at all.

But if the tools you use and love don't have good support for significant whitespace, or you won't make the whitespace visible, or even, you know, use vaiable-size fonts for coding... Well, then you will hate significant whitespace with a passion and consider it pure madness!

:-)

Coming from a C background I had the same views as you regarding white space not being information or instruction. I'll admit I looked down my nose a bit at Python in it's early days because of it.

What changed my mind, of all things, was writing Coffeescript¹. I'm not a big fan of Javascript, and writing Coffeescript felt like a distillation of Crockford's The Good Parts book. You couldn't forget and generate the bad parts.

But additionally found the indenting as code felt quite pleasant. The only hassle is not being able to press % on an opening or closing curly brace in Vi to find the other end of the block. OTOH, with the indentation, if a piece of code looked wrong, it probably was.

Mind you, I still haven't learnt much Python.

¹ These days I use Typescript, but if they ever came out with a Coffeetypescript…

It seems a little crazy that we have a TOML stdlib but not YAML. also TOML is ugly
I think TOML is a great format. Almost self documenting, easy to understand, less foot Gün’s for the uninitiated and the best is it’s based on INI format, but it’s smarter.

If you think you need to serialize something more complex, use XML. It might look ugly, but it’s very powerful, can be verified on many levels and has a mature ecosystem.

“Cooler” doesn’t always mean better, especially for bigger data. Neither YAML, nor JSON scales to that sizes while being readable and easy to maintain.

This. I've said it in one of the other threads re: YAML. TOML is great for simple user editable configs. Once you get into data exchange territory, use XML. Just the ability to define a schema and 'test' your XML document conforms is powerful and can tell you if something's wrong long before you end up with catastrophic failures.
So what if it's ugly? Is this a serialization format or paintbrush?

Also, I think TOML stdlib gets to the heart of what I've been arguing. People who like syntactic whitespace like YAML. Everyone else (like C devs) don't. It makes quite a bit of sense to me that C devs don't want to touch YAML with a 10-ft pole.

It's not just aesthetically ugly — including the entire path to every item is just a lot. It's the opposite of DRY.
The Kubernetes community is looking at you with a curious look.