I've developed software in many languages for about 10 years on projects large and small. I have yet to see anyone intentionally not use a space. In the scheme of things it doesn't really matter that much (after all, we all know those are comments and can read them), but I do think the no-space version looks similar to commented-out code and requires an extra millisecond of brain power to confirm it is a comment :-)
In the last 24 years, I've developed and maintained code professionally in C, C++, Pascal, BASIC, Java, Perl, Objective C, Bourne shell, bash, csh, tcsh, and assembly for 68K, PowerPC and x86. During this time, I've noticed a few things...
Comments with leading spaces are at least 1000 times more common than comments without spaces. Missing leading spaces in comments are most often typos due to hasty typing.
I can't remember ever seeing comments in sample code in a professional book or manual without the space.
The only professional developers I've known who routinely omit the leading space in comments grew up using a non-Western, ideographic writing system that doesn't use spaces.
I have never, ever seen an official company coding style that tells people to omit the leading space in comments.
So all in all, I would say the overwhelming evidence is that a space after the line-comment is preferred.
I mostly avoid having comments on the end of a line of code, because then the comments hang off the end and aren't as easy to parse when scanning. When I have a good reason, though, I like to use two spaces to separate code and comments (then one space after the comment marker). It just makes it easier for the eye...
Consider:
int top; // Index of the top of the stack.
versus:
int top; // Index of the top of the stack.
Subjectively, it seems like two spaces just makes it easier to split up what's code and what's not.
Well I have found the standard (according to Wikipedia) for commenting in Java. This is supposed to be "consistent with the Sun Microsystems Javadoc standards":
/** * Registers the text to display in a tool tip. The text * displays when the cursor lingers over the component. * @param text the string to display. If the text is null, * the tool tip is turned off for this component. */
So I'm starting to think the standard is a space. Also, all the other examples have a space.
Python's official style guide, PEP 8, is very clear about this issue:
Each line of a block comment starts with a # and a single space (unless it is indented text inside the comment).
and:
Inline comments should be separated by at least two spaces from the statement. They should start with a # and a single space.
This confirms everybody's anecdotal evidence, but I think this is the first answer to quote "some official or otherwise published coding standards" as requested;-).
I just came across StyleCop's SA1005 rule, which states:
A violation of this rule occurs when a single-line comment does not begin with a single space. For example:
private void Method1() { //A single-line comment. // A single-line comment. }
The comments should begin with a single space after the leading forward slashes:
private void Method1() { // A single-line comment. // A single-line comment. }
Since StyleCop is in one way or another a Microsoft product, I'd say this qualifies as an official coding standard with respect to spaces in line-comments.