7 ms·
Dunno, to me YAML is the python of markup languages. YAML is decent at handling things like nesting and arrays, while TOML sucks at it. I don't dislike YAML t
by torginus 3y ago
Dunno, to me YAML is the python of markup languages.
YAML is decent at handling things like nesting and arrays, while TOML sucks at it.
I don't dislike YAML that much.
That being said, we knew since the dawn of C macros that templating languages which are not aware of syntax, are AWFUL.
Likewise, writing Helm charts (the place I encountered YAML templating) is just horrible, but would be so much nicer is templates respected the YAML syntax tree and expanded at the right subnode, instead of being a text replace botch-jobs.
- wkat4242 3y agoThe biggest issue I have with Yaml is that they forbid tabs. Their argument is that tabs are shown differently in every editor which is actually something I like. When you're looking for something deeply nested you can reduce the tab distance a bit, when that's not needed you can increase it to improve visibility of nesting levels. And forbidding it makes a one-keystroke action a two or four one. I really don't understand the python/Yaml hate for tabs, and as a result I don't really use either.
- torginus 3y agoLike with Python, any competent text editor will take care of this for you, I've never encountered this issue before.
- tvink 3y agohttps://lists.gnu.org/archive/html/emacs-devel/2016-12/msg01000.html https://lists.gnu.org/archive/html/emacs-devel/2016-12/msg01...
- bayindirh 3y agoThis e-mail enters to my "favorite quotes from internet" list directly from the top.
- bqmjjx0kac 3y agoIt is a funny quip, but I wish they'd consider the reformatting. I find using an autoformatter reduces cognitive load while reading and writing.
- bayindirh 3y agoYeah, OP is not wrong. I also like neatly formatted code and is way easier to read. I always reformat all my code before all commits. It's just good hygiene. The funny part is the fussing and the answer they get. I'd just autoformat the area of my patch and send in the patch that way, maybe plus some autoformatted blocks here and there, slowly fixing the stuff as I go. If something is too bothersome, first try doing something, and figure out the rest of the process as you go. Edit: blocks became blogs without my knowledge. Maybe I should write a blog post about it. Don't know.
- bqmjjx0kac 3y agoReformat-on-change is also a valid strategy! I think I've even seen this employed on C++ codebases with clang-format. Conceptually, it's like `git diff | clang-format`, but there are more flags and scripts involved: https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting https://clang.llvm.org/docs/ClangFormat.html#script-for-patc...
- dhosek 3y agoUs old folks remember the days when reformatting was a computationally expensive action that required a special program to “pretty print” the code. And heaven forbid your code used some language feature your pretty printer didn’t understand and mangled the output making your code uncompilable.
- bayindirh 3y agoWell, I'm not that of a young folk. I was playing with computers (programming, in fact) in the early 90s, and I remember when it was expensive. However, Eclipse is formatting C++ code with a simple hotkey and without breaking it and understanding the language for the last 15 years as far as I can remember. It's instant, too. Because of that I feel a bit surprised when younger people look it like it's black magic. It's neither new, nor unsolved in my conscious experience.
- 2OEH8eoCRo0 3y agoThere's deep wisdom there.
- michaelmior 3y ago> And forbidding it makes a one-keystroke action a two or four one. The majority of editors can be configured to use tab to insert the appropriate number of spaces. Many will automatically detect the correct configuration.
- moffkalast 3y agoThe majority isn't all, and in my experience you always end up having to use one in some random situation that doesn't have that. tap tap tap tap Literally 100% of editors support tabs.
- Defletter 3y agoThe horror
- moffkalast 3y agoThe attempt on my life has left me scarred and deformed.
- lolinder 3y agoWhich editor have you run into that doesn't? Even nano supports configuring it with both nanorc or a command line flag.
- layer8 3y agoHTML textareas don’t support entering tabs. There are rich-text editors that increase the margin on Tab rather than inserting a tab.
- Redoubts 3y ago> And forbidding it makes a one-keystroke action a two or four one. You can’t be serious
- jampekka 3y agoNot everyone wants a bloated and buggy IDE to write their code for them.
- geerlingguy 3y agoAlmost every text editor has support for tabs-as-spaces. I haven't used an IDE in years.
- wkat4242 3y agoI don't want that though. Because then when editing I still have to mess around with spaces. And the double nature of the spaces makes it hard to see when you have an odd number of spaces when you reach deep indenting levels, which counts as the lesser number of double spaces in Python. IMO it would be ideal if tabs would be displayed as a block, and you could resize the width of that block on the fly <3
- lkirkwood 3y agoLike vim, for example? Which supports replacing tab inputs with spaces...
- jampekka 3y agoI code practically exclusively with vim. The replacement is buggy and has many corner cases that come up constantly. As in all editors. Tab indentation has no bugs or corner cases.
- Two9A 3y agoAnd I've been using vim exclusively for north of fifteen years with Tab replacement, never had a problem with the editor getting confused about what happens with spaces when I hit Tab. Some detail about the corner cases you've run into would be great, if they're happening constantly I can see how it would be a bugbear.
- andybak 3y agoTabs aren't a problem Spaces aren't a problem. What is a problem is not picking one or the other. There's arguments for both sides but it is critical to just take a side. I'm sorry your side lost but it makes everything better to just go along with the consensus.
- fatnoah 3y agoAt one of my internships in the 90's, a developer I worked with solved the problem by never indenting. Every single line of code started at column 1.
- swader999 3y agoWhy even use more than one line?
- solardev 3y agoWhy not just make everything whitespace? Give both tabs and spaces their rightful place! https://en.wikipedia.org/wiki/Whitespace_%28programming_language%29?wprov=sfla1 https://en.wikipedia.org/wiki/Whitespace_%28programming_lang...
- throwaway_08932 3y agoSounds like you were an indent-ured labourer.
- alemanek 3y agoIt sounds like this is the origin story of Python. Whoever worked with this person made it their life’s mission to enforce proper indentation.
- otteromkram 3y agoWhy did you leave an empty column at the start? :]
- wkat4242 3y agoTrue, that's how real coders work! 10 IF A=1 OR Z=2 GOTO 30 20 GOTO 50 30 PRINT "HELLO WORLD" 40 GOTO 10 50 GOTO 30
- inportb 3y agoI agree with you about YAML's treatment of tabs. I still use YAML because there's often no other choice. Python is actually flexible in its acceptance of both spaces and tabs for indentation. Maybe you were thinking of Nim or Zig? Nim apparently supports an unsightly "magic" line for this (`#? replace(sub = "\t", by = " ")`), and Zig now appears to tolerate tabs as long as you don't use `zig fmt`. I haven't used either yet because of the prejudice against tabs, but Zig is starting to look more palatable.
- wkat4242 3y ago> I agree with you about YAML's treatment of tabs. I still use YAML because there's often no other choice. True, I'm using it too when I have no other choice. > Python is actually flexible in its acceptance of both spaces and tabs for indentation. True but it does give constant warnings then which is annoying. And I was worried about it dropping support in the future so I didn't want to waste time learning it.
- da39a3ee 3y agoYour problem, and I mean this sincerely and respectfully, is that you're not using your text editor / IDE correctly. Adding two or four spaces of indentation is done by pressing TAB! Once. Most editors will do know how to do this out of the box, but if yours doesn't you need to change it.
- wkat4242 3y agoYou still have to mess around with a bunch of spaces when you're editing or copy/pasting, and not having exact even numbers makes for ambiguous situations. Especially if something is 5 levels deep, it's really hard to see if you have 12 or 11 spaces (so 5 levels + 1 space or 6 levels) indentation.
- kadoban 3y agoThis is not true in a correctly configured editor.
- wkat4242 3y agoHow so?
- kadoban 3y agoMy editor, I press tab once and it inserts the correct number of spaces (on a new line it also starts at the previous indentation level as appropriate). I press backspace once and it deletes the correct number of spaces. Any editor used for programming needs to be capable of this.
- kadoban 3y ago> And forbidding it makes a one-keystroke action a two or four one. This isn't a tabs or spaces issue. This is a "your editor is bad or configured wrong" issue.
- mejutoco 3y agoEvery editor I know can enter n spaces when pressing tab. That might solve your concern.
- wkat4242 3y agoIt does not. You still have to mess around with a bunch of spaces when you're editing or copy/pasting, and not having exact even numbers makes for ambiguous situations.
- mejutoco 3y agoI use tab and shift tab on intellij and vim on insert mode. Outside of insert mode I use "<<" and ">>". I am on vim mode on intellij too. What editor are you using?
- pclmulqdq 3y agoI'm pretty sure most of the "spaces" people have their editor set up to convert the 'tab' key into multiple spaces. Now excuse me while I duck under this table.
- weebull 3y agoYou're safe because you're right.
- pdonis 3y ago> forbidding it makes a one-keystroke action a two or four one. Not if your editor can be configured to interpret a Tab keypress as the appropriate number of spaces. AFAIK all common text editors, at least in the Unix world, do this.
- wkat4242 3y agoI don't want that though, because then I still have to mess around with spaces when editing. I actually like tabs for indenting levels especially because I can configure how far they indent on the fly.
- AlecSchueler 3y agoMy editor can also change the width of blocks of spaces on the fly, as well as navigating them in arbitray chunks.
- pdonis 3y ago*> I still have to mess around with spaces when editing. Not if your editor automatically indents and dedents with spaces. I find that to work just fine when editing Python code, for example. Tab is interpreted as "indent" and Backspace if you're at an indent stop is interpreted as "dedent".
- mort96 3y agoTOML has the inline table syntax with curlies, like JSON, and inline array syntax with brackets, also like JSON. It could support nesting pretty well. Sadly, it doesn't support line breaks in the inline table syntax, so using inline tables for nesting is a PITA; inline tables are pretty much unusable for anything which doesn't fit within like 80-100 characters. Inline arrays can contain newlines however, so deeply nested arrays works well. Newlines in inline tables will be coming in TOML 1.1, which will make TOML much better for deeply nested structures. Unfortunately, there will probably be many years until 1.1 is both actually released and well supported across the ecosystem. And of course, inline tables can't be at the top level of the document, so TOML might still not be the best way to represent a single deelpy nested structure.
- fkyoureadthedoc 3y agoAnd then the second layer of hell, a DSL inside the YAML for something like an Azure DevOps pipeline. Truly awful.
- lolinder 3y agoMy personal favorite was when my company switched to configuring Jenkins in YAML, with some of the config being in YAML proper and other config being in Groovy embedded inside of multiline strings. Since it's Jenkins, the Groovy itself embeds multiline strings for scripts that need to run, so the languages end up nested three levels deep! The only thing that saves me is IntelliJ's inject-language-in-string feature.
- vidarh 3y agoThe worst thing with Helm charts is not the YAML, or even the text replace botch-jobs, but that they seem to think that a Go stacktrace is reasonable error reporting. I don't think I've ever worked with a tool with such awfully useless error messages. But I agree, it'd be better if the template expansion was actually structural and not just text. The huge amount of "| indent 8" etc. in Helm charts is such a stench that by about the second time people encountered that they ought to have made a better template expansion mechanism top priority.
- sethammons 3y agoYou have an error on line one. Good luck
- amath 3y agoAh, this had me laughing.
- fatherzine 3y agoUnlikely it will ever get better. First to market with a prototype tool, gains market share and momentum. Eventually the enthusiasm fades off and people start hating it, for good and sometimes bad reasons. Yet users are stuck because change is expensive and risky. The team is stuck because any change risks becoming the straw that broke the camel's back, possibly cascading through the user population. Story of our young industry.
- vidarh 3y agoI think you're part right in that I don't think they will make any backwards incompatible changes. But they could still make things a lot better in two simple ways: * Fix error reporting. Nobody is doing anything that relies on the current error reporting anyway because it's near useless. * Add a slight templating change that means "after this parses as valid YAML, expand this bit, and check that the expansion is itself valid YAML before merging it in" with options to either replace the node, or merge in adjacent (the latter to insert in lists etc). You can do that without backwards incompatible changes by making a syntax change that still uses the go {{ ... }} blocks, but that starts with a directive they can make simply expand to a new template processing directive in the first pass. Then just add a second pass that operates on a parse tree (I've just written a template expansion mechanism that works on json/yaml parse trees, in fact; if we didn't need Helm charts primarily for distribution to partners that I don't want to make use a custom deployment tool, I'd be tempted to replace our Helm charts with an expansion of that. Better error reporting and being able to avoid the incessant "| indent .." blocks and ensuring the output either generates valid yaml or can "contain" the error report to the generated sub-block would make it so much easier to use.
- _ea1k 3y agoYeah, that's why I prefer ytt over helm syntax. It isn't great syntax, but at least it is aware of what it is doing. Having said that, yaml has some pretty obvious mistakes. It should have been a lot more prescriptive about data types. Not doing that creates a lot of unneeded confusion and weird bugs.