7 ms·
> 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 ti
by 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.
- marcosdumay 8y agoEditing JSON is ok without specific format support, it just looks like any other C-like language. Editing YAML is basically impossible without specific support, your editor will almost certainly break any file you open and destroy relevant information on the process.
- kakarot 8y agoCare to elaborate? Your statement is hollow on its own. How does your editor destroy information? What kind of information is destroyed? Why is your editor rearranging bits in validly encoded text files?
- marcosdumay 8y agoMost programming editors rearrange the white space of the files they open. Some do it more, some do it less. Rearranging white space in a YAML file often destroys information.
- kakarot 8y agoMine do no such thing. The only whitespace that gets stripped in /any/ editors I have are trailing whitespace and extra whitespace before the EOF, and that's only in certain IDEs where I have consciously enabled these options. They are disabled by default. Removing trailing whitespace should never change the logic of a file in general, but as for YAML it certainly doesn't. And editors should never remove leading whitespace... who does that? Can you name an offending editor as an example?
- marcosdumay 8y agoPress tab on a line in emacs, and the whitespace will get rearranged. It's more explicit in vi, but don't bother (un)indenting blocks there either. Just writing characters anywhere a file on the MS IDEs I've tried is enough to rearrange the line's whitespace, while the Jetbrain's I've tried are more conservative and won't break lines you haven't changed somehow.
- fnordsensei 8y agoHave a look at the CodeDeploy appspec.yml specification for whitespace [1]. … [4]mode:[1]mode-specification [4]acls: [6]-[1]acls-specification [4]context: [6]user:[1]user-specification … "AWS CodeDeploy will raise an error that might be difficult to debug if the locations and number of spaces in an AppSpec file are not correct." Great. There couldn't possibly be an easier format to use, could there? [1]: https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file.html#reference-appspec-file-spacing https://docs.aws.amazon.com/codedeploy/latest/userguide/refe...
- laumars 8y agoIn fairness, that documentation makes the process out to be far more complicated than it actually is in reality. Plus their point about errors being difficult to debug can be equally true with other data formats too (eg some JSON parses can throw really unhelpful errors if you accidentally include a comma at the end of list)
- pjc50 8y agoThree big things that annoy me even though I'm happily writing Python: - "cut and paste and edit" is broken. You can't autoformat the pasted code into the right place, you have to go back and fix the whitespace. Since whitespace is semantically significant, this can introduce bugs. - visually identical whitespace may not be textually identical whitespace. Unless you go around breaking the tab key off your colleague's keyboards you'll trip over this. Especially (again) if you paste. Occasionally seen in merges too. - editors can no longer give you 100% correct indentation.
- giancarlostoro 8y ago> - "cut and paste and edit" is broken. You can't autoformat the pasted code into the right place, you have to go back and fix the whitespace. Since whitespace is semantically significant, this can introduce bugs. Depends on how your editor is configured / it's feature set. Which makes me wonder how editorconfig would handle this when enabled. It seems like a insignificant issue to me, you can auto-PEP8 the code before pasting it. You should probably be following PEP8 anyway (as far as spacing is concerned at least). > - visually identical whitespace may not be textually identical whitespace. Unless you go around breaking the tab key off your colleague's keyboards you'll trip over this. Especially (again) if you paste. Occasionally seen in merges too. I turn on show all whitespace on my editors regardless of programming language. I've been burned by Sublime Text not just figuring out the already defined whitespace ruleset for a file by what it's using and just shoving in it's own defaults. I wish all editors would base whitespace on what the file's structure looks like, if there's mixed spaces, give me a warning. > - editors can no longer give you 100% correct indentation. I don't understand this, it sounds like you've got your editor configured poorly or something? But it goes back to how unintuitive the nice editors can be. You can use editorconfig to define the indentation project wide, then any editor should pick it up, of course if you define PEP8 at a minimum it guarantees spacing settings. I'm not sure if PyCharm covers a few of those cases, since I use it so seamlessly I don't usually have complaints.
- scarface74 8y agoI’m on the opposite end. I just had to export a JSON based AWS CodePipeline configuration and had a hell of a time trying to edit it and paste things in the right place. I ended up converting it to yaml, making the edits and converting it back to JSON. Before anyone asks the obvious, how do I handle deeply nested code in brackets. Simple, I don’t. When things start getting nested deeply, I use my IDE to Extract Method.
- SignsOfABeast 8y agoYAML is a generic format which leaves formatting as a result of effect to you. Ansible puts rules on top of it, which makes intendation not always trivial, it is easy to have an dangling key value pair which doesn't cause an error, but has only an effect with the right intendation.
- AnthonBerg 8y agoPlease consider simply believing and trusting those who tell you they hate significant whitespace and that it is a real impediment to work. Another take, perhaps: Assigning deep semantic significance to invisible symbols is simply stupid. It is stupid to a much greater degree than wanting to be free from having to care about the amount of invisible symbols is “sloppy”.
- arh68 8y agoI largely agree with you, but: How hard is it to use HN formatting? I can’t count how many times people screw it up. It’s not difficult to begin with, the documentation is free, yet here I am reading your comment with broken formatting. something: nothing hello: goodbye Anyone who has trouble with this is just being sloppy. No useless backticks! You might think you’re doing it right, but unless you check, maybe you’re not.
- ravenstine 8y agolol Well played.