News for hackers. Stuff that matters.
Re:YAML: Probably not so great after all by fabian2k on Sunday August 18, 2019 @01:31PM (#20731579)
I've used YAML as the format for a config file, and I certainly regret that choice. Trying to explain to someone that doesn't know YAML how to edit it without setting them up for failure is quite annoying. There are too many non-obvious ways to screw up, like forgetting the space after the colon or of course bad indentation.
Re:YAML: Probably not so great after all by bastardoperator on Sunday August 18, 2019 @06:46PM (#20733438)
YAML is easier to read and write. That's the benefit. It's also always going to be smaller than anything JSON or XML. Maybe it's not as correct, maybe some people don't like it, I don't really mind it. I don't see it really going anywhere soon either considering Kubernetes and the lack of alternatives in widespread usage.

I've never had someone that needed extensive help understanding YAML and that's besides reviewing work for people just coming up to speed. Find me an IDE or editor that doesn't have YAML support. Also, YAML supports comments so if you have pitfalls people need to know about you can document them inline.

Your argument is people who don't know things might screw stuff up. Well Yeah! This applies to everything.

Re:YAML: Probably not so great after all by jtdev on Sunday August 18, 2019 @11:00PM (#20734553)
>”YAML is easier to read and write.”

You may be surprised to find that there’s significant disagreement on that point.

Re:YAML: Probably not so great after all by bastardoperator on Sunday August 18, 2019 @11:58PM (#20734776)
Not surprised at all, people on the internet complain about everything. When they build something better I'll be the first to jump ship.
Re:YAML: Probably not so great after all by geocar on Monday August 19, 2019 @03:24AM (#20735646)
> When they build something better I'll be the first to jump ship.

Will you though?

With learning a tool (almost any tool), its value increases with more use until you find a local maximum. The amount of effort to switch to something with a higher maximum at that point will definitely be considered by most people as part of the cost of that competitor. It is very hard to write off years of your life on anything.

When was the last time you did this?

It could take a few months at a minimum, just to see if you can understand it. Then, perhaps years of building things another way just to get good at it. Would you really give a few years of your life in making configuration suck less forever?

If you're serious, I have a potential solution: We don't have configuration files (or indention) or parsing problems, and users aren't the slightest bit confused on how to configure our applications (although they are often surprised if they've ever had to use a configuration file!). The downside is it's going to require a lot of re-learning on your part, and there's little I can do to make it any easier for you.

Re:YAML: Probably not so great after all by bastardoperator on Monday August 19, 2019 @05:05AM (#20736130)
Will I? Personally, I enjoy tinkering with new tech. If we look at trends in technology, it's an absolute guarantee.

The last time I wrote off technology? In 30 years I've been doing this, I would say constantly, especially with tooling. I wouldn't consider the lessons learned using defunct tools to be lost either.

I'm not complaining about serialization formats, so why would I dedicate time to making it better?

Solution? I'm a quick learner so I'm not overly concerned. In a perfect world, you could just point me to your documentation.

Re:YAML: Probably not so great after all by geocar on Monday August 19, 2019 @02:44PM (#20740516)
Ok, I'll give it a shot.

Smalltalk environments don't typically have "configuration files" because it's so much easier to just directly manipulate the configuration parameter. Interactive development- the kind impossible with anything but the most specialised of IDE-- simply makes "config files" obsolete. Take a look at the seaside configuration guide[1] to get an idea what this is like.

In k/q[2] we also don't typically use configuration files, but for a different reason: Every type can be serialised over network or onto the disk, and when it's written to the disk it's usually in a format we can mmap() and access transparently. This is how q is also a database -- the data types q supports also includes tables.

k/q also has a built-in event loop that's not dissimilar to what you get when you run nodejs with the debugger port open except it's fast, and it's the regular way k/q processes communicate with each other.

What typically happens is that a table is designed for configuration, and we just expose it to the UI. Production environments are usually locked down so the only UI is to edit existing configuration parameters (and those are permissioned accordingly). These UI are typically quite general for any k/q data type, so they're quite rich and easy for people to use.

Then parts of the application interested in configuration just query the appropriate configuration table - this is only about 1000x faster than you would expect connecting to a remote database, and in many ways it's similar to a python application just storing its config in an sqlite database, except SQLite doesn't let you have a table as a data type so you can't put a table into another table, and you don't have tooling around comments and advice like you do with k/q UIs.

There are other places if you look carefully: Environments people have used (even beyond thirty years ago) that didn't have configuration "files", often had interesting and useful solutions to storing configuration. People tended to build configuration into part of their application, and so the legacy of that has tended to be excellent tooling instead of novel file formats.

[1]: http://www.shaffer-consulting.com/david/Seaside/Configuratio...

[2]: https://kx.com/

Re:YAML: Probably not so great after all by bastardoperator on Tuesday August 20, 2019 @04:41PM (#20751879)
You're trying to tell me a database or passing config options to your program are better than configuration files? What you're describing is the entire reason and purpose of why configuration files exist. YAML is also not limited to configuration files. If we look at the example you provided it's pretty clear:

"From the point of view of a component, the configuration can be thought of as a Dictionary-like collection"

This is exactly what YAML and JSON provide too. Using a configuration file is a choice, so are parameters, and so are databases. I'm not really understanding what you're trying to get at?

Re:YAML: Probably not so great after all by geocar on Wednesday August 21, 2019 @02:20AM (#20754938)
No. I'm saying when your application language is also your database or your operating environment [or for some other reasons], you don't need a configuration format.

The reason configuration file [formats] exist is because many programs are configurable and programmers are too lazy (or are not specified to, take your pick) to build a configuration tool [that has all their needs]. Configuration files are inferior in every way to an integrated and well-thought-out configuration process except that they may be easier to build and use in less ideal environments.

JSON is a fine format for interchange, and even persistence (i.e. to store configuration) but as a "configuration file" that people are expected to edit in their own way it is lacking, and that's why there are things like YAML and TOML and a million other things.

Re:YAML: Probably not so great after all by booleandilemma on Sunday August 18, 2019 @05:49PM (#20733143)
Giving meaning to whitespace causes so many headaches and yet people still embrace Python, for some reason. I don’t understand it.
Re:YAML: Probably not so great after all by whatshisface on Sunday August 18, 2019 @05:58PM (#20733193)
Your editor makes a world of difference here. Since you shouldn't be writing brace-language code without indents anyways, the biggest issue remaining is mixing tabs and spaces. Gedit makes this a big pain with it's default config (it doesn't even auto-indent) but Atom and IDLE handle it well.
Re:YAML: Probably not so great after all by userbinator on Sunday August 18, 2019 @06:18PM (#20733314)
Code you write yourself is not usually the source of problems with significant whitespace; it's situations like posting code on websites and discussing it where code in a whitespace-significant language becomes next-to-useless when leading whitespace is stripped, whereas code in any other language will still survive and then easily be autoformatted without changing its meaning.
Re:YAML: Probably not so great after all by icebraining on Sunday August 18, 2019 @08:27PM (#20733893)
If I were to use such a shitty website, I'd rather make a pastebin and link to it, instead of forcing every reader to reformat it themselves.
Re:YAML: Probably not so great after all by pshc on Sunday August 18, 2019 @07:46PM (#20733693)
Can’t remember the last time this has actually happened to me. In what websites are people posting code without code block formatting support? Like, instant messengers?
Re:YAML: Probably not so great after all by contradictioned on Monday August 19, 2019 @09:03AM (#20737333)
Funfact, even Facebook, Whatsapp, and Telegram support preformatted text in triple backticks.
Re:YAML: Probably not so great after all by vgetr on Sunday August 18, 2019 @06:34PM (#20733390)
I’ve heard this argument in a lot of contexts, and it has always struck me as saying, “if hitting yourself with this bat hurts, try wrapping this towel around it and maybe it will hurt less.”
Re:YAML: Probably not so great after all by kevin_thibedeau on Sunday August 18, 2019 @06:09PM (#20733249)
Python 3 rejects mixed whitespace so the problem will be caught quickly.
Re:YAML: Probably not so great after all by bobbylarrybobby on Monday August 19, 2019 @02:25AM (#20735371)
If I pinky promise to indent my code anyway, then why does it matter whether I also have braces or not? In fact, braces allow me to press one button in my editor and get the indentation absolutely perfect, without affecting semantics.

Braces also allow for easily copying and pasting blocks of code because the braces delimit the semantics of the copied text. Because your code is already indented, with white space indentation you have to check that a) you pasted the first line at the right indentation level b) every subsequent line is also at the right level relative to the first line. No small feat.

Re:YAML: Probably not so great after all by otabdeveloper4 on Monday August 19, 2019 @04:21AM (#20735909)
> If I pinky promise to indent my code anyway, then why does it matter whether I also have braces or not?

Without braces copy-pasting becomes a context-sensitive headache. That's poor usability.

Re:YAML: Probably not so great after all by codetrotter on Sunday August 18, 2019 @06:02PM (#20733211)
Admittedly I’ve been writing code in Python for many years now but, even from the start I never had a problem with the significance of whitespace.

Quite the opposite.

I like to format my code nicely anyways (or rather, mostly my editor does it for me because I’ve asked it to do so).

I indent with two spaces usually, regardless of language. And have my editors configured to insert two spaces when I press tab.

JavaScript, Rust, Python, C. Same difference, in terms of how I use whitespace.

Re:YAML: Probably not so great after all by ben509 on Sunday August 18, 2019 @07:33PM (#20733643)
The main headaches are due to people either wanting to copy and paste code from various sites, or wanting to write really deeply nested code.

If you're writing well structured, original code in Python, it's generally cleaner and easier than other languages because the syntax avoids ambiguities that other languages have.

Re:YAML: Probably not so great after all by DangitBobby on Sunday August 18, 2019 @09:08PM (#20734093)
The difference in my experience is that once you know what's wrong with your whitespaces in Python, you're out of the woods. The interpreter is your friend from that point onward. YAML parsers, on the other hand, give you these really strange errors that are pretty difficult to understand, and it doesn't end with whitespaces.
Re:YAML: Probably not so great after all by h1d on Sunday August 18, 2019 @11:13PM (#20734593)
There are quite a few comments saying they don't like python even from 10+ year users.

Language becomes popular largely through library ecosystem and resources around it, not just how the language looks. I think Google embracing it had a good role in acquiring mind shares.

https://news.ycombinator.com/item?id=20672051

Re:YAML: Probably not so great after all by h1d on Sunday August 18, 2019 @11:09PM (#20734584)
YAML is so bad for human writing. Everytime I write ansible tasks, I get confused with indentation and how to do arrays etc. JSON and YAML is frankly a generation behind compared to TOML or JSON5.
Re:YAML: Probably not so great after all by ljm on Sunday August 18, 2019 @03:04PM (#20732154)
I’m not keen on how so many tools and services opt for YAML by default, either. Both JSON and YAML are a nightmare to handle once you’ve got 3000 line files and several layers of nesting.

CI would be a lot nicer to use if it didn’t rely on a single YAML file to work. And if you want to switch, suddenly you had a build step to convert back to YAML.

Re:YAML: Probably not so great after all by js2 on Sunday August 18, 2019 @05:50PM (#20733154)
I keep my YAML CI files as minimal as possible by putting the logic into a Makefile and/or shell scripts and just have the YAML invoke that.