Pricefield | Lemmy
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
@[email protected] to Programmer [email protected] • 1 year ago

C++ Moment

lemmy.world

message-square
156
fedilink
1.04K

C++ Moment

lemmy.world

@[email protected] to Programmer [email protected] • 1 year ago
message-square
156
fedilink
  • 𝘋𝘪𝘳𝘬
    link
    fedilink
    81•1 year ago

    Python: So you used spaces and tabs for indentation? NOW DIE!

    • @[email protected]
      link
      fedilink
      47•1 year ago

      Mixing spaces and tabs should be a warcrime.

      • @[email protected]
        link
        fedilink
        English
        9•1 year ago

        And in Python, it’s merely a SyntaxCrime.

      • @[email protected]
        link
        fedilink
        8•1 year ago

        Find me anyone who claims they use tabs for indentation, and I bet I’ll find at least one case where they’re using both tabs and spaces.

        The only safe way to avoid war crimes is to avoid tabs.

        • @[email protected]
          link
          fedilink
          3•
          edit-2
          1 year ago

          Linux kernel?

          https://www.kernel.org/doc/html/v4.10/process/coding-style.html#indentation

          edit: oh python, nevermind

          • @[email protected]
            link
            fedilink
            2•1 year ago

            The kernel definitely mixes tabs and spaces:

            https://elixir.bootlin.com/linux/latest/source/block/bfq-iosched.c#L390

        • @[email protected]
          link
          fedilink
          8•1 year ago

          I use the tab key but I’m pretty sure vs code converts that to spaces

          • @[email protected]
            link
            fedilink
            4•1 year ago

            Depends on your settings, but yeah typically it does

            • @[email protected]
              link
              fedilink
              2•1 year ago

              It worries me that a programmer wouldn’t know for sure what’s happening when they hit tab, and that it’s a setting that can be changed.

              • @[email protected]
                link
                fedilink
                2•1 year ago

                I mean I was 99% sure it convert to spaces, I cannot say I was certain. The default settings are fine for what I do, I only ever had to change the spacing from 4 to 2 spaces once when dealing with someone else’s files

        • @[email protected]
          link
          fedilink
          10•1 year ago

          Why would I use spaces if I use tabs? Also, it seemd like a huge waste of time hitting the space bar so many times…

          • @[email protected]
            link
            fedilink
            9•
            edit-2
            1 year ago

            Why would I use spaces if I use tabs?

            To comply with Python’s best practices:

            https://peps.python.org/pep-0008/

            Also, if you work on the Linux Kernel, you’ll see a mix of tabs and spaces:

            https://elixir.bootlin.com/linux/latest/source/block/bfq-iosched.c#L390

            Also, it seemd like a huge waste of time hitting the space bar so many times…

            You use an editor that doesn’t auto-indent?

            • @[email protected]
              link
              fedilink
              3•1 year ago

              I assume this was a joke 😁

              • @[email protected]
                link
                fedilink
                English
                4•1 year ago

                I use vi without syntax highlighting.

                • @[email protected]
                  link
                  fedilink
                  1•1 year ago

                  Please don’t hack me, mister FBI

                  • @[email protected]
                    link
                    fedilink
                    English
                    2•1 year ago

                    To be fair you can totally bind an arbitrary number of spaces to tab in vi. I’ll dig out the syntax highlighting file some time. Oh and I use vim really.

          • @[email protected]
            link
            fedilink
            1•1 year ago

            deleted by creator

        • @[email protected]
          link
          fedilink
          8•1 year ago

          Don’t IDEs just replace any tab with 4 spaces anyways? Pretty sure VSCode does

          • @[email protected]
            link
            fedilink
            4•1 year ago

            I    don’t    use    an    ide,    but    I    wrote    a    script    that    replaces    any    space    I    type    with    four.

            I    haven’t    worked    out    all    the    use    cases    yet,    though.

          • @[email protected]
            link
            fedilink
            3•1 year ago

            That’s a setting in the editor.

    • Malle_Yeno
      link
      fedilink
      5•1 year ago

      Mixing tabs and white spaces in 2024 is categorically a you problem lmao

    • xigoi
      link
      fedilink
      22•1 year ago

      Good. Spaces and tabs for indentation should never be mixed in any language other than Whitespace.

      • @[email protected]
        link
        fedilink
        English
        4•
        edit-2
        1 year ago

        Some people use tabs for indentation and spaces for alignment. It kind of gets the pros of tabs (user configurable indent-width) and the pros of spaces (alignment). That doesn’t work in Python where you can’t align stuff and the interpreter doesn’t allow mixing tabs with spaces, but in other languages it is a possible style.

        • @[email protected]
          link
          fedilink
          English
          2•1 year ago

          There are no pros to tabs. Configure tabs to a number of spaces.

      • 𝘋𝘪𝘳𝘬
        link
        fedilink
        3•1 year ago

        Raw adjust with tabs, fine adjust with spaces.

        Don’t laugh, people are actually doing that.

    • @[email protected]
      link
      fedilink
      English
      4•1 year ago

      Are you ok?

Programmer [email protected]

[email protected]
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: [email protected]

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 26 users / day
  • 49 users / week
  • 291 users / month
  • 1.53K users / 6 months
  • 4 subscribers
  • 1.84K Posts
  • 38.8K Comments
  • Modlog
  • mods:
  • @[email protected]
  • @[email protected]
  • UI: 0.18.4
  • BE: 0.18.2
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org