dormi.zone
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Sjmarf to Programmer Humor@programming.dev • 10 months ago

Brace Style

sh.itjust.works

message-square
154
fedilink
1.32K

Brace Style

sh.itjust.works

Sjmarf to Programmer Humor@programming.dev • 10 months ago
message-square
154
fedilink
  • @Fillicia@sh.itjust.works
    link
    fedilink
    76•10 months ago

    • @mariusafa@lemmy.sdf.org
      link
      fedilink
      35•10 months ago

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

    • go $fsck yourself
      link
      fedilink
      English
      21•10 months ago

      It’s just YAML…

      • @Fillicia@sh.itjust.works
        link
        fedilink
        25•10 months ago

        YAML makes you appreciate Python’s 4 spaces indentation.

        • Victor
          link
          fedilink
          13•10 months ago

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

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

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

            • ℍ𝕂-𝟞𝟝
              link
              fedilink
              English
              11•10 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
                6•10 months ago

                Tabs!

                • @nexussapphire@lemm.ee
                  link
                  fedilink
                  English
                  11•10 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
                    link
                    fedilink
                    English
                    8•
                    edit-2
                    10 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
                    4•10 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
                  link
                  fedilink
                  English
                  5•10 months ago

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

                • baltakatei
                  link
                  fedilink
                  1•10 months ago

                  deleted by creator

        • @Simulation6@sopuli.xyz
          link
          fedilink
          1•10 months ago

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

          • @BeardedGingerWonder@feddit.uk
            link
            fedilink
            English
            6•10 months ago

            Just assign tab to 4 spaces.

    • u/lukmly013 💾 (lemmy.sdf.org)
      link
      fedilink
      English
      7•
      edit-2
      10 months ago

      Mmmm, perfectly level.

    • @Kojichan@lemmy.world
      link
      fedilink
      2•10 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
        2•10 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
        1•10 months ago

        porn.xml

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

    • bitwolf
      link
      fedilink
      1•
      edit-2
      10 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
  • 3.68K users / day
  • 5.31K users / week
  • 8.42K users / month
  • 17.2K users / 6 months
  • 23.3K subscribers
  • 1.39K Posts
  • 48.8K Comments
  • Modlog
  • mods:
  • Feyter
  • adr1an
  • @BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne
  • BE: 0.19.3
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org