OrcasEnjoyingYachts
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Sjmarf@sh.itjust.works to Programmer Humor@programming.dev · 9 months ago

Brace Style

sh.itjust.works

message-square
156
fedilink
1.32K

Brace Style

sh.itjust.works

Sjmarf@sh.itjust.works to Programmer Humor@programming.dev · 9 months ago
message-square
156
fedilink
  • Fillicia@sh.itjust.works
    link
    fedilink
    arrow-up
    78
    arrow-down
    1
    ·
    9 months ago

    • mariusafa@lemmy.sdf.org
      link
      fedilink
      arrow-up
      36
      ·
      9 months ago

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

    • go $fsck yourself@lemmy.world
      link
      fedilink
      English
      arrow-up
      21
      ·
      9 months ago

      It’s just YAML…

      • Fillicia@sh.itjust.works
        link
        fedilink
        arrow-up
        25
        ·
        9 months ago

        YAML makes you appreciate Python’s 4 spaces indentation.

        • Victor@lemmy.world
          link
          fedilink
          arrow-up
          13
          ·
          9 months ago

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

          • Fillicia@sh.itjust.works
            link
            fedilink
            arrow-up
            20
            ·
            9 months 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
            10
            ·
            9 months ago

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

            • ℍ𝕂-𝟞𝟝@sopuli.xyz
              link
              fedilink
              English
              arrow-up
              11
              ·
              9 months 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
                6
                arrow-down
                1
                ·
                9 months ago

                Tabs!

                • nexussapphire@lemm.ee
                  link
                  fedilink
                  English
                  arrow-up
                  11
                  ·
                  9 months 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.

                  • Oscar@programming.dev
                    link
                    fedilink
                    English
                    arrow-up
                    8
                    ·
                    edit-2
                    9 months ago

                    Linux uses 8 spaces. Excerpt from the official style guide:

                    Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations 4 (or even 2!) characters deep, and that is akin to trying to define the value of PI to be 3.

                    Rationale: The whole idea behind indentation is to clearly define where a block of control starts and ends. Especially when you’ve been looking at your screen for 20 straight hours, you’ll find it a lot easier to see how the indentation works if you have large indentations.

                    Now, some people will claim that having 8-character indentations makes the code move too far to the right, and makes it hard to read on a 80-character terminal screen. The answer to that is that if you need more than 3 levels of indentation, you’re screwed anyway, and should fix your program.

                    In short, 8-char indents make things easier to read, and have the added benefit of warning you when you’re nesting your functions too deep. Heed that warning.

                    • https://www.kernel.org/doc/html/latest/process/coding-style.html

                    The reasoning seems sound, but I still prefer 4 personally.

                  • ulterno@lemmy.kde.social
                    link
                    fedilink
                    English
                    arrow-up
                    4
                    ·
                    9 months ago

                    I set my clang-format to tabs only (actual tabs ASCII 0x9, no alignment and there is a continuation tab instead), then anyone can set their editor to whatever tab length they feel like and look at their code however they want.

                    But no spaces on the left of my code. This is for C, C++ and JSON.

                • lad@programming.dev
                  link
                  fedilink
                  English
                  arrow-up
                  5
                  ·
                  9 months ago

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

                • baltakatei@sopuli.xyz
                  link
                  fedilink
                  arrow-up
                  1
                  ·
                  9 months ago

                  deleted by creator

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

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

          • BeardedGingerWonder@feddit.uk
            link
            fedilink
            English
            arrow-up
            6
            ·
            9 months ago

            Just assign tab to 4 spaces.

    • u/lukmly013 💾 (lemmy.sdf.org)@lemmy.sdf.org
      link
      fedilink
      English
      arrow-up
      7
      arrow-down
      1
      ·
      edit-2
      9 months ago

      Mmmm, perfectly level.

    • Kojichan@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      9 months ago

      I’d love to see your .editorconfig.

      …

      …

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

      • Fillicia@sh.itjust.works
        link
        fedilink
        arrow-up
        2
        ·
        9 months 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/

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

        porn.xml

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

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

      But yaml forces the indentation

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.

  • 2.04K users / day
  • 4.47K users / week
  • 9.25K users / month
  • 17.5K users / 6 months
  • 1 local subscriber
  • 23.1K subscribers
  • 1.38K Posts
  • 50.3K Comments
  • Modlog
  • mods:
  • Feyter@programming.dev
  • adr1an@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • BE: 0.19.10
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org