• LarmyOfLone@lemm.ee
    link
    fedilink
    arrow-up
    0
    ·
    5 months ago

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

    while x==y
         func1
         func2
    
    • p1mrx@sh.itjust.works
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      5 months ago

      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!
      
  • Bienenvolk@feddit.de
    link
    fedilink
    arrow-up
    0
    ·
    5 months ago

    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.

    • Alien Nathan Edward@lemm.ee
      link
      fedilink
      English
      arrow-up
      0
      ·
      5 months ago

      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”.

    • kryptonianCodeMonkey@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      5 months ago

      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
        link
        fedilink
        English
        arrow-up
        0
        ·
        edit-2
        5 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

  • Luvon@beehaw.org
    link
    fedilink
    arrow-up
    0
    ·
    5 months ago

    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

    • Azzy@beehaw.org
      link
      fedilink
      arrow-up
      0
      ·
      5 months ago

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

      • Luvon@beehaw.org
        link
        fedilink
        arrow-up
        0
        ·
        5 months ago

        Haha ya that is probably it, looks great, just don’t read all the way to the right 😆

  • Gork@lemm.ee
    link
    fedilink
    arrow-up
    0
    ·
    5 months ago

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

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

  • Psythik@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    5 months ago

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