• @Solrac
    link
    698 months ago

    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?

    • @[email protected]
      link
      fedilink
      98 months ago

      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

      • @[email protected]
        link
        fedilink
        118 months ago

        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.

    • @Phoenix3875
      link
      58 months ago

      Meh, it’s what you get when you write a language in a different language’s “style”.

  • @[email protected]
    link
    fedilink
    618 months ago

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

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

    • @redempt
      link
      68 months 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
    link
    468 months ago

    Allman works best if you like folding code blocks.

      • @psycho_driver
        link
        38 months ago

        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.

        • JackbyDev
          link
          fedilink
          English
          48 months 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.

  • LazaroFilm
    link
    English
    348 months ago

    No line breaks. Just one long line of code.

    • @kryptonianCodeMonkey
      link
      32
      edit-2
      8 months ago

      All line breaks. Just one tower of code.

      class
      HelloWorld
      {
      public
      static
      void
      main(String[]
      args)
      {
      System.out.println("Hello,
      World!");
      }
      }
      
      • @[email protected]
        link
        fedilink
        English
        15
        edit-2
        8 months ago

        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

      • Madlaine
        link
        fedilink
        7
        edit-2
        8 months ago

        why not

        System
        .out
        .println(
        "Hello,

        ?

      • qazM
        link
        38 months ago

        I’ve seen some people who code like this

  • Aedis
    link
    318 months ago

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

    • @mvirts
      link
      58 months ago

      I might have to give this a try 😹

  • @[email protected]
    link
    fedilink
    22
    edit-2
    8 months 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
    link
    198 months ago

    Allman is the only other one that has some sanity.

  • @JackLSauce
    link
    178 months ago

    That’s not Lisp…

    (while (== x y)
      (func1)
      (func2)
    )
    
        • 7heo
          link
          fedilink
          1
          edit-2
          8 months ago

          Hear me out: brainfuck, but with parentheses only.

          >    )))
          <    (((
          +    ())
          -    (()
          .    ()(
          ,    )()
          [    )((
          ]    ))(
          

          Hello world example:

          ()))(((()(())))(())(())))))()))))(()
          (()(()(()(()(((((())(((((()(()((((()
          (()(()))()))(()()()))))))))())()()))
          )))()(()(())())()))((()()))))(((((((
          ((((((()(())())())()((()(()(()(()(()
          (()()((((((((()()())))))))))))())()(
          

          Ancient aliens meme with the caption "LIPS!!"

          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()
          
    • flamingos-cant
      link
      fedilink
      English
      88 months ago

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

  • @seth
    link
    168 months ago

    deleted by creator

    • @[email protected]
      link
      fedilink
      English
      258 months ago

      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.

      • @seth
        link
        78 months ago

        deleted by creator

    • @kryptonianCodeMonkey
      link
      24
      edit-2
      8 months ago

      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!

      • @[email protected]
        link
        fedilink
        English
        68 months ago

        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.

    • @[email protected]
      link
      fedilink
      English
      158 months ago

      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)

    • @[email protected]
      link
      fedilink
      48 months ago

      using 3 space wide tabs 🙋

      although it doesn’t matter to others, because it’s an editor setting.

      I use nano btw.

  • @[email protected]
    link
    fedilink
    English
    12
    edit-2
    8 months 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
    link
    English
    118 months 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