The title of the stackexchange discussion is a little misleading. It really is: '"Hello, World" in what sloc thinks is zero lines of source code'<p>Most of the top solutions seem to take advantage of bugs in the way sloc tries to parse commented lines. e.g. many are:<p><pre><code> /**/<do_something>/**/
</code></pre>
And I'm surprised I don't see a related bug issue in the git repo: <a href="https://github.com/flosse/sloc/issues" rel="nofollow">https://github.com/flosse/sloc/issues</a><p>Still this is a fun read. I'm curious to see what other tricks are out there.
> 17 chars<p>> //^H^HHello, World!<p>> After the forward-slashes for the comment, there are two backspace characters which erase them from the output.<p>Coolest solution in my opinion.
Slightly more entertaining:<p><a href="http://www.ioccc.org/1994/smr.hint" rel="nofollow">http://www.ioccc.org/1994/smr.hint</a><p>This is an IOCCC entry for the world's smallest quine, sizing up at 0 bytes of C. Some C compilers will compile an empty source file into a program which does nothing when executed, i.e. ouputs zero bytes, i.e. is a quine.
Oh I thought this was Jon Skeet's "hello world" in 1 byte, written in his custom "H" language. Of course he could have done it in 0 bytes but that would just be silly.
So, this is actually a bug in sloc, eh?<p>Quote: "NPM's sloc is a moderately popular tool for counting source lines of code in a file".<p>Never heard of it, personally I use LocMetrics. And it detects correctly that these are sources.
In Fortran, Hello World is just<p><pre><code> print*,"Hello, World"
end
</code></pre>
This is shorter than the way a Hello World program in Java, C, or C++ would be written.
The current winner seems to be HTML at 23 bytes, though I would argue it doesn't meet the requirements of the question, which call for a "full program".
> '''"""''';print("Hello, World!");"""'''"""<p>This is still one line of code.<p>It is a valid python program . This is because python will join strings that are adjacent strings (eg. "foo " "bar" is evaulated just like "foo bar") and while multiline strings are commonly used as comments they are evaluated as a string-literal rather than a comment.