Post ATWh0XFCxLLEwcyprU by codesections@fosstodon.org
 (DIR) More posts by codesections@fosstodon.org
 (DIR) Post #ATVmKwZEovrht3wLOS by codesections@fosstodon.org
       2023-03-11T15:06:50Z
       
       0 likes, 0 repeats
       
       I have a new appreciation for the holy wars waged over code formatting and tabs-vs-spaces.  That's because I've been hacking on @masukomi's Hey (https://github.com/masukomi/hey_3), which is a (quite nifty!) time-tracking CLI app. But it uses tabs and snake_case when the normal #rakulang practice is spaces and kebab-case.I mean, #timtowtdi and there's nothing _wrong_ with those choices.  And of course I followed those conventions in my PRs – anything is better than chaos.But, man, my eyes, my eyes!
       
 (DIR) Post #ATVmL1fnpx5Tis39ou by martijn@ieji.de
       2023-03-11T15:27:14Z
       
       0 likes, 0 repeats
       
       @codesectionsI don't understand the holy war, the tab character is the only one you can adjust to how you like it rendered, so it's the only possible answer. You like two space indentation, let your editor render the tab two space width.
       
 (DIR) Post #ATVmL3ulVIFCfr48Q4 by cnx@larkspur.one
       2023-03-11T16:31:19.394072Z
       
       0 likes, 0 repeats
       
       It can be more complicated than that, @martijn, since the style war doesn’t stop at indentation, but also code width.  While highlighting, say, lines longer than 80 columns for the de facto standard tab width of 8 is technically simple, it’s as difficult as mixing tabs for indentation, spaces for alignment or getting rid of trailing whitespaces in so-called modern editors/IDE in practice.  I guess this is why most projects ended up simplifying this by setting a concrete convention, whether it is tabs or spaces.  Cc: @codesections
       
 (DIR) Post #ATWh0R06Abgra1rgTg by codesections@fosstodon.org
       2023-03-11T15:46:08Z
       
       0 likes, 0 repeats
       
       @martijn > I don't understand the holy war … You like two space indentation, let your editor render the tab two space width.Yeah, in fairness a big part of the frustration was from the fact that I have my editor configured to prefer spaces (e.g., pressing tab indents with spaces) and I didn't bother futzing with it for a one-off PR.… so instead I spent that time double-checking that I'd indented correctly.  In retrospect, maybe I should have changed the settings!
       
 (DIR) Post #ATWh0RYU6lCDIfx94i by wizzwizz4@fosstodon.org
       2023-03-11T17:07:34Z
       
       0 likes, 0 repeats
       
       @codesections @martijn I would have done that, too. But if you're not reconfiguring your IDE, just do whatever and then run an autoformatter afterwards – assuming the autoformatter is clever enough to understand tabs for indentation / spaces for alignment.
       
 (DIR) Post #ATWh0S6A5Y8Oz7i2ZE by codesections@fosstodon.org
       2023-03-11T18:26:33Z
       
       1 likes, 0 repeats
       
       @wizzwizz4 @martijn > just do whatever and then run an autoformatter afterwardsBut if the project doesn't already use an autoformatter, running one is a good way to turn a 5-line PR into a 100-line one.(and, as a practical matter, there's the fact that afaik there isn't a widely accepted autoformatter for #rakulang) But, more broadly, I'm actually pretty anti-autoformatter (at least for expressive languages).  And I'll tell you why in a reply to this toot.
       
 (DIR) Post #ATWh0TjtzHW84fJI9I by codesections@fosstodon.org
       2023-03-11T18:35:22Z
       
       0 likes, 0 repeats
       
       I'm not a huge fan of code formatters for two main reasons.First, they make code less expressive – when you format code, you emphasize certain elements and de-emphasize others (e.g., line breaks before method calls gives more prominence that a 1-line expression) .This helps the reader focus on the important elements and – maybe more importantly – it communicates which elements *you* view as important. When code is formatted automatically, you lose an important communication channel.1/2?
       
 (DIR) Post #ATWh0VWVM3zNbh3cXo by codesections@fosstodon.org
       2023-03-11T18:45:19Z
       
       0 likes, 0 repeats
       
       The second reason I don't love code formatters is that, ime, any rules that avoid unreadably cluttered code in edge cases always make average code take up more vertical space.That, in turn, means you get less code per screen. So coding involves way more context-switching.  Maybe my short-term memory just sucks, but imo "having code fit in one screen" is a hugely underrated superpower.(In fact, I believe in single-page code so much that I wrote a package devoted to it https://github.com/codesections/_)
       
 (DIR) Post #ATWh0XFCxLLEwcyprU by codesections@fosstodon.org
       2023-03-11T18:51:15Z
       
       0 likes, 0 repeats
       
       3/3That said, I don't *hate* code formatters.  They have their place, especially for large teams – even if the code is less communicative and longer, that still beats arguing about formatting.And I recognize the value in having a single, community-wide style; even though I don't love its decisions, I use rustfmt when writing #rustlang But I'm personally really glad that #rakulang *doesn't* have a generally-accepted formatter.  IME, it's part of what keeps Raku code concise and expressive