In many languages, there are two ways to comment:

  • Open/close (often used for multi-line comments), i.e. /* my comment */
  • Single open (often used for end-of-line comments), i.e. // my comment

This may be trivial for you, but if your language does not rely on line breaks to mark the end of a code line, then it may actually make more sense to stick with the multi-line comment syntax as a best-practice.

Take JavaScript for example, which is often minified (and not always by a dedicated minifier):

var a = 'b'; // initialize a
var b = 'c';

Now, let's minify it to one line:

var a = 'b'; // initialize a var b = 'c';

Our second assignment statement is commented out.

While many folks out there make use of online services to minify JavaScript, this may not always be feasible (such as when using a home-brewed script to move your development site files to a live version, hence minifying JS code).

Leave a Reply

Your email address will not be published. Required fields are marked *