this post was submitted on 10 Feb 2024
630 points (100.0% liked)

196

17460 readers
664 users here now

Be sure to follow the rule before you head out.


Rule: You must post before you leave.



Other rules

Behavior rules:

Posting rules:

NSFW: NSFW content is permitted but it must be tagged and have content warnings. Anything that doesn't adhere to this will be removed. Content warnings should be added like: [penis], [explicit description of sex]. Non-sexualized breasts of any gender are not considered inappropriate and therefore do not need to be blurred/tagged.

If you have any questions, feel free to contact us on our matrix channel or email.

Other 196's:

founded 2 years ago
MODERATORS
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 1 points 1 year ago

All of these are bearable except for Haskell style. Wtf is that😭

[–] [email protected] 2 points 1 year ago

I want a language that takes this and has a specification for the editor to prettify it

while x==y
     func1
     func2
[–] [email protected] 2 points 1 year ago

This is the way

[–] [email protected] 18 points 1 year ago

Allman is objective the correct choice

[–] [email protected] 3 points 1 year ago

Allman is a benign neurosis

[–] [email protected] 19 points 1 year ago

Allman is the only other one that has some sanity.

[–] [email protected] 4 points 1 year ago (1 children)

On a serious note tho, I never understood the benefits of GNU's spaces after functions. I don't really mind most of the rest but I just don't get the benefits of 'funcname (arg)' vs. 'funcname(arg)'. Is there a specific reason for this? Personally, I find this to reduce readability because I have to think for a split second whether I'm looking at a variable or a function call.

Of cause this is also due to my habits, but I'm curious as to what the reasoning is.

[–] [email protected] 4 points 1 year ago (1 children)

Honestly I think it's just "spaces before open parens" and at least it's consistent. K&R, which I use, wants spaces before the parens in conditionals and loops but not in method sigs or method calls and the linter at work gets me almost every time I type the word "if".

[–] [email protected] 1 points 1 year ago

Fair enough if the GNU dudes valued consistent spacing more than taking function calls as one "logical block". Not my cup of tea but that's what configurable auto formatting is for.

[–] [email protected] 10 points 1 year ago (1 children)

If you have ADHD, your coding style is a combination of all of these, and sometimes none of the above.

[–] [email protected] 2 points 1 year ago

For real, this is why I enable format on save.

[–] [email protected] 5 points 1 year ago

The eternal holy wars rage on

[–] [email protected] 5 points 1 year ago

Allmans what I learnt then went to K&R on my own because it made more sense to me. I think GNU is fine I guess, not the others though. Not that what I say matters I've forgotten how to code and can barely do Hello World these days.

[–] [email protected] 5 points 1 year ago (1 children)

And who can forget this abomination

while (x == y) { func1(); func2(); }

[–] [email protected] 3 points 1 year ago

Aka the bash one-liner

[–] [email protected] 7 points 1 year ago (1 children)

Some of those made me physically ill.

Like. You do WHAT with your whitespace?!

[–] [email protected] 2 points 1 year ago

To be fair, some of these look very different in non-C-like languages (e.g. Lisp/Haskell).

[–] [email protected] 1 points 1 year ago

Crockford gang approves.

[–] [email protected] 23 points 1 year ago* (last edited 1 year ago)

Noone writes Haskell like that. People generate Haskell like that because layout syntax is a fickle beast to generate and outputting braces means you can make mistakes in layout without breaking things, the way the braces and semicolons are output emphasise how they actually don't matter, they're also easy to delete in a text editor.

Also it matches up with other Haskellisms, e.g. lists:

let foo = [ bar
          , baz
          , quux
          ]

See how it's immediately apparent that you didn't miss a single comma? It's also trivial to match up opening and closing brackets like that, even in deeply nested situations.

Not doing that is actually my main pet peeve with Rust's standard formatting.

[–] [email protected] 56 points 1 year ago (2 children)

Allman looks fine to me. But I'm a C# dev so maybe I'm just used to it.

[–] [email protected] 6 points 1 year ago

Allman changes the way I code. I avoid using imperative constructs so much more because they waste so much more space on my screen.

[–] [email protected] 23 points 1 year ago

It's not my favorite but it's fine.

[–] [email protected] 9 points 1 year ago (1 children)

oh so you hate Richard stallman?

[–] [email protected] 10 points 1 year ago
[–] [email protected] 46 points 1 year ago (1 children)

Allman works best if you like folding code blocks.

[–] [email protected] 4 points 1 year ago (1 children)
[–] [email protected] 3 points 1 year ago (1 children)

If you use if (blah) { then when you fold your code you still see the { but not the closing } (I suppose some IDEs might be smart enough to do something about this, but when not it looks like your code has an overbite).

And then you've got a mental disorder if you indent your opening and closing brace more than the statement spawning them.

[–] [email protected] 4 points 1 year ago

Yeah, I just don't see why IDEs couldn't make them all fold in the same way. It's trivial. I don't see it as a valid complaint.

load more comments
view more: next ›