Allman is very practical for JSON
Allman is the way.
With all due respect, 🤮
Touché!
Always Allman. Those others give you cancer
Allman all the way.
Allman makes the code look almost academic
Academic code is specifically created to be easily understood, so I’d agree.
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?
Do I need to call your parens*
Allman all the way baybeeee
I’ve written Haskell quite a bit, and I don’t fully understand why this is called Haskell style. Haskell code looks nothing like this, the syntax is completely different. For Haskell’s syntax I think it works fine, because I never noticed something weird. But this code in “Haskell style” looks absolutely insane
It’s sometimes called comma-leading style where you move all the special characters to the front of the line and it is exceedingly common in Haskell, possibly due to how Haskell treats significant whitespace. You’ve surely seen list definitions that look like this:
someList = [ 1 , 2 , 3 ]
or a data definition like this:
data Color = Red | Green | Blue | RGB Int Int Int deriving (Show, Eq)
or a list of module exports like this:
module Foo { bar , baz , quux }
Or in a long function type declaration where the arrows are moved to the start of the line, or a record definition, etc. etc.
Meh, it’s what you get when you write a language in a different language’s “style”.
You should see how a Lisper writes in their native language
They are super extra not okay
W take
All of those are heretical. The one True Language is Brainfuck, where the coding syntax for Hello World is
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
The Morse code of programming languages.
Allman looks fine to me. But I’m a C# dev so maybe I’m just used to it.
It’s not my favorite but it’s fine.
Allman changes the way I code. I avoid using imperative constructs so much more because they waste so much more space on my screen.
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.
Plus one for Allman gang
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.
this is only true if you don’t indent properly
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.
Allman works best if you like folding code blocks.
Why?
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.
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.
No line breaks. Just one long line of code.
All line breaks. Just one tower of code.
class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }
as always, c++ lets us do better in breathtakingly elegant fashion:
#\ i\ n\ c\ l\ u\ d\ e\ \ <\ 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
why not
…
System
.out
.println(
"Hello,…
?
I’ve seen some people who code like this
Tell me you’re a Java developer without telling me you’re a Java developer.
Haskell, baby, what is you doing??
I might have to give this a try 😹
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.
deleted by creator
Indents should exclusively be a single tab per indent, not any number of spaces, and width should be handled by the IDE renderer, configurably, rather than baked into the code.
deleted by creator
Tabs should be 4 spaces because it can be replaced 1:1 with “tabs”.
For example…
def foo(): if bar: foobar()
vs…
def foo(): tabsif bar: tabstabsfoobar()
Put that in your code review, cowards!
Only if a person’s machine is set to a tab size of four spaces. By this logic, we would need eight spaces for the people with a larger tab size of eight on their machines so they could be 1:1. Minimizing horizontal space is ideal as not everyone has huge horizontal monitor space to work with. But, everyone has infinite vertical space with scrolling.
I think they mean the word ‘tabs’
oh lol, I missed that =p
If your code takes up so much horizontal space with 4-space tabs, you’re putting too much on one line or indenting too deep. 4-space tabs keeps your line length manageable.
If you have to nest more than 2 layers, rewrite your code.
Or you’re using four spaces per tab, just throwing that out there. =p
I’m a tab stop = 8 kinda guy 2 is just tiny looks like an accidental leading space
(this is also why using spaces for indentation is bad)
using 3 space wide tabs 🙋
although it doesn’t matter to others, because it’s an editor setting.
I use nano btw.
nano? I mean, really?
nano on the command line with syntax highlighting
why not nvim?
amen
Allman is the only other one that has some sanity.
That’s not Lisp…
(while (== x y) (func1) (func2) )
(((((Not(enough)))((parentheses)))))
No syntax, only parentheses
Hear me out: brainfuck, but with parentheses only.
> ))) < ((( + ()) - (() . ()( , )() [ )(( ] ))(
Hello world example:
()))(((()(())))(())(())))))()))))(() (()(()(()(()(((((())(((((()(()((((() (()(()))()))(()()()))))))))())()())) )))()(()(())())()))((()()))))((((((( ((((((()(())())())()((()(()(()(()(() (()()((((((((()()())))))))))))())()(
Python transpiler:
#!/usr/bin/env python """Lipsfuck to brainfuck transpiler""" from sys import stdin OPS = {")))": '>', "(((": '<', "())": '+', "(()": '-', "()(": '.', ")()": ',', ")((": '[', "))(": ']'} def main(): """Obvious main procedure""" _d = ''.join(stdin.readlines()).rstrip('\n') for _op in [_d[x:x+3] for x in range(0, int(len(_d)), 3)]: print(OPS[_op], end='') print() if __name__ == "__main__": main()
What kind of monster writes lisp with the closing bracket on its own line.
Allman is objective the correct choice
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
I found this from ~9 years ago on imgur, “A Python programmer attempting Java”
Haha ya that is probably it, looks great, just don’t read all the way to the right 😆