33

When my coworker doesn't want to believe his code is inconsistent, yet he changes the syntax for commenting 3 times over 10 lines.

Comments
  • 2
    Programming standards and code reviews should sort this out. Inconsistent comments probably aren't that big a deal in the grand scheme of things but if they can't do that constantly what else are they up to.
  • 4
    Wait what?

    Which language would support ALL of the following comment syntax? O__0

    // ...
    /* ... */
    # ...

    Code looks like PHP or something. Which I had no idea also supported #-comments
  • 1
    @theImposter it is true. But you can find this kind of problems absolutely everywhere, not only in comments. Everyday is a new adventure, discovering new ways and mostly badly written things.
    At least, it works...
  • 1
  • 2
    at least he comments
  • 1
    @corscheid in PHP, // and # denote one-line comments

    /*
    ...
    */ is supposed to be used for block comments and (in theory) using it for line comments wastes CPU time because it takes slightly longer to parse.
  • 0
    @hrombach true, I knew about block comments with /**/, I was saying I had no idea that

    # this can be 1-line comment in PHP
    // This is how I thought it must be
  • 1
    @corscheid C++ has the same three types and I think many other languages inherited them too.
  • 0
    I always associated comment syntax like this:

    // AND /**/
    for languages like C, C++, Java, PHP..

    #
    For languages like Perl, Python, Bash..

    Despite the fact that # is technically acceptable for comments in PHP, I still don't feel right using it. // Works just as well and seems more stylistically preferred/'correct'
  • 1
    @corscheid I agree actually, I don't use # comments in PHP code either. And whenever I get a PR that has # comments I usually change them to // before I merge. 😆
  • 5
    @hrombach Pretty sure PHP is the wrong language if you have to care about how fast the comments are being parsed
  • 1
    @Kimmax firstly: not so true anymore since PHP 7
    Secondly: that's why I added "in theory"
  • 0
    @lucasgrelaud It is consistent with the code for example, in spanish:

    if ( persona.Nombre.esValido ) {
    guardar(persona);
    }

    It is inconsistent, besides a non-spanish speaker wouldn't understand it.
  • 0
    @lucasgrelaud exactly my point
Add Comment