11 ms·
I know I'm in a minority, but I really dislike YAML... I recently did a lot of Ansible and boy, at the beginning, I was just struggling a lot. Syntactic whitesp
by BossingAround 8y ago
I know I'm in a minority, but I really dislike YAML... I recently did a lot of Ansible and boy, at the beginning, I was just struggling a lot. Syntactic whitespace kills me.
I don't like it in Python either, but for some reason, when I write Python, it's a lot easier. Maybe YAML is just a bit more complex (and Python has better IDE support..?)
- nerdponx 8y agoThe simple parts of YAML are great for simple applications. The complicated parts of YAML are not great for complicated applications.
- bluedino 8y ago>> I really dislike YAML I wasn’t aware anyone liked it
- SamWhited 8y agoTools keep using it even where it's the wrong tool for the job, so someone must like it, surely? I'm sure it will be just like XML where it's the trendy thing for a while in the early days, then everyone stops and hates it for a while. Except XML at least has a handful of applications where it's the right tool for the job (it has a nice streaming mode), YAML doesn't even have that.
- hazz99 8y agoYAML is great for simple human-editable configuration files. Its very easy to write, and can be picked up quite quickly. Opting for YAML over XML/JSON/whatever doesn't make me a tool. It made life much easier for myself & my colleagues.
- kjeetgill 8y agoI think they meant tools like docker or npm and stuff. Not calling people tools.
- SamWhited 8y agoheh, I didn't even consider this interpretation of the above; sorry about that. I meant "tools like Docker keep using it", not people. But I still don't know what you're talking about; YAML has an 83 page spec that includes pointers, and uses tons of random confusing symbols. I say "maybe it's just me" in some of these posts, but I know it's not: I've watched many of my coworkers get it wrong the first time for years and then have to be corrected. A quick common example I see in CI config all the time: If I write version: 1.10, that's a number, then I decide to move to latest so I write version: 1.10.x, that's a string. Oops, we were never using version "1.10" we were using "1.1". Everything about it is implicit and bad. Now, it's easy to say "always use quoted strings", and I agree, but then why the hell does it have bare strings in the first place? That seems like an easy enough oversight or typo to make, and it will be made.
- h1d 8y agoI have a feeling that it is/was preferred in rails/ruby community.
- illumin8 8y agoI generally dislike languages like YAML or Python where whitespace matters, and can break your code, however, YAML is way more easily human readable than JSON, so I started to appreciate it for readability purposes. I guess YMMV, but after you've used both YAML and JSON for a while, you might appreciate YAML a little bit more.
- chriswarbo 8y ago> YAML is way more easily human readable than JSON, so I started to appreciate it for readability purposes. > I guess YMMV, but after you've used both YAML and JSON for a while, you might appreciate YAML a little bit more. I've used JSON a lot, and XML and s-expressions and MessagePack and ini and YAML and a whole bunch of other formats. I usually have to fire up Google to read YAML. YAML is the only one where I routinely have to Google for a syntax cheatsheet and wade through tables of redundancy and edge-cases. YAML made sense before JSON became a thing. Why people persist with it in new projects is baffling to me.
- ekianjo 8y agoa raw YAML file is readable with your eyes. A Json file needs to be prettified before you go thru it. Json is good for APIs but is not made for readibility.
- chriswarbo 8y agoWe must disagree with what "readable" means then. I find JSON readable (as long as it's nicely layed out, e.g. by piping through 'jq "."'), in the sense that I can skim over the structure looking for [/]/{/}/". If I want to read some of the content, like a string, I just need to read '\"' as '"' and '\\' as '\', which is a small constant cost per (usually rare) occurrence. With YAML it's difficult to even know the structure of what I'm looking at, due to anchors and extensions. It's also hard to discern structure from skimming, since strings can appear unquoted, and may contain unescaped lexical tokens (depending on which particular symbols it started with); hence we must carefully consider each and every character, rather than just skimming for the next token. If I know I'm looking at a perfect YAML file, than I should be able to guess the gist of what it says, since I can make assumptions about what the syntax means. If I want to be sure, I'd be Googling for cheatsheets. Yet as a programmer, I mostly look at files when they're buggy, meaning I can't just assume that, say, an unescaped quotation mark won't terminate the string; or that a certain piece of text is allowed to run across multiple lines; or that the indentation corresponds to the nesting; etc.
- atombender 8y agoYAML is a bit bonkers in that it's a superset of JSON (all valid JSON is valid YAML), so if you don't like the whitespace sensitivity, you can write your YAML like this: { a: 42, # But you can have comments! b: "hello world", c: "and multi-line strings!", # and trailing commas! }
- tomrod 8y agoOh hey, a Python dictionary that throws an error. Just kidding -- faced a JSON parsing issue today and this made me smile. It's a step up from XML though.
- pjmlp 8y agoFor me lack of validation and comments are many steps down, not up.
- zamadatix 8y agoLack of validation?
- pjmlp 8y agoJSON files don't have validation support like XML schema does.
- mdaniel 8y agoMaybe not built in like DTD, closer to XML Schema in its laid-on-top manner, but I would argue that JSON Schema is fairly good, and on its way to becoming an IETF standard: http://json-schema.org/ http://json-schema.org/ and https://tools.ietf.org/html/draft-handrews-json-schema-01 https://tools.ietf.org/html/draft-handrews-json-schema-01 (et al) The lack of obvious namespace management is suboptimal, but so far I thankfully haven't encountered a situation where it was a show-stopper. IntelliJ and related tools also allow associating a json schema with a YAML file, which I have found infinitely handy
- ilovetux 8y agoI find YAML to be almost unusable. IMO it's just not intuitive. If I get to choose a format for my config files I would only use TOML, it's just better (again IMO).
- h1d 8y agoAgreed. From readability perspective, I started out with INI, which I ditched partially due to having no standard on the format and skipped JSON when it can't add comments, skipped YAML for not looking too intuitive, considered JSON5 but skipped for being not popular enough and landed on TOML.
- skywhopper 8y agoAll these comments amuse me, because I feel the opposite. YAML has always made immediate intuitive sense to me. Meanwhile TOML feels like a terrible hack. Also, I'm guessing I'm in a tiny minority who loves YAML but hates Python's semantic indentation...
- harshreality 8y agoI'm the same way. I think it's a difference in my expectations of a programming language versus a hierarchical data storage format. I'm fine with (and even prefer) enforced whitespace in data formats. That makes it easier to view and edit. In programming languages, it makes me twitch. I don't have any problem with "accepted" formatting styles (i.e. linux kernel c style), but for the language itself to enforce that for some reason feels like it's adding perpetual cognitive overhead (like whenever I use python). I don't know why; it shouldn't be any different than using a particular formatting style voluntarily in a more flexible language, but somehow, it feels different.
- jrockway 8y agoI don't mind YAML. I dislike that something things become strings and sometimes they become other types: foo: bar # {"foo":"bar"} foo: "bar" # {"foo":"bar"} foo: 42 # {"foo":42} foo: "42" # {"foo":"42"} Other than that, no major complaints. My editor understands YAML and shows the indentation level in the background (highlight-indentation-mode) and auto-formats files so they all have consistent indentation (prettier-mode). As a result, it is not much of a nightmare to edit, despite the fact that semantic whitespace COULD cause you a lot of problems.
- aldanor 8y agoHow about... foo: yes # "foo": true bar: YEs # "bar": "YEs" baz: YES # "baz": true
- jrockway 8y agoYeah, that's a little crazy. It's the classic case of in-band signalling. It never works. I wish quotes around strings were mandatory, then having 83 ways to say "true" would be OK. But when strings randomly get upgraded to other primitive types... it's a little weird.
- bpicolo 8y agoWriting YAML is easily the part I hate most about writing/deploying software. It's unstructured, feedback cycles tend to be slow (e.g. when deploying k8s configs into prod), and you can't possibly write something useful without documentation pulled up. It's definitely easier to implement than purpose built DSLs, but it's not a good experience.
- ravenstine 8y ago> Syntactic whitespace kills me. Okay, I'm gonna be the asshole in the room, but how hard is it to just use consistent indentation? I can't count how many times I've heard people complain about significant whitespace in languages. Not only is it not difficult to begin with, but every code editor and IDE will show you where there's a syntax error in your YAML. People are free to dislike YAML, even for its significant whitespace, but how does it "kill you"? Look at this example from the article: ``` something: nothing hello: goodbye ``` This is pure sloppiness, and anyone who has trouble carelessly adding pointless bytes to code, no matter the language, is sloppy. I don't understand why people criticize YAML and Python because "whitespace is hard". P.S.: There's a similar configuration language called ArchieML, which is similar to YAML but doesn't have significant whitespace. http://archieml.org http://archieml.org
- saagarjha 8y ago> how hard is it to just use consistent indentation It's pretty annoying when you don't have access to an IDE or decent editor.
- fulafel 8y agoIn the YAML case: It's hard if you don't have editor support and good diagnostics. Not because you're unusually sloppy, but because you make human mistakes and because you don't know the syntax. (YAML syntax is surprisingly complex and poorly documented in the pedagogic sense). Also, the edit-debug cycle is slow with Ansible or YAML-using CI systems, so this is doubly painful. In the Python case it's much better, because people less often casually edit .py files without editor support, and because Python has good diagnostics and it's much much harder to produce syntactically correct but semantically wrong Python by whitespace mixups.
- kakarot 8y agoEverything is hard when you don't have editor support and good diagnostics. Don't blame YAML because you prefer to use Notepad.exe However, missing/extra whitespace is not "hard". You would be docked points in an English paper and you should be docked points as a programmer. So, whitespace aside... Tell me what is easier to edit without built-in syntax support: JSON, or YAML? If we define "easy" as "how long it takes to complete a task" or "how quickly you can grok the structure of a given block of code", then YAML beats out JSON every time.
- andrewflnr 8y agoI know you only said Python is better, not great, but you might want to check out OpsMop: https://medium.com/@michaeldehaan/opsmop-building-the-next-generation-of-configuration-management-tooling-11268b7f21b6 https://medium.com/@michaeldehaan/opsmop-building-the-next-g... . By the creator of Ansible, in pure Python, including the config.
- dmix 8y agoIs there a reason http://opsmop.io/ http://opsmop.io/ and http://vespene.io/ http://vespene.io/ are both down and their Github's both say "DISCONTINUED"? https://github.com/opsmop/opsmop https://github.com/opsmop/opsmop https://github.com/vespene-io/vespene https://github.com/vespene-io/vespene
- andrewflnr 8y agoI... No. The OpsMop Twitter has a tweet from January 31, so it seems like if the project had died it would have to be really recent. That would be sad.
- jaxxstorm 8y agoMichael DeHaan threw his toys out of the pram because he wasn’t getting the user numbers he wanted and discontinued them
- geerlingguy 8y agoLooks like it happened a few days ago: https://threadreaderapp.com/thread/1091710068234641408.html https://threadreaderapp.com/thread/1091710068234641408.html
- dmix 8y ago> In this case, lots of discussions show everyone is busy, has no time, and also ... increasingly they have interest in low-code/no-code type solutions. This is not open source as whole, just the IT ops vertical Looks like he doesn’t believe the code approach is viable as much as other people are claiming in this thread.
- Slippery_John 8y agoI like looking at YAML when it doesn't use any of the insane YAML features. Even so I'm not convinced it should be used (at least not as widely as it is) for one big reason: it can be truncated almost anywhere and still be valid. This causes way more issues than you might think. JSON has no such issue - the only case I can think of where you can truncate JSON into valid JSON is if your JSON is just a number.
- gcb0 8y agoYAML is useless because it replaces JSON (tree structure that is minimally verbose to not be confusing) with something worse (a tree structure that is just less verbose than JSON to be slightly confusing)
- marcosdumay 8y agoPython has better IDE support and, maybe more importantly, python does not completely disallow any indentation style so it handles unsupported IDEs better. But it's essentially an IDE support problem. My life improved a lot since I got an YAML mode for emacs. Now things would be just perfect if haskell's cabal migrated to dhall...