unboiled.info
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Sjmarf@sh.itjust.works to Programmer Humor@programming.dev · 1 year ago

Brace Style

sh.itjust.works

message-square
148
link
fedilink
763

Brace Style

sh.itjust.works

Sjmarf@sh.itjust.works to Programmer Humor@programming.dev · 1 year ago
message-square
148
link
fedilink
alert-triangle
You must log in or # to comment.
  • TunaCowboy@lemmy.world
    link
    fedilink
    arrow-up
    138
    ·
    edit-2
    1 year ago

    What if I prefer this?

    #define CURLYOPENRIGHTCLOSEDLEFTBRACKET {
    #define CURLYOPENLEFTCLOSEDRIGHTBRACKET }
    #define CURVYOPENRIGHTCLOSEDLEFTBRACKET (
    #define CURVYOPENLEFTCLOSEDRIGHTBRACKET )
    #define PERIODWITHPERIODONTOP :
    #define COMMAWITHPERIODONTOP ;
    
    int main CURVYOPENRIGHTCLOSEDLEFTBRACKET CURVYOPENLEFTCLOSEDRIGHTBRACKET CURLYOPENRIGHTCLOSEDLEFTBRACKET
      if CURVYOPENRIGHTCLOSEDLEFTBRACKET 1 CURVYOPENLEFTCLOSEDRIGHTBRACKET CURLYOPENRIGHTCLOSEDLEFTBRACKET
        asm volatile CURVYOPENRIGHTCLOSEDLEFTBRACKET
          "mov $1, %%rax\n"
          "mov $1, %%rdi\n"
          "lea message(%%rip), %%rsi\n"
          "mov $4, %%edx\n"
          "syscall\n"
          PERIODWITHPERIODONTOP
          PERIODWITHPERIODONTOP
          PERIODWITHPERIODONTOP "%rax", "%rdi", "%rsi", "%rdx"
        CURVYOPENLEFTCLOSEDRIGHTBRACKET COMMAWITHPERIODONTOP
      CURLYOPENLEFTCLOSEDRIGHTBRACKET
      return 0 COMMAWITHPERIODONTOP
    CURLYOPENLEFTCLOSEDRIGHTBRACKET
    
    asm CURVYOPENRIGHTCLOSEDLEFTBRACKET ".section .data\n"
      "message: .ascii \"wut\\n\"\n"
      ".section .text\n" CURVYOPENLEFTCLOSEDRIGHTBRACKET COMMAWITHPERIODONTOP
    
    • humbletightband@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      59
      ·
      1 year ago

      You can’t be helped, sorry. We will put you to an asylum for people like you

      • milicent_bystandr@lemm.ee
        link
        fedilink
        arrow-up
        20
        ·
        1 year ago

        Asylum? We have the electric chair for this.

        • humbletightband@lemmy.dbzer0.com
          link
          fedilink
          arrow-up
          13
          arrow-down
          1
          ·
          1 year ago

          Yeah, now I see why you want him dead. He used mov after lea

      • uis@lemm.ee
        link
        fedilink
        arrow-up
        3
        ·
        1 year ago

        Pack him, boys: https://youtu.be/hHuLZFuugTQ

    • z500@startrek.website
      link
      fedilink
      arrow-up
      47
      ·
      edit-2
      1 year ago

      You win a free trip to the Hague

      • SkyezOpen@lemmy.world
        link
        fedilink
        arrow-up
        17
        ·
        1 year ago

        They don’t even deserve the trial. Straight to gulag.

        • uis@lemm.ee
          link
          fedilink
          arrow-up
          3
          ·
          1 year ago

          Still need at least troyka to send to gulag. Or regular court outside of stalinism.

          • lud@lemm.ee
            link
            fedilink
            arrow-up
            3
            ·
            1 year ago

            The taxi chauffeur can be judge and do it on the way to the gulag.

            Obviously the sentence is predetermined.

    • dariusj18@lemmy.world
      link
      fedilink
      arrow-up
      27
      ·
      1 year ago

      Can this be done with emoji?

      • brbposting@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 year ago

        😫

    • xmunk@sh.itjust.works
      link
      fedilink
      arrow-up
      19
      ·
      1 year ago

      Acceptable, just FYI I added a pre-commit git hook, please rebase your changes.

    • MajorHavoc@programming.dev
      link
      fedilink
      arrow-up
      17
      ·
      1 year ago

      Thanks. I hate it.

  • Admiral Patrick@dubvee.org
    link
    fedilink
    English
    arrow-up
    94
    ·
    edit-2
    1 year ago

    Mom, can we stop and get some Python?

    No, we have Python at home.

    Python at home…

  • AlexWIWA@lemmy.ml
    link
    fedilink
    English
    arrow-up
    71
    ·
    1 year ago

    Python with extra steps

  • Fillicia@sh.itjust.works
    link
    fedilink
    arrow-up
    58
    ·
    1 year ago

    • mariusafa@lemmy.sdf.org
      link
      fedilink
      arrow-up
      28
      ·
      1 year ago

      Literally me every time I want to program something slightly complex in Python.

    • go $fsck yourself@lemmy.world
      link
      fedilink
      English
      arrow-up
      17
      ·
      1 year ago

      It’s just YAML…

      • Fillicia@sh.itjust.works
        link
        fedilink
        arrow-up
        19
        ·
        1 year ago

        YAML makes you appreciate Python’s 4 spaces indentation.

        • Victor@lemmy.world
          link
          fedilink
          arrow-up
          8
          ·
          1 year ago

          I thought python allowed whatever indentation you wanted as long as it’s consistent?

          • Fillicia@sh.itjust.works
            link
            fedilink
            arrow-up
            16
            ·
            1 year ago

            pep8 calls for 4 space but it is a guidance not a rule.

            Google internal style guide recommend(ed?) 2 spaces to accomodate the line length limit.

          • zalgotext@sh.itjust.works
            link
            fedilink
            arrow-up
            8
            ·
            1 year ago

            It does, but most style guides and autoformatters will use 4

            • ℍ𝕂-𝟞𝟝@sopuli.xyz
              link
              fedilink
              English
              arrow-up
              7
              ·
              1 year ago

              Python is one of the few languages with an official style guide, I think that guide says 4 spaces.

              • northendtrooper@lemmy.ca
                link
                fedilink
                arrow-up
                5
                arrow-down
                1
                ·
                1 year ago

                Tabs!

                • nexussapphire@lemm.ee
                  link
                  fedilink
                  English
                  arrow-up
                  10
                  ·
                  1 year ago

                  I’ve set tabs to four spaces in vim because who the fuck defaults tab to eight spaces. That shit looks alien and pushes text off the screen fast.

                • lad@programming.dev
                  link
                  fedilink
                  English
                  arrow-up
                  5
                  ·
                  1 year ago

                  4 tabs is a bit overboard, don’t you think?

        • Simulation6@sopuli.xyz
          link
          fedilink
          arrow-up
          1
          ·
          1 year ago

          4 spaces? Hard core Python programmers must have a callus on their thumbs.

          • BeardedGingerWonder@feddit.uk
            link
            fedilink
            English
            arrow-up
            5
            ·
            1 year ago

            Just assign tab to 4 spaces.

    • u/lukmly013 💾 (lemmy.sdf.org)@lemmy.sdf.org
      link
      fedilink
      English
      arrow-up
      4
      ·
      edit-2
      1 year ago

      Mmmm, perfectly level.

    • Kojichan@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      I’d love to see your .editorconfig.

      …

      …

      What’s that in your project root? …pom.xml? Misread that at first as porn.xml.

      • 0ops@lemm.ee
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        porn.xml

        If I had a nickel every time I read it like that

      • Fillicia@sh.itjust.works
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        I’m not the OG on this, just an old reddit post I remembered

        https://old.reddit.com/r/ProgrammerHumor/comments/9fhvyl/writing_yaml/

    • bitwolf@lemmy.one
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      1 year ago

      But yaml forces the indentation

  • Treczoks@lemmy.world
    link
    fedilink
    arrow-up
    62
    arrow-down
    4
    ·
    1 year ago

    Python programmer encountering a real programming language for the first time.

    • NutWrench@lemmy.ml
      link
      fedilink
      arrow-up
      9
      ·
      1 year ago

      Or a former BASIC programmer who really hates braces . . .

      • dosuser123456@lemmy.sdf.org
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        [urge to mention that @dosuser123456@lemmy.sdf.org codes in basic intensifies]

    • Reddfugee42@lemmy.world
      link
      fedilink
      English
      arrow-up
      5
      arrow-down
      2
      ·
      1 year ago

  • MadMadBunny@lemmy.ca
    link
    fedilink
    arrow-up
    49
    arrow-down
    1
    ·
    1 year ago

    WE CAN DO THAT!?!??

    • Skullgrid@lemmy.world
      link
      fedilink
      arrow-up
      43
      ·
      1 year ago

      … whitespace is whitespace.

      • dQw4w9WgXcQ@lemm.ee
        link
        fedilink
        arrow-up
        3
        ·
        1 year ago

        deleted by creator

  • SlothMama@lemmy.world
    link
    fedilink
    arrow-up
    51
    arrow-down
    6
    ·
    1 year ago

    I low key love it. It’s unconventional, but it’s not hard to read

    • repungnant_canary@lemmy.world
      link
      fedilink
      arrow-up
      28
      ·
      1 year ago

      it’s not hard to read

      Until there’s missing brace somewhere

      • Jyek@sh.itjust.works
        link
        fedilink
        arrow-up
        8
        ·
        1 year ago

        I think this could be better for reading but harder for writing. Like you could write a script that converts between this and the easier to write way if you are working on a project with others.

      • Caveman@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        On braces are not used in if or for statements

  • /home/pineapplelover@lemm.ee
    link
    fedilink
    arrow-up
    45
    arrow-down
    1
    ·
    1 year ago

    I was like, “where are the braces?”. Then, I turned to the right

    • AlecSadler@sh.itjust.works
      link
      fedilink
      arrow-up
      10
      ·
      1 year ago

      And then I realized it’s python.

      • /home/pineapplelover@lemm.ee
        link
        fedilink
        arrow-up
        3
        ·
        1 year ago

        Wait what? It’s Python? But there are semicolons

        • petrol_sniff_king@lemmy.blahaj.zone
          link
          fedilink
          arrow-up
          5
          ·
          1 year ago

          They mean that the code is being written like it were python. You can’t get rid of the curly braces, but you can shove them all under your bed where mom can’t see.

    • Knock_Knock_Lemmy_In@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      1 year ago

      Thank you. I couldn’t see the problem.

      And if this layout is auto generated, maybe I still don’t see the problem.

  • Heavybell@lemmy.world
    link
    fedilink
    English
    arrow-up
    43
    ·
    edit-2
    1 year ago

    This looks like a python programmer that is mad they have to write C# Java…

    • schnurrito@discuss.tchncs.de
      link
      fedilink
      arrow-up
      8
      ·
      1 year ago

      Pretty sure that is Java, not C#

      • Heavybell@lemmy.world
        link
        fedilink
        English
        arrow-up
        5
        ·
        1 year ago

        No, you`re right.

  • Match!!@pawb.social
    link
    fedilink
    English
    arrow-up
    40
    ·
    1 year ago

    This should be its own language. Pyava.

    • jwt@programming.dev
      link
      fedilink
      arrow-up
      30
      ·
      1 year ago

      Or Jathon (pronounced like Mike Tyson would pronounce JSON)

      • runeko@programming.dev
        link
        fedilink
        arrow-up
        19
        ·
        1 year ago

        Or we can round out the confusion and call it PythonScript

  • sunglocto@lemmy.zip
    link
    fedilink
    English
    arrow-up
    41
    arrow-down
    1
    ·
    1 year ago

    Idk why but i fell in love with this and might just use it now

    • Vilian@lemmy.ca
      link
      fedilink
      arrow-up
      14
      ·
      1 year ago

      God

    • NigelFrobisher@aussie.zone
      link
      fedilink
      arrow-up
      8
      ·
      1 year ago

      I just realised why we do live coding interviews.

    • morrowind@lemmy.ml
      link
      fedilink
      arrow-up
      5
      ·
      1 year ago

      It would be nice and easy if we had elastic tabstops

      • Vilian@lemmy.ca
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        That’s true, I wanted to port that to Kate for me to test, but I’m too dumb to port the Scala implementation to QT/KDE framework

  • NigelFrobisher@aussie.zone
    link
    fedilink
    arrow-up
    39
    ·
    edit-2
    1 year ago

    My credo on this kind of thing is never do something that will make your successor so mad that they find out where you live and post parts of your body to Interpol.

    • dejected_warp_core@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      1 year ago

      Good fences make good neighbors.

      Corollary: server-side commit hooks make good teammates.

  • nexussapphire@lemm.ee
    link
    fedilink
    English
    arrow-up
    37
    ·
    1 year ago

    Last day at the company, pushed over 5,000 commits. Just style changes, still passes all the checks.

    • KairuByte@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      9
      ·
      1 year ago

      This would never pass PR review.

      • el_abuelo@programming.dev
        link
        fedilink
        arrow-up
        12
        ·
        1 year ago

        Jokes on you, we don’t have PR review.

        • KairuByte@lemmy.dbzer0.com
          link
          fedilink
          arrow-up
          3
          ·
          1 year ago

          Dear god

          • el_abuelo@programming.dev
            link
            fedilink
            arrow-up
            3
            ·
            1 year ago

            He can’t hear you all the way down here.

        • dejected_warp_core@lemmy.world
          link
          fedilink
          arrow-up
          2
          ·
          1 year ago

          This is fine.

        • nexussapphire@lemm.ee
          link
          fedilink
          English
          arrow-up
          1
          ·
          1 year ago

          Do your code reviewers subscribe to the didn’t check looks good model? Joking btw.

  • Hack3900@lemy.lol
    link
    fedilink
    arrow-up
    33
    ·
    1 year ago

    I kinda like it…

    • VonReposti@feddit.dk
      link
      fedilink
      arrow-up
      11
      ·
      edit-2
      1 year ago

      I think you’ll like Ruby. It has mostly done away with braces and code blocks end with end, e.g.

      def create
        unless admin redirect_to new_session_path and return
        
        @product = Product.new product_params
      
        if @product.save
          flash[:success] = "New product has been created!"
          redirect_to edit_product_path(@product) and return
        else
          flash[:error] = "Something went wrong!
          render :new
        end
      end
      

      This is working code that I simplified a bit from an old project of mine.

      • Caveman@lemmy.world
        link
        fedilink
        arrow-up
        9
        ·
        1 year ago

        Ruby syntax is nice although I prefer python way of enforcing indentation instead of adding "end"s. Personally I just want a statically typed language with enforced indent as syntax.

        • VonReposti@feddit.dk
          link
          fedilink
          arrow-up
          5
          ·
          1 year ago

          Funny, the forced indentation is what I hate about Python. If you think a missing semicolon can be hard to catch, don’t ever think about a missing whitespace :p

          The end keyword really isn’t a big deal for me. I find it to be a good way to easily spot the end of a method. But if you wouldn’t like it I’d still find it a good compromise to avoid syntax issues due to whitespace.

          • hglman@lemmy.ml
            link
            fedilink
            English
            arrow-up
            4
            ·
            1 year ago

            i can count on one hand how many times ive had white space issues in 15 years of using python. its just not an issue

            • 0ops@lemm.ee
              link
              fedilink
              arrow-up
              2
              ·
              1 year ago

              Same and agreed, especially if you keep your functions small and focused as you should. 3-5 indents is nbd to keep track of, and if you need more than that… No you don’t, refactor.

              I’ve had way more hangups with brackets then indentation, personally, not that either is a super frequent issue, but I’m indenting anyway, so brackets are redundant and just another thing I have to keep track of

          • JackbyDev@programming.dev
            link
            fedilink
            English
            arrow-up
            2
            ·
            1 year ago

            } helps me easily spot the end of stuff. end just blends into the statements.

        • JackbyDev@programming.dev
          link
          fedilink
          English
          arrow-up
          1
          ·
          1 year ago

          Just add a linter to your build lol. Now if it’s indented wrong it breaks!

      • barsoap@lemm.ee
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        1 year ago

        That’s just Algol instead of B. Most languages use the one or the other, then there’s sexpr-based languages (lisp, scheme), lua (technically Algol but not needing semicolons while also not needing newlines so it’s definitely special), and layout syntax (Haskell, or, if you want a bad implementation, python).

    • Caveman@lemmy.world
      link
      fedilink
      arrow-up
      10
      ·
      1 year ago

      Who’s going to write the extension so that they are all hidden and automatically inserted?

    • bss03@infosec.pub
      link
      fedilink
      arrow-up
      4
      ·
      1 year ago

      Might check out the Haskell layout rules.

      Basically, when you leave out the ‘{’ then Haskell uses your intendation to insert ‘;}’ on later lines between the leading whitespace and the first token.

      There some really old Haskell code out there that lines up the ‘{;}’ characters on the left under block-introduction keywords.

      • barsoap@lemm.ee
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        It’s not just old Haskell code that’s how you write Haskell if you want explicit braces. Well, mostly generate, but it’s still the idiomatic formatting (and when you generate you always generate braces because it’s easy to get layout subtly wrong when generating).

        Haskell also does the whole

        data Foo = Bar
                 | Baz
                 | Quux
        
        foo = [ Bar
              , Baz
              , Quux
              ]
        

        thing, makes sense to apply it to braces especially as they’re seen only very rarely. Single-line, yes, but not multi-line.

  • Binette@lemmy.ml
    link
    fedilink
    arrow-up
    33
    ·
    1 year ago

    Pseudo-python

Programmer Humor@programming.dev

programmer_humor@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmer_humor@programming.dev

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 1 user / day
  • 1.49K users / week
  • 4.23K users / month
  • 14.4K users / 6 months
  • 2 local subscribers
  • 25K subscribers
  • 1.54K Posts
  • 40.4K Comments
  • Modlog
  • mods:
  • Feyter@programming.dev
  • adr1an@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • UI: unknown version
  • BE: 0.19.12
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org