Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Why, in code, is there a tendency to use multiple // instead of a /**/ when writing multi-line comments?

11 Answers

Relevance
  • Anonymous
    4 years ago

    do not know sorry

  • 4 years ago

    Just habit and what is easier at the time.

  • mars
    Lv 7
    4 years ago

    form preference

  • 4 years ago

    Style.

    When I was first learning programming, there wasn't a multi-line comment, so I'm accustomed to using single-line comments for things like documentation. Some programming languages still don't have this feature.

    I only use multi-line comments when debugging, and I want to skip a block of code.

  • How do you think about the answers? You can sign in to vote the answer.
  • ?
    Lv 5
    4 years ago

    This is just your supposition, and not a fact, and is based only on C, C++, and Java. Many

    other languages have different styles: Python uses triple quotes for docstrings; Lisp, Scheme,

    Racket and others use ; and dash-bracket combinations for comments; Haskell uses -- for

    single-line comments and {- -} for multiline comments; OCaml uses another style, etc.

    Don't be so parochial. The few lines of code that you've seen are a drop in the bucket.

    >

    > John (gnujohn)

  • joe
    Lv 6
    4 years ago

    personal preference

  • 4 years ago

    // means that whatever exists from there to the end of the current line is a comment.

    For two line comments, it requires the same number of keystrokes as /* */. For more than two lines in a comment, // is less efficient in terms the number of key strokes.

    Not all compilers support //. Some compilers support nested /* */ comments, while others do not. A nested comment looks like this:

    /* start of comment 1

    /* start of comment 2

    end of comment 2 */

    end of comment 1 */

    I tend to use /* */ for temporarily disabling sections of code when I am debugging new code. If the compiler supports nested comments, it makes it much easier to disable large sections of code that already have comments included.

    For compiler portability, using non-nested /* */ should offer the best independence across different compilers.

    That's my view.

  • 4 years ago

    If you are using an editor that doesn't do syntax highlighting then using // will make it more clear which lines are comments and which aren't. This is especially important when you are commenting out code.

  • George
    Lv 4
    4 years ago

    two less key presses each time.

  • Anonymous
    4 years ago

    I'm sure it's because it more clearly marks the whole block of text as comments, no matter what gibberish you've typed in there

Still have questions? Get your answers by asking now.