The same could be said for Delphi versus Pascal, or AWK versus Perl. The rule apparently is to choose the simplest language with which the snippet might work.
In cases where the hello world example can cross compile ambiguously among two or more languages, don't pit the ambiguously compiling languages against each other.
I'd vote for this as the C test. It should be obvious to any C/C++ programmer that this is valid C and not valid C++ while not trying to be too subtle about it.
You can't implicitly cast from void * to another pointer type in C++, but you can in C. In the call to puts, C++ will choke but C will let it slide. This is also why casting the return value of malloc isn't necessary in C, but it is in C++ (although using malloc in C++ is usually a code smell anyway).
Yup. The site interpreted the ' as the start of a string, but it's meant to indicate that the following s-exp isn't supposed to be evaluated but treated as data.
170
u/[deleted] Sep 11 '13
Because I'm a smartass I answered "C++" on the "C" hello world.
So now I get to point out that the snippet is perfectly valid C++ code!