• algernon@lemmy.ml
    link
    fedilink
    arrow-up
    3
    ·
    5 months ago

    Sadly, that’s not code Linus wrote. Nor one he merged. (It’s from git, copied from rsync, committed by Junio)

        • rwhitisissle@lemmy.ml
          link
          fedilink
          arrow-up
          1
          ·
          5 months ago

          I’ve heard similar from the worst first year CS students you could ever meet. People talk out their ass without the experience to back up their observations constantly. The indentation thing is a reasonable heuristic that states you are adding too much complexity at specific points in your code that suggests you should isolate core pieces of logic into discrete functions. And while that’s broadly reasonable, this often has the downside of you producing code that has a lot of very small, very specific functions that are only ever invoked by other very small, very specific functions. It doesn’t make your code easier to read or understand and it arguably leads to scenarios in which your code becomes very disorganized and needlessly opaque purely because you didn’t want additional indentation in order to meet some kind of arbitrary formatting guideline you set for yourself. This is something that happens in any language but some languages are more susceptible to it than others. PEP8’s line length limit is treated like biblical edict by your more insufferable python developers.

      • Epzillon@lemmy.ml
        link
        fedilink
        arrow-up
        1
        arrow-down
        1
        ·
        5 months ago

        Isn’t that from 1991 while the quote is from 1995? If we’re nitpicking maybe we shouldn’t time travel 🤓

    • laughterlaughter@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      5 months ago

      Plus it shows three levels of indentation. Well… there is the extra one created by the compiler directives, but do they really count?

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

    rules aren’t there to be enforced, they’re there so that when you break them you take a second to think about why.

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

    Why is multiple levels of indentation bad?

    IDK, but if the reason is “to break stuff into multiple functions”, then I’m not necessarily writing yet another single-use function just to avoid writing a comment, especially in time critical applications. Did that with a text parser that could get text formatting from a specifically written XML file, but mainly due to it being way less time critical, and had a lot of reused code via templates.

    • theherk@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      5 months ago

      Like with everything, context matters. Sometimes it can indicate poorly structured control flow, other times inefficient loop nesting. But many times it is just somebody’s preference for guard clauses. As long as the intent is clear, there are no efficiency problems, and it is possible to reach the fewest branches necessary, I see no issues.

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

      That *++ operator from C is indeed confusing.

      Reminds me of the goes-to operator: --> that you can use as:

      while(i --> 0) {
      
      • letsgo@lemm.ee
        link
        fedilink
        arrow-up
        1
        ·
        5 months ago

        That’s not a real operator. You’ve put a space in “i–” and removed the space in “-- >”. The statement is “while i-- is greater than zero”. Inventing an unnecessary “goes to” operator just confuses beginners and adds something else to think about while debugging.

        And yes I have seen beginners try to use <-- and --<. Just stop it.

        • marcos@lemmy.world
          link
          fedilink
          arrow-up
          0
          arrow-down
          1
          ·
          5 months ago

          The sheer number of people that do not expect a joke on this community… (Really, if you are trying to learn how to program pay attention to the one without the Humor on the name, not here.)

          Well, I guess nobody expects.