202

Python / Windows Batch, 25 bytes print"trick"#||echo.treat Everything after the # is interpreted as a comment by python, while the || is an OR in batch, saying that as the previous command failed, execute this one. I also like the use of an OR as it almost reads "trick or treat" :)


164

A Brief History of 2D Programming Languages: 16 (+2) years v19977/2{@{{4{\_______>/02&&&#???? * P+++++1P1P-1P+1E * * \'\02'oo100@n590@n; * * * >"8991",,,;5-;,@ * * ...


158

Whitespace / Starry, 135 bytes Here's to a clear night sky on Halloween! + + + + + + * + +* + * + * + + +* + +* + . + . + +* + +* . . . Note that whitespace on empty lines may not be preserved if you copy from the above code Whitespace outputs "TRICK". Try it Online! Starry ...


151

2sable / pl, 8 bytes 0000000: 74 72 65 61 74 93 d0 cb treat... Both programs have been tested locally with the same 8 byte file, so this is a proper polyglot. 2sable: trick This is the program in code page 1252. treat“ÐË Try it online! pl: treat This is the program in code page 437. treatô╨╦ Try it online! How it works 2sable: ...


148

15 languages, 68 66 65 bytes / 15^3 = 0.019... Retina, Starry, Prelude, ETA, Axo, Labyrinth, Hexagony, Foo, Brian & Chuck, Gol><>, evil, Whitespace, Fission, ><> and GolfScript. After a massive rewrite, I managed to fit in four more languages. The code contains the few tabs for Whitespace. Since Stack Exchange converts them to spaces, I've ...


142

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 ...


140

Linux ELF x86 / DOS .COM file, 73 bytes 00000000 7f 45 4c 46 01 00 00 00 1a 00 00 00 1a 00 43 05 |.ELF..........C.| 00000010 02 00 03 00 1a 00 43 05 1a 00 43 05 04 00 00 00 |......C...C.....| 00000020 eb 0c b4 09 ba 41 01 cd 21 c3 20 00 01 00 b2 05 |.....A..!. .....| 00000030 b9 3b 00 43 05 cd 80 2c 04 cd 80 74 72 69 63 6b |.;.C...,...trick| ...


133

Python 3.0 and Python 2, score 6 (12 bytes, 2 versions) print(3/2*2) Try it Online: Python 2 Python 3 Relies on the fact that Python 3+ uses float division by default, unlike Python 2, which uses floor division.


129

C + x86 assembly Not satisfied with a constant defined in the software of your language? Why not use a language that can access a constant value of PI right from your FPU hardware: #include <stdio.h> int main (int argc, char **argv) { double pi; __asm__("fldpi" : "=t" (pi)); printf("%g\n", 3 * 3 * pi); ...


115

15 years, Python Versions: 0.9.1, 2.0.0, 2.2.0, 2.2.2, 2.5.0, 2.5.1, 3.0.0, 3.1.0, 3.1.3, 3.2.1, 3.3.0, 3.3.3, 3.4.0, 3.5.0 and 3.6.0a4. Versions not linked can be found on the downloads page. The release date of 0.9.1 can be found here. Unfortunately I had to skip a large bunch of years due to missing old versions and compilation problems on my computer. ...


104

evil / ZOMBIE, 109 bytes Another spooky answer ! xf is a vampire summon task f say "trick" stumble say "jzuueeueeawuuwzaeeaeeaeawuuuuwzuueeueeaw" animate bind The ZOMBIE code defines a vampire named xf whose only task f is activated at instanciation and will output trick once before being deactivated by stumble. The other say call is ...


96

30 languages, 248 bytes, \$\frac {248} {30^3} = 0.009185\$ #|#?15g,@ kkmNmSaIeoe99+{\#/-;n@0ea #[9!@>.>.eeaww#-1@*"12" L #{ ### #`{ 25 print(4^2 +7)/2 """ Jo is here. $'main'MoO OOM 7 >Jo, 30 >X Jo f::=~27 ::=]##}#(prin 29) print (7/6*24)###;alert 2#-[>+<-----]>-.|#(write(if(= 1/5 .2)26 3))""" Edit: Beatnik removed ...


95

Python / Perl, 28 bytes print([]and"trick"or"treat") Explanation Since [] is an ArrayRef in Perl, it's truthy, but it's an empty array in Python, therefore falsy.


92

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 ...


91

C and C++, 68 65 bytes #include<math.h> float f(float n){auto p=.5;return pow(n,2-p*3);} Original answer: #include<math.h> float f(float n){return pow(n,sizeof('-')-1?2:.5);} For both versions, C produces n^2 and C++ produces sqrt(n).


88

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]+'!') ...


85

Python 2/Python 3, 92 Uses the "standard" Python version check (integer vs. float division). print("This program wasn't written in Python %d, it was built for Python %d!"%(3/2*2,4-3/2))


84

Note: If you see this first, you might want to sort by oldest 17. Julia (128 bytes) #v`16 "<" 6/b0\ .q@#;n4"14"" #>3N9@15o|R"12"*^ #=| print((1/2and 9 or 13)-(0and+4)^1<<65>>62);# =#;print(17) #gg99ddi2` |1|1+6 There are two ESCs on the last line, one before the first g and one after the 2. This could be golfed more, but things got messy ...


80

Python 2 / Python 3 - 128 n=int(input()) s="Isf tthhies ,b oIs sq ufiitn.d" print(["not "*any([n%a<1for a in range(2,n)])+"prime",s[::2]+s[1::2]][1/2>0]) Identifies prime numbers with Python 2, get's you into trouble with Python 3. Bonus __help__ = """In the forloop I'm setting the values i to n. To be a "notPrimes", it's n % i == 0 if: 1 < i, ...


78

Python, bash, C, J, PHP and Python3 import subprocess p = subprocess.Popen(""" echo ' #define _USE_MATH_DEFINES #include <stdio.h> #include <math.h> int main(int pi) { if (pi == 1) printf("%.5f", M_PI); if (pi == 2) printf("o. 1"); if (pi == 3) printf("<?php printf(\\"%%.5f\\", pi()); ?>"); if (pi == 4) printf("import ...


68

Bonus submission (C / C++11) Primality testing using the usual naive method is so mainstream. That's why I have invented a brand-new randomized naive method! This test is as follows: Choose any integer d at random. It must not be smaller than 2 and larger than a bit more than sqrt(n). If d is a divisor of n, output not prime. If we made this test 20sqrt(n) ...


66

Java, 189 bytes, 10 versions, score = 18.9 Supported versions: 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8 and 9 Note that most versions after 10 didn't include any new classes in java.util, so no further improvement is expected. (For previous scores, check the history!) Object v(){int i=0;try{for(String[]s={"Locale","Map","Timer&...


63

16 languages, 1363 bytes #define ip"MemuL tulaS",,,,,,,,,,"!",@++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.@,kc"Kaixo Mundua!"v#! #define print(A,B,C)main(){printf("Helo Byd!");}//ss ...


60

Python, brainfuck and JavaScript, 103 99 bytes Yay under 100 bytes! 0,[.5,];p=["rock","scissors","paper"] 1//1;lambda x:p[p.index(x)-1];""" x=>p[-~p.indexOf(x)%3]//""" In Python, this defines a function which beats the input, in brainfuck it's just a simple cat program, and in JavaScript it loses. Here's a version which gives the functions a name, f, ...


58

Fishing/><> 233 217 bytes v++C-CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC+CCCCCCC-CCCCCCCCCCCCCCCCCCC+CCCCCC \ "This program wasn't written in ""><>" ", it was built for Fishing!" >r!`ol?!;32. Fishing ><>!`N Fishing is a language based on a fisherman walking around catching fish. To make a program ...


57

C, Perl, PHP, Python, Ruby Update: I've put together a jsfiddle that helps visualize the path through the code for each of the five languages: http://jsfiddle.net/wK6bD/4/embedded/result/ An alternative version, that removes all comments, and compresses all insignificant strings, regex and replacement patterns: http://jsfiddle.net/wK6bD/5/embedded/result/ ...


57

23/Malbolge, 5688 bytes bCBA@?>=<;:987 6543210/.-,+*) ('&%$#"!~}|{zy ...


56

Lua/C - 182 164 bytes #if 0 print"This program wasn't written in Lua, it was built for C!"--[[ #endif main(){printf("This program wasn't written in C, it was built for Lua!\n");}/*]]--*/ Takes advantage of the feature where Lua treats a hash mark on the first line as a comment to allow for Unix shebangs. Otherwise wraps the other language's comments in ...


55

JavaScript/Haskell, 158 bytes 147 bytes General idea: sneak each one's comment syntax into the other. In one line: u="This program wasn't written in ";v=", it was built for ";j="JavaScript";h="Haskell";{-console.log(u+j+v+h+"!")}//-}main=putStrLn$u++h++v++j++"!" What this looks like to Haskell: -- ...


55

23. Hexagony, 186 bytes Sorry if this messes up plans... #v`16/"<"6/b.q@"(::)::: (22)S#;n4"14" #>3N6@15o|> ^*ttt*~++~~~% #=~nJ<R"12"; #[ print((1/2and 9 or 13)-(0and+4)^1<<65>>62)#46(89999+++++!)=#print(17)#0\32=""<0]#echo 21 #8␛dggi2␛` |1|6 ␛ is used to represent a literal ESC ...


Only top voted, non community-wiki answers of a minimum length are eligible