I'm not the language you're looking for!
C89/C99, 171 152 136 114 111 107 105 bytes
Thanks at @Hurkyls, @Qwertiys, @jimmy23013 and @MD XF for your hints.
golfed version:
c;main(){c=-4.5//**/
-4.5;printf("This program wasn't written in C%d, it was built for C%d!",90-c,98+c);}
ungolfed version:
c;
main()
{
c = -4.5//**/
-4.5;
printf("This program wasn't written in C%d, it was built for C%d!",90-c,98+c);
}
Little description:
C versions previous C99 just had the multiline comment like this:
/*foo*/
with C99 the single line comment was introduced. like this:
//foo
so if you compile a line like this:
c =-4.5//**/
-4.5;
the for the c99 compiler compiling-related code would be:
c = -4.5 -4.5;
while the for a c89 compiler relevant code would be:
(as the first /
isn't part of a comment and therfor treat as operator)
c = -4.5 / -4.5;
Foo/CJam, 70 bytes
"This program wasn't written in ""Foo"", it was built for ""CJam"\@"!"
In Foo, as many have found out, it just prints everything in the double quotes, and ignores most other character or does something that doesn't affect the output in most cases. In short, \@
does nothing and the strings are all printed as-is.
In CJam, \
swaps the top two items, and @
moves the 3rd item to the top, which arrange the strings into the right order. And after the program ends, everything left in the stack is automatically printed.
JavaScript/Ruby, 170 bytes
Might be 2.0 only, doesn't appear to work in at least 2.1.5... Edit: Updates as per advice from @Jordan hopefully it works in a few more versions now!
a='1';c=console=console||eval('def c.log s;$><<s end;c');c.log("This program wasn't written in "+(d=['JavaScript','Ruby'])[b= ~(a=~/1/)]+', it was built for '+d[b+1]+'!')
Abuses the ~
operator in that Ruby will treat =~
as a regex match returning the position of the first match in the string (0
), but JavaScript will treat it as =
~/1/
which is -1
(since /1/
is converted to NaN
for numeric operations, which has 0
value).