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

196

18159 readers
268 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
[–] Ashiette@lemmy.world 87 points 2 years ago (1 children)

Allman is very practical for JSON

[–] brianary@startrek.website 63 points 2 years ago (2 children)
[–] Zugyuk@lemmy.world 18 points 2 years ago

Always Allman. Those others give you cancer

[–] deadbeef79000@lemmy.nz 17 points 2 years ago

Allman all the way.

[–] Solrac@lemmy.world 67 points 2 years ago (5 children)

Finally, someone understands that Allman is not that great, and that Kernighan & Ritchie is the way to go. Also, Haskell, my guy, you good? Lisp, are you ok? Do I need to call your parents?

[–] v_krishna@lemmy.ml 32 points 2 years ago

Do I need to call your parens*

[–] MechanicalJester@lemm.ee 30 points 2 years ago

Allman all the way baybeeee

[–] Phoenix3875@lemmy.world 5 points 2 years ago

Meh, it's what you get when you write a language in a different language's "style".

load more comments (2 replies)
[–] Gork@lemm.ee 59 points 2 years ago (1 children)

All of those are heretical. The one True Language is Brainfuck, where the coding syntax for Hello World is

++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.

load more comments (1 replies)
[–] blindsight@beehaw.org 53 points 2 years ago* (last edited 2 years ago) (3 children)

idk, Allman is very readable. Easy to scan vertically to find the matching open brace. Not quite as vertically-space efficient as the best way, but it's not offensive.

[–] I_am_10_squirrels@beehaw.org 32 points 2 years ago

Plus one for Allman gang

[–] hardware26@discuss.tchncs.de 8 points 2 years ago

In my first ever programming class textbook was using Allman. Probably for this reason, it is easy for a beginner to match braces. It is a lot loss common industry to my knowledge.

[–] rubythulhu@lemmy.blahaj.zone 6 points 2 years ago (1 children)

this is only true if you don’t indent properly

[–] blindsight@beehaw.org 6 points 2 years ago (1 children)

I literally don't understand. I've read your comment several times and I don't know what you're talking about. Sorry!

Did you think I was saying that made Allman better than the best way? Because it's easy to scan vertically the best way, too. It's just also easy with Allman, so it's not offensive.

I don't think they were disagreeing with you, I think they were just trying to say:

You shouldn't need braces to be vertically aligned if your code is uniformly indented. Then you can easily see what code is paired together just by their indentation level.

Of course this is not always true if you've got a bunch of crazy nested indentation pushing things off to the right.

[–] blackn1ght@feddit.uk 50 points 2 years ago (2 children)

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

[–] nik9000@programming.dev 20 points 2 years ago

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

[–] redempt@lemmy.world 6 points 2 years 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.

[–] psycho_driver@lemmy.world 42 points 2 years ago (3 children)

Allman works best if you like folding code blocks.

load more comments (3 replies)
[–] LazaroFilm@lemmy.world 33 points 2 years ago (1 children)

No line breaks. Just one long line of code.

[–] kryptonianCodeMonkey@lemmy.world 31 points 2 years ago* (last edited 2 years ago) (3 children)

All line breaks. Just one tower of code.

class
HelloWorld
{
public
static
void
main(String[]
args)
{
System.out.println("Hello,
World!");
}
}
[–] eupraxia@lemmy.blahaj.zone 14 points 2 years ago* (last edited 2 years ago)

as always, c++ lets us do better in breathtakingly elegant fashion:

#\
i\
n\
c\
l\
u\
d\
e\
 \ 
&lt;\
i\
o\
s\
t\
r\
e\
a\
m\
>

finishing out hello world is left as an exercise to the reader, but the advantages and superior performance of this format should be obvious

[–] Oszilloraptor@feddit.de 7 points 2 years ago* (last edited 2 years ago)

why not

...

System
.out
.println(
"Hello,

...

?

load more comments (1 replies)
[–] Aedis@lemmy.world 28 points 2 years ago

Tell me you're a Java developer without telling me you're a Java developer.

[–] ImplyingImplications@lemmy.ca 24 points 2 years ago (1 children)

Haskell, baby, what is you doing??

load more comments (1 replies)
[–] barsoap@lemm.ee 21 points 2 years ago* (last edited 2 years 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.

[–] Phegan@lemmy.world 19 points 2 years ago

Allman is the only other one that has some sanity.

[–] Chrumbs@lemmy.blahaj.zone 16 points 2 years ago

Allman is objective the correct choice

[–] JackLSauce@lemmy.world 15 points 2 years ago (2 children)

That's not Lisp...

(while (== x y)
  (func1)
  (func2)
)
[–] kryptonianCodeMonkey@lemmy.world 15 points 2 years ago (1 children)

(((((Not(enough)))((parentheses)))))

[–] superb@lemmy.blahaj.zone 6 points 2 years ago (1 children)

No syntax, only parentheses

load more comments (1 replies)
[–] flamingos@ukfli.uk 8 points 2 years ago

What kind of monster writes lisp with the closing bracket on its own line.

[–] Luvon@beehaw.org 14 points 2 years ago (1 children)

Allman or even horstmann I could still deal with, the rest would be difficult.

Though none are as bad as whoever came up with right aligning all the brackets to make any code look like python until you spot the deranged line of brackets on the right…

I cannot for the life of me find it now but the dude put it on GitHub

[–] AzzyDev@beehaw.org 24 points 2 years ago (1 children)

I found this from ~9 years ago on imgur, “A Python programmer attempting Java”

load more comments (1 replies)
[–] strepto@kbin.social 12 points 2 years ago

I quite like GNU

[–] AVincentInSpace@pawb.social 12 points 2 years ago* (last edited 2 years ago)

People code like that????

People indent braces more than the line before and less than the line after?

Words cannot express my displeasure

[–] fidodo@lemmy.world 12 points 2 years ago

Looking at them all, I don't hate whitesmiths. Keeps all the associated block on one line which makes it a bit easier to parse

[–] glibg10b@lemmy.ml 10 points 2 years ago

I use Allman for control statements and K&R for declarations

[–] Psythik@lemmy.world 10 points 2 years ago (1 children)

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

load more comments (1 replies)
[–] ThatFembyWho@lemmy.blahaj.zone 7 points 2 years ago (1 children)

Some of those made me physically ill.

Like. You do WHAT with your whitespace?!

load more comments (1 replies)
[–] NewPerspective@lemmy.world 6 points 2 years ago

Go is a very opinionated language which is why I was so lucky for their opinion on this (and other things) to agree with mine.

[–] thesporkeffect@lemmy.world 5 points 2 years ago

The eternal holy wars rage on

load more comments
view more: next ›