Back writing in my website.

  • thingsiplay@lemmy.ml
    link
    fedilink
    arrow-up
    5
    ·
    19 hours ago

    I think this solves an issue, that’s not an issue at all and makes it more complicated and harder to read. What do I mean by that?

    It requires more text and exact correct syntax of multiple elements. It makes it harder to see where the start and end is, and one has to look for any lines that could potentially be a comment in a heredoc. The syntax highlighter does not show this in comment color. Bash still executes those lines to read the “comment”, as it thinks its normal code. In example variables can still be expanded in heredocs. Other tools removing comments from script to count lines would be fooled too.

    Compare this to a single hashtag symbol in the beginning of each comment. That’s all. This is also good practice everyone understands. From practical point of view, why would anyone use heredocs for multi line comments over single line comments?

    • TehPers@beehaw.org
      link
      fedilink
      English
      arrow-up
      2
      ·
      20 hours ago

      Multiline comments are a bit of an anti-pattern at the best of times.

      If you’re making this as a general statement, it varies from language to language. For example, CSS (and arguably HTML and Markdown) only supports multiline comments, and multiline comments are often used for documentation (as with jsdoc and, though only comments in the same way that heredocs to /dev/null are, Python).

      But yeah, if you actually do this in Bash, wat.

      • FizzyOrange@programming.dev
        link
        fedilink
        arrow-up
        1
        arrow-down
        1
        ·
        5 hours ago

        The fact that CSS only supports multiline comments doesn’t mean multiline comments are good, it means CSS is badly designed.

        • TehPers@beehaw.org
          link
          fedilink
          English
          arrow-up
          2
          arrow-down
          1
          ·
          5 hours ago

          It means neither of those, actually, just that CSS supports only multiline comments.

          Multiline comments remain prevalent across ecosystems though (like in JS and Python). If you believe they’re bad there too, that’s fine, but the fact is that it would be an anti-pattern to go against those established standards.

      • thingsiplay@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        19 hours ago

        CSS (and arguably HTML and Markdown) only supports multiline comments, and multiline comments are often used for documentation

        Those aren’t programming languages. Because, especially in HTML, a line end does not end an instruction and is just for formatting. So single line comments would be very awkward in HTML, so they had to use multi only. And because CSS is meant to be used close to HTML, I think they opt in to the same. JavaScript in example has single line comments again.

        Does any programming language exist that supports multiline comments only without single line comments?

          • thingsiplay@lemmy.ml
            link
            fedilink
            arrow-up
            3
            ·
            edit-2
            17 hours ago

            Good example, at least historical. ;-) I wonder why they never added single line comments before. I mean it took them quite a long time to do so. Languages before 1960 even had single lines too.

            Edit: BTW it was common in C to write multiline comments to have them look like single line comments too, because that’s easier to read and understand. Maybe that’s why they didn’t feel the need for, because in practical usage it could be replicated. In example as:

            /* Title
             * description
             * variables
             */
            

            This could easily be replaced by single lines as:

            // Title
            // description
            // variables
            
        • TehPers@beehaw.org
          link
          fedilink
          English
          arrow-up
          1
          arrow-down
          1
          ·
          edit-2
          18 hours ago

          Both HTML and CSS (when together) are turing complete, and JSX syntax only supports HTML comments in many places.

          JavaScript having single line comments isn’t really relevant. Multiline comments are in heavy use there, arguably moreso than single line comments.

          Edit: and I should add that “programming languages” is moving the goalpost. The person I responded to didn’t qualify their statement to programming languages.

          • thingsiplay@lemmy.ml
            link
            fedilink
            arrow-up
            2
            ·
            18 hours ago

            I don’t think that being turing complete means anything in this discussion, because it does not change what the language is for and how its used and interpreted. HTML and CSS are not instructions for the CPU, they are markup languages describing text for humans, not compiling it down to execute machine code for CPUs.

            • TehPers@beehaw.org
              link
              fedilink
              English
              arrow-up
              2
              ·
              18 hours ago

              Again, the discussion was about multiline comments, not programming languages.

              And regardless of all that, JSX remains one of the most used languages in the world and supports only multiline comments in certain contexts, and JavaScript as a whole uses multiline comments generously.

              The discussion was around multiline comments being an anti-pattern, which is entirely untrue. They just serve a different purpose than single-line comments, and usage varies from language to language.

              • thingsiplay@lemmy.ml
                link
                fedilink
                arrow-up
                1
                ·
                18 hours ago

                The discussion was around multiline comments being an anti-pattern, which is entirely untrue.

                It is an antipattern in Bash. He did not say that for HTML or JavaScript.

                • TehPers@beehaw.org
                  link
                  fedilink
                  English
                  arrow-up
                  1
                  ·
                  18 hours ago

                  Bash doesn’t have multiline comments. Even the article acknowledges this lol. From context, it was a general statement, not specific to Bash.