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?
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.
Allman all the way baybeeee
You should see how a Lisper writes in their native language
They are super extra not okay
Do I need to call your parens*
Meh, it’s what you get when you write a language in a different language’s “style”.
W take
Haskell, baby, what is you doing??
I might have to give this a try 😹
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.
fixed?? 😳😳
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.
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!"); } }
why not
…
System
.out
.println(
"Hello,…
?
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
I’ve seen some people who code like this
Allman is very practical for JSON
Allman is the way.
Always Allman. Those others give you cancer
With all due respect, 🤮
Touché!
Allman makes the code look almost academic
Academic code is specifically created to be easily understood, so I’d agree.
Allman all the way.
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.
Tell me you’re a Java developer without telling me you’re a Java developer.
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.
oh so you hate Richard stallman?
Based
I quite like GNU
GNU style is logical, because braces are syntactically a single statement:
while (x == y) func1(); // can be replaced by { ... }
However, I prefer to entirely avoid unbraced single statements after while/if:
while (x == y) { func1(); // easy to add func2(); later }
Although this is ok when it fits:
while (x == y) func1(); // brevity!
I might argue that rhe syntax of God’s language is the one true syntax.
I am tired and unmotivated so I probably won’t though.
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.
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