Comment from my group project teammate. You don’t need to comment every line lol

  • u/lukmly013 💾 (lemmy.sdf.org)
    link
    fedilink
    English
    157 months ago

    I am not a programmer, I just barely wrote one bash script in the past. But I’d say more comments are better than too few.

    When I later wanted to edit it, I got completely lost. I wrote it with absolutely no comments.

    • @riodoro1
      link
      227 months ago

      Bash is a shit „language” and everytime i need to write the simplest thing in it I forget which variable expansion I should use and how many spaces are the right amount of spaces. It’s impossible to write nice to read bash, but even in C you can write code that comments itself.

      • @marcos
        link
        107 months ago

        It’s perfectly possible to write nice to read bash, and to also make is safe to run and well-behaved on errors.

        But all the three people that can do those (I’m not on the group) seem to be busy right now.

      • @AProfessional
        link
        English
        67 months ago

        bash sucks but i don’t agree. Some simple rules like regularly use intermediate variables with useful names and never use shorthand arguments goes a long way.

    • @[email protected]
      link
      fedilink
      English
      37 months ago

      I’ve been programming for almost 25 years and I’d still rather see too many comments than too few. A dogmatic obsession with avoiding comments screams “noob” just as much as crummy “add 1 to x” comments. If something is complex or non-obvious I want a note explaining why it’s there and what it’s supposed to do. This can make all the difference when you’re reviewing code that doesn’t actually do what the comment says it should.

    • @Fades
      link
      1
      edit-2
      7 months ago

      Wrong. Too many comments makes the code messy and less readable and also it provides ZERO value. Just look at the post, WHAT is useful about ANY of that comment???

      All it is is a waste of goddamn space, literal junk crowding the actual code.

      I love how you admit you aren’t a developer but feel quite confident to tell us that a larger number of comments automatically means it’s better.

      This person articulated it better than I: https://midwest.social/comment/10319821

      • @LwL
        link
        37 months ago

        Too many is still better than too few, and it’s not close. Useless comments make parsing a bit harder. Missing comments can mean hours of research.

        • @[email protected]
          link
          fedilink
          English
          4
          edit-2
          7 months ago

          These are arguments talking past each other. Sure 1 useful comment and 9 redundant ones can be better than zero, but comments are not reliable and often get overlooked in code changes and become misleading, sometimes critically misleading. So often the choice is between not enough comments versus many comments that you cannot trust and will sometimes tell you flat-out lies and overall just add to the difficulty of reading the code.

          There’s no virtue in the number of comments, high or low. The virtue is in the presence of quality comments. If we try to argue about how many there should be we can talk past each other forever.

    • @[email protected]
      link
      fedilink
      1
      edit-2
      7 months ago

      While this is true, an alternative is to name your variables and functions descriptively so that when you see number_of_cats you know that variable is the number of cats, and buyAnotherCat() is a function that increases the number of cats.