But stepping back even further why are we talking about this, it’s just a fun exercise against a hello world. The only thing being solved for is fun.
The argument for including it even so is that if you think of the underlying challenge as "fooling sloc" and that the original challenge phrased it in terms of "code" simply because sloc mostly deals with code, but as it happens, it also tries to count HTML even though it isn't (necessarily) code, then it's reasonable to include.
I have to qualify HTML qua HTML because once you include Javascript, it goes from trivially not code to trivially being code, or at least capable of carrying code.
But it is important not to blur the lines between a document format and code. There are real and important differences. HTML qua HTML is not a programming language.
Edit: Oh, the solution to the other debate going on is that programming languages ALWAYS execute in the context of a virtual machine of some sort, or in the case of assembly, a real machine (at least in potential). The distinguishing characteristics of a programming language is something along the lines of being at least one of "Turing complete" and "able to read input, change behavior based on it, and write output", although I'm not getting too far down the weeds on that one on purpose. You can't use "whether or not they need a specialized execution environment to function" as a distinction for whether or not something is a programming language, because they all do.
Hello world
Run it with `cat`. ;)It is slightly disappointing that all the solutions I see for various languages are just different ways to trigger pretty much the same multi-line comment parsing problem in sloc.
Most of the top solutions seem to take advantage of bugs in the way sloc tries to parse commented lines. e.g. many are:
/**/<do_something>/**/
And I'm surprised I don't see a related bug issue in the git repo: https://github.com/flosse/sloc/issuesStill this is a fun read. I'm curious to see what other tricks are out there.
/**/-->/*
console.log('Hello World!');
console.log('You can add as much as you want');
--> */This is still one line of code.
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.
Using an arbitrary metric that is not commensurate with reality is inaccurate. The point is that the title is clickbait for what amounts to a singularly exploited bug in a tool, not what was purported. Literally the same misinformation goes on in the political space all the time, where it is lamented. If it's related to quirky coding eventualities, it's lauded.
That's the point.
http://www.ioccc.org/1994/smr.hint
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.
This sort of thing actually does have real-world applicability though: eg security issues caused by different parsing by a validation layer versus the actual execution.
> //^H^HHello, World!
> After the forward-slashes for the comment, there are two backspace characters which erase them from the output.
Coolest solution in my opinion.
Quote: "NPM's sloc is a moderately popular tool for counting source lines of code in a file".
Never heard of it, personally I use LocMetrics. And it detects correctly that these are sources.
print*,"Hello, World"
end
This is shorter than the way a Hello World program in Java, C, or C++ would be written.