182
\$\begingroup\$

Isn't it annoying when you find a piece of code and you don't know what language it was written in? This challenge attempts to somewhat solve this.

Challenge

You will have to write a program that when run in two different languages, will output the string:

This program wasn't written in <language program compiled/interpreted in>, it was built for <other language the program can be run in>!

  • In the output, language names should have official capitalization. eg: CJam, C++

  • Neither program should take any input from the user.

  • When run in both languages, output should be to stdout or equivalent.

  • There should be no output to stderr in either program.

  • You may use comments in either language.

  • Two different versions of the same language count as different languages.

    • If this is done, the program should output the major version number, and if running on two different minor versions, should report the minor version also.

    • You should not use prebuilt version functions (this includes variables that have already been evaluated at runtime).

Example output:

Perl and Ruby:

  • Perl: This program wasn't written in Perl, it was built for Ruby!

  • Ruby: This program wasn't written in Ruby, it was built for Perl!

Python and C:

  • Python: This program wasn't written in Python, it was built for C!

  • C: This program wasn't written in C, it was built for Python!

Python 2 and Python 3:

  • Python 2: This program wasn't written in Python 2, it was built for Python 3!

  • Python 3: This program wasn't written in Python 3, it was built for Python 2!

Python 2.4 and Python 2.7:

  • Python 2.4: This program wasn't written in Python 2.4, it was built for Python 2.7!

  • Python 2.7: This program wasn't written in Python 2.7, it was built for Python 2.4!

This is code golf so the shortest code in bytes wins.

\$\endgroup\$
  • 2
    \$\begingroup\$ "Two different versions of the same language count as different languages." So tricking like with C pre and past 99 comments is valid? easy ^^ \$\endgroup\$ – Zaibis Sep 3 '15 at 13:54
  • 1
    \$\begingroup\$ Added it, it feels paradoxical but fits to your rules. \$\endgroup\$ – Zaibis Sep 3 '15 at 14:48
  • 1
    \$\begingroup\$ No one's doing a Whitespace/Python polyglot? \$\endgroup\$ – Not that Charles Sep 4 '15 at 15:22
  • \$\begingroup\$ nevermind. Saw the 23 implementation \$\endgroup\$ – Not that Charles Sep 4 '15 at 15:26
  • \$\begingroup\$ Does relying on the program to be run with a certain interpreter count as input? that is, switching on argv[0]? \$\endgroup\$ – cat Oct 28 '16 at 12:10

110 Answers 110

3
\$\begingroup\$

Perl5 / JavaScript

y= 1, split = function(){return ''; " =; #"}
print ( "This program wasn't written for", split( //, " Perl, it was built for JavaScript!") );
y), "\bJavascript, it was built for Perl!");
x=split();
\$\endgroup\$
3
\$\begingroup\$

Commodore 64 Basic/QBasic, 169

In order to get the capitalization right, you'll need to switch your Commodore 64 to character set 2 by pressing <SHIFT> + <C=>.

1 c$ = "QBasic": d$ = "Commodore 64 Basic"
2 if(fre(0) < 0) then e$ = c$:c$ = d$:d$ = e$
3 print "This program wasn't written in "; c$; ", it was built for "; d$; "!"

In Microsoft dialects of Basic, the "fre()" function returns the available free space. Now, QBasic can run on surprisingly low-memory IBM compatibles, so you can't reliably tell QBasic and Commodore Basic apart just by the amount of free space. However, the Commodore Basic version returns a signed 16-bit integer where the QBasic version returns a 32-bit one -- and since the Commodore 64 has more than 32767 bytes free with just a small program, while QBasic, as a real-mode program, will never see more than 1048576 bytes, "fre(0)" will always return a negative number on a C64 and a positive number under QBasic.

Commodore Basic's 80-character-per-line limit and QBasic's autoformatter interact in annoying ways here. For example, I found a neat trick involving an if-then-else statement (invalid in Commodore Basic, but an "end" statement keeps the Commodore interpreter from encountering the invalid bits) -- except that the resulting line is 86 characters long after QBasic's autoformatter gets through adding whitespace. Likewise, line 1 can't be combined with line 2: the result would be 88 characters long after autoformatting.

\$\endgroup\$
  • \$\begingroup\$ Why does QBasic autoformatting matter? \$\endgroup\$ – CalculatorFeline Mar 7 '16 at 0:42
  • \$\begingroup\$ @CatsAreFluffy, QBasic has a combined editor/interpreter. If you type in or load a program with what it considers improper whitespace, it will insert the whitespace for you. \$\endgroup\$ – Mark Mar 7 '16 at 19:00
  • \$\begingroup\$ So? If you paste an improperly formatted program in, it'll be autoformatted. I just don't get why the pasted-in program has to be formatted properly. If people had to care about whitespace added by the IDE, I'd have to fix every single one of my answers. (Well actually, I think 3 of them are fine, but why is ths so long) \$\endgroup\$ – CalculatorFeline Mar 7 '16 at 19:08
  • \$\begingroup\$ I'm pretty sure there's a thing called QB64 which allows disabling autoformatting. \$\endgroup\$ – CalculatorFeline Apr 2 '16 at 19:56
3
\$\begingroup\$

Scala/Groovy, 128 bytes

Adapting my Java/Groovy snippet for Scala instead lets us get rid of a lot of Java boilerplate:

def Scala=" Groovy"
def Groovy=" Scala"
print("This program wasn't written in$Scala, it was built for$Groovy!".replace('$',' '))
\$\endgroup\$
  • \$\begingroup\$ Worth pointing out that this isn't scala "proper", but Scala script. A full scala program does still need a main entry point. \$\endgroup\$ – Cubic Nov 1 '15 at 12:35
3
\$\begingroup\$

jq / Python 3, 151

"\("; print('This program wasn\u0027t written in Python 3, it was built for jq!')#" | "This program wasn't written in jq, it was built for Python 3!")"

The problem gets a little bit complicated when one of the languages does not have a comment syntax.

Run with jq -n -r or with python3.

\$\endgroup\$
3
\$\begingroup\$

JavaScript / JavaScript ES6, 110 bytes

"This program wasn't written in "+((b=[a="JavaScript",c=a+" ES6"].keys)?c:a)+", it was built for "+(b?a:c)+"!"

Checks for the existence of .keys. Most browsers these days are ES6 so I recommend installing a separate engine such as Rhino if you really want to test this.

\$\endgroup\$
3
\$\begingroup\$

CoffeeScript+CJam

Uses CoffeeScript's ### and CJam's e#

e###
"This program wasn't written in CJam, it was built for CoffeeScript!"
e### ###
e### alert "This program wasn't written in CoffeeScript, it was built for CJam!"

How CJam sees it

e# comment
push "This program wasn't written in CJam, it was built for CoffeeScript!"
e# comment
e# comment

How Coffee sees it:

e
###
comment
###
###
comment
###
alert("This program wasn't written in CoffeeScript, it was built for CJam!")
\$\endgroup\$
3
\$\begingroup\$

Javascript ES6, ES5 131 127 bytes

I just thought I post this for fun

"This program wasn't written in "+((c=eval("try{let a=0}catch(e){1}"))?"ES5":"ES6")+", it was built for "+(c?"ES6":"ES5")+"!"

The main part of the code is this:

try{d.join``;0}catch(e){1}

If the version of javascript is ES5, this returns 1, because d.join`` throws an error.

\$\endgroup\$
3
\$\begingroup\$

Crystal / Ruby, 117 bytes

c="Crystal";r="Ruby";x='a'!="a";puts "This program wasn't written in "+(x ?c: r)+", it was built for "+(x ?r: c)+"!"

Crystal is heavily inspired by Ruby, so not much trickery is needed here except a way to detect which language is being used. This snippet abuses a key difference in both languages: Crystal has a character type (Char), while Ruby only has a String.

In Crystal, 'a' is a character literal, while "a" is a string literal. In Ruby, both are string literals. The code tests if 'a'=="a" (true in Ruby, false in Crystal) then uses that to decide whether to print Crystal or Ruby.

\$\endgroup\$
3
\$\begingroup\$

JavaScript / Python3, 119 bytes

i=1//2
d=['print','console.log']
s=['python','js']
eval(d[i])('this program is not '+s[i]+', it was built for '+s[1-i])

Tested on Node.js v6.x and Python 3.5.1

The trick was to use Python's "floor division" operator which is the same as JavaScript's line comment //. This is how we swap 0 and 1 for i depending on the language.

This won't work on python2 because print was not a function until python3 and therefore cannot be evaluated using eval. It should work for almost any JavaScript VM.

Edit

Golfed 7 bytes by removing j variable and using s[1-i] instead of s[j].

\$\endgroup\$
  • 1
    \$\begingroup\$ You could remove the j= line and use eval(d[i])('this program is not '+s[i]+', it was built for '+s[1-i]), for a saving of 7 bytes :) \$\endgroup\$ – ETHproductions Nov 10 '16 at 17:38
  • \$\begingroup\$ @ETHproductions Thanks! That is clever! \$\endgroup\$ – styfle Nov 10 '16 at 19:15
3
\$\begingroup\$

Emoji/Emojicode, 170 bytes

👴💬This program wasn't written in Emoji, it was built for Emojicode!💬➡
🏁🍇😀🔤This program wasn't written in Emojicode, it was built for Emoji!🔤🍉

Try Emoji online!
Try Emojicode online!

\$\endgroup\$
3
\$\begingroup\$

Excel / Google Sheets, 128 126 Bytes

Anonymous worksheet function that takes no input and outputs to the calling cell.

="This program wasn't written in "&IfError(M("Google Sheets, it was built for Excel"),"Excel, it was built for Google Sheets")

Or

="This program wasn't written in "&Substitute(IfError(M("Google Sheets1Excel"),"Excel1Google Sheets"),1,", it was built for ")
\$\endgroup\$
3
\$\begingroup\$

Ruby/Crystal, 149 140 bytes

v = 1e10.class == Float ? ["Ruby", "Crystal"] : ["Crystal", "Ruby"]
puts "This program wasn't written in #{v[0]}, it was built for #{v[1]}!"

Crystal is a language similar to Ruby, but it is compiled. In Crystal, the type of the literal 1e10 is Float64, while in Ruby it is Float. Probably can be golfed some.

\$\endgroup\$
2
\$\begingroup\$

Brainfuck/Javascript 936 chars

/*[-]>[-]>++++[-<++++++++>]<>[-]>++++++[-<++++++++++>]<+++++>[-]>++++++++++[-<++++++++++>]<---<<<>>+++++++++++++++++++.>+++++++.+.++++++++++.<<.>>---.++.---.--------.+++++++++++.-----------------.++++++++++++.<<.>>++++++++++.----------------------.++++++++++++++++++.-----.<<+++++++.>>++++++.<<-------.>>+++.-----.---------.+++++++++++..---------------.+++++++++.<<.>>-----.+++++.<<.>------------------.>++++.-----------------.++++++++.+++++.--------.+++++++++++++++.------------------.++++++++.<<++++++++++++.------------.>>--.+++++++++++.<<.>>+++.----------------------.++++++++++++++++++.<<.>>-----------------.+++++++++++++++++++.------------.+++.++++++++.<<.>>--------------.+++++++++.+++.<<.>++++++++.>-----------------.+++++++++++++++++++++.---------------------.++++++++++++++++++.----------------.+++++++++++++++.---------.+++++++.++++.<<+*/console.log("This program wasn't written in Javascript, it was built for Brainfuck!");

This is just Brainfuck Code in a Comment Javascript will ignore, but Javacript Code that Brainfuck will ignore. So it is perfect. :D

\$\endgroup\$
  • 1
    \$\begingroup\$ Outputs 'This program wasn't written in Brainfuck, it was built for Javascript!!' when executed in BF. Probably because you have an extra . in console.log. \$\endgroup\$ – Blue Sep 3 '15 at 16:41
  • 1
    \$\begingroup\$ I think you can get around the issue @muddyfish mentioned by just removing the . before the */, which is a byte shorter anyhow. \$\endgroup\$ – kirbyfan64sos Sep 3 '15 at 17:16
  • \$\begingroup\$ I know, I was just waiting for the OP to do it themselves. \$\endgroup\$ – Blue Sep 3 '15 at 17:26
  • \$\begingroup\$ fixed the little bug :D \$\endgroup\$ – timmyRS Sep 3 '15 at 17:35
  • 1
    \$\begingroup\$ You have another bug, the comma in your JS string will be executed, prompting for input. This probably isn't allowed, so you should use a hex escape sequence. \$\endgroup\$ – mbomb007 Sep 4 '15 at 17:29
2
\$\begingroup\$

MySQL (5) / Perl (5), 144 bytes

-- $_;print"This program wasn't written in Perl, it was built for MySQL!";
select"This program wasn't written in MySQL, it was built for Perl!";

h/t

\$\endgroup\$
2
\$\begingroup\$

Python/Lisp 158 chars

""""(princ "This program wasn't written in Lisp, it was built for Python!")""";print 'This program wasn\'t written in Python, it was built for Lisp!';""" " """

\$\endgroup\$
2
\$\begingroup\$

BASH/JavaScript, 171 164 bytes

/* 2>&-;echo This program wasn\'t written in BASH, it was built for JavaScript\!;#*/console.log("This program wasn't written in JavaScript, it was built for BASH!")

First post to PPCG!

\$\endgroup\$
2
\$\begingroup\$

Shells/Emacs Lisp (157 bytes)

:; echo "This program was not written for shells, it was built for Emacs!"; exit
(message "This program was not written in Emacs, it was built for shells!")

: is a nop in both languages. ; is a comment in Emacs Lisp and a delimiter in many shells. :; is used as a startup hack for Emacs Lisp scripts, if you need to pass more than one argument to Emacs itself by the command line.

\$\endgroup\$
2
\$\begingroup\$

Fuzzy Octo Guacamole and Jolf, 112 bytes

(non-competing, FOG is newer than the challenge)

a++++"This program wasn\'t written in ""Jolf"", it was built for ""Fuzzy Octo Guacamole""!"//__ssss.Z_sssts''.jX

Prints This program wasn't written in Fuzzy Octo Guacamole, it was built for Jolf! in FOG, and This program wasn't written in Jolf, it was built for Fuzzy Octo Guacamole! in Jolf.

This was fun.

FOG side is complicated, because there is no command to swap the top 2 items.

FOG Explanation:

a++++"This program wasn\'t written in ""Jolf"", it was built for ""Fuzzy Octo Guacamole""!"//__ssss.Z_sssts''.j_;

The a adds the 2 top items, adding 0 and 0 and pushing the result, 0. Does nothing.

The + increment, so at the end the stack has [5].

The strings just push those to the stack.

The // does nothing but push '/' to the stack twice, but in Jolf it is a comment.

The __ pops the 2 '/'s we pushed, just removing them.

The ssss moves the top 4 strings, the parts that need rearranging, to the other stack. They are now in reverse order also.

The . switches stacks.

Z reverses the stack.

_ pops the '!', so we get it out of the way. It is set to the temp var.

Then we move the 'Fuzzy Octo Guacamole', the 'was built for', and the 'Jolf' to the other stack in that order. That is the 3 s.

t pushes the temp var, which is still the '!' and then the next s puts it on the other stack.

We have all the strings, but how to print?

We first push '', the empty string.

Then we switch stacks with ..

Then we use j. This is join. It pushes the current stack as a string with the top of the inactive stack as a separator.

This is equivalent to the python ''.join(stack).

Then the X pops and prints, and we are done!

Side note: The poor 5 is left on the stack, all by himself. ;_;

Jolf Explanation:

Much simpler.

Jolf is prefix, so the a gets the alert function ready.

The + all concatenate the strings, so they just get stuck together.

So this just prints as-is, no need to rearrange. And the // is a comment, and hides the FOG side code.


Thanks to @CᴏɴᴏʀO'Bʀɪᴇɴ for making Jolf, a wonderful language to use.

Aʟsᴏ, ғʀᴇᴇ ᴘʟᴜɢ ғᴏʀ sᴍᴀʟʟ ᴄᴀᴘs!!!

\$\endgroup\$
  • \$\begingroup\$ Does FOG's interpreter complain with non-ASCII? If so, you could use Ά in place of pairs of +s (so s/++/Ά/g). \$\endgroup\$ – Conor O'Brien Apr 22 '16 at 3:30
  • \$\begingroup\$ @CᴏɴᴏʀO'Bʀɪᴇɴ no, but it will push the letters to the stack as strings. It ends up longer. \$\endgroup\$ – Rɪᴋᴇʀ Apr 22 '16 at 15:10
2
\$\begingroup\$

Python 2/C, 179 bytes

#if/*
"""*/1
main(){char*//"""
s="This program wasn't written in %s, it was built for %s!"
#if/*
"""*/1
;printf(s,"C","Python");}
#endif
#endif/*"""
print s%("Python","C")
#*/

Syntax-highlighted version:

Python:

#if/*
"""*/1
main(){char*//"""
s="This program wasn't written in %s, it was built for %s!"
#if/*
"""*/1
;printf(s,"C","Python");}
#endif
#endif/*"""
print s%("Python","C")
#*/

C (poor highlighting, sorry)

#if/*
"""*/1
main(){char*//"""
s="This program wasn't written in %s, it was built for %s!"
#if/*
"""*/1
;printf(s,"C","Python");}
#endif
#endif/*"""
print s%("Python","C")
#*/
\$\endgroup\$
2
\$\begingroup\$

C and ecpp, 140 bytes

#ifdef ECPP
#replace "C" "ECPP"
#replace "ECPP" "C"
#endif
main(){puts("This program wasn't written in ""C"", it was built for ""ECPP""!");}

Try ecpp online!
Try C online!

The #ifdef and #endif avoid syntax errors in C. #replace "C" "ECPP" replaces the string "C" with the string "ECPP", and #replace "ECPP" "C" replaces the string "ECPP" with "C".

This takes advantage of C's automatic string concatenation capabilities.

\$\endgroup\$
2
\$\begingroup\$

Python/Clojure, 166 Bytes

#_()(println"This program wasn't written in Clojure, it was built for Python!")(comment
print("This program wasn't written in Python, it was built for Clojure!")#_())

Clojure – Try it online!

Python 3 – Try It Online!

Has room for improvement, not even a clever answer but I wanted to try it anyway.

Relies on the fact that #_() is an (unintentional?) reader no-op in Clojure (#_ will skip the next form, () is an empty form) yet starts a comment in python as python uses # for commenting.

\$\endgroup\$
  • \$\begingroup\$ Hello and welcome to PPCG. Would it be possible to provide two links to two online interpreters for ease fo verification? \$\endgroup\$ – Jonathan Frech Mar 5 at 9:25
  • \$\begingroup\$ Welcome to PPCG. I added some links to Try It Online (TIO), which is what we commonly use for easy demonstration. \$\endgroup\$ – Kirill L. Mar 5 at 10:21
  • \$\begingroup\$ @KirillL. Thanks, I forgot to add them. \$\endgroup\$ – nihilazo Mar 5 at 14:06
  • \$\begingroup\$ @nihilazo "Ignore next form (#_) The form following #_ is completely skipped by the reader." - from the official docs \$\endgroup\$ – ASCII-only Mar 7 at 5:49
  • \$\begingroup\$ 156? \$\endgroup\$ – ASCII-only Mar 7 at 5:53
2
\$\begingroup\$

Haskell/Standard ML (MLton), 175 bytes

Explanation

Haskell's line comment marker, --, is a valid name for a Standard ML (SML) identifier. SML's function and value introduction keywords, fun and val, are valid Haskell identifiers. So we define -- in SML to be the identity function (which arbitrarily defines fun in Haskell to be id). We define i in SML to be the beginning of the output string, which makes val in Haskell a constant function evaluating to that string. Then we can hide our main Haskell program in an ML comment, and hide the ML comment delimiters from Haskell using --.

Haskell, 175 bytes

fun--id
 =id;
val i="This program wasn't written in ";--print(i^"Standard ML, it was built for Haskell!");(*
main=putStrLn$val 1++"Haskell, it was built for Standard ML!"-- *)

Try it online!

Standard ML (MLton), 175 bytes

fun--id
 =id;
val i="This program wasn't written in ";--print(i^"Standard ML, it was built for Haskell!");(*
main=putStrLn$val 1++"Haskell, it was built for Standard ML!"-- *)

Try it online!

\$\endgroup\$
  • \$\begingroup\$ "Then we can hide our main Haskell program in an ML comment that we hide from Haskell using --."? \$\endgroup\$ – ASCII-only Mar 11 at 3:34
  • \$\begingroup\$ @ASCII-only, is that better? \$\endgroup\$ – dfeuer Mar 12 at 2:14
  • 3
    \$\begingroup\$ It's easier to use @ to hide (* from Haskell. 159 bytes \$\endgroup\$ – Ørjan Johansen Mar 12 at 3:53
  • \$\begingroup\$ @ØrjanJohansen, oh, that's very clever. I would never have thought to use an as-pattern like that, since it's otherwise so useless! \$\endgroup\$ – dfeuer Mar 12 at 4:00
2
\$\begingroup\$

Brainfuck/PHP 812 chars

<?php/*[-]>[-]>++++[-<++++++++>]<>[-]>++++++[-<++++++++++>]<+++++>[-]>++++++++++[-<++++++++++>]<---<<<>>+++++++++++++++++++.>+++++++.+.++++++++++.<<.>>---.++.---.--------.+++++++++++.-----------------.++++++++++++.<<.>>++++++++++.----------------------.++++++++++++++++++.-----.<<+++++++.>>++++++.<<-------.>>+++.-----.---------.+++++++++++..---------------.+++++++++.<<.>>-----.+++++.<<.>------------------.>++++.-----------------.++++++++.+++++.--------.+++++++++++++++.------------------.++++++++.<<++++++++++++.------------.>>--.+++++++++++.<<.>>+++.----------------------.++++++++++++++++++.<<.>>-----------------.+++++++++++++++++++.------------.+++.++++++++.<<.>>--------------.+++++++++.+++.<<.>++++++++++++++.--------.++++++++.<+.*/echo "This program wasn't written in PHP, it was built for Brainfuck!";

This is just Brainfuck Code in a PHP Comment that is getting ignored, while Brainfuck will ignore the PHP.

\$\endgroup\$
2
\$\begingroup\$

sed, sed -E, 105 bytes

s/^/This program wasn't written in sed, it was built for sed -E!/
s/(.*)(,.*)( -E)(\(\)\(\)\(\))?/\1\3\2/

Try sed -E Try sed

The second line rearranges the -E only when -E is provided. The extra (\(\)... mess is to keep sed from erroring out from invalid match groups otherwise.

\$\endgroup\$
2
\$\begingroup\$

Whitespace and Malbolge, 1318 bytes

Did I just outgolf Dennis?

   D'`rq
   	 	 ">7<Y
   	    	kW8Ux
   		  	 	54-P>
   		  			=MLon
   		 		  %[k5F
   		 			h}UeA	
   		   	 b?,__
   		 		  )(r8Y
   		    	Xtsl2
   	  		 	Sonmf
   	     ,jLba
   			  	 f_%cE
   		 				[`Y}@
   		  		 ?[ZYR
   	     vVUTS
   			 	  RQJIm
   		 		  M/KDh
   		 	  	HA)E>
   			 	 	bB$@?
   		   	 >=6Z{
   	     3810/
   			  .R2r0		
   		    	/.'&+
   			 	$H('&		
   	     feB"!
   			 	  ~`_{z
   		 	  	s9qvu
   	     tsrk1
   	 		  ohmlk
   		  	 	jc)J`
   		   		&GF\a
   		    	ZY^]\
   			    UyYXW
   			  		9UNrR
   		  	 	QJOHM
   			 	  Fj-CH
   		 	  	AF?c=
   		 	   B;:9]
   	 	 			=<|{9
   	     2V0v4
   		 		-QP0/	 
   		 	  	o-&Jk
   	     )"!&}
   		 			 C#c!x
   		  	 	}|u;s
   			 	  xwpun
   			 	  4UTpo
   		 	  	ng-kj
   			  	 ihgfH
   			 			%]\[`
   	     Y^W{[
   			 	  Z<RvV
   	  			UT65Q
   		 			 JnNG/
   			  		Ei,HG
   		    	F?D=B
   			 			A@?8\
   	     <54Xy
   		 		 	x6/S3
   		    	210/o
   			  	 -&Jk#
   		  			(!~%$
   		 				{Ab~w
   			  	 |u;yx
   			    qYutm
   	     3kpon
   			  		g-kji
   		 	  	hgfH%
   		 	   ]\[`_
   	 	 	  ^WVzZ
<Rv9O
  TMRQP
 ImGLE
 DhHGF
	 	ED=%;
	_?>=<
  ;4z2V
 6/u-,
+O/.'
&J*j(
  	!~}C#
 c!x}|
u;\xq
votsl
2poQP
lkd*K
J`ed]\"ZY^W{UZYRWVOsSRKJOHGkKJIHA@dDCBA#">7[;{z870Tu3210).-,%$H"'&%$#"!~w=^]s9Zvo5Vlqpih.leM*u

Try it online! - Whitespace

Try it online! - Malbolge

\$\endgroup\$
1
\$\begingroup\$

Brainf***/Thue, 829 bytes

a::=~This program wasn't written in Thue, it was built for Brainf***!
::=
a++++++++[>+>++>+++>++++>+++++>++++++>+++++++>++++++++>+++++++++>++++++++++>+++++++++++>++++++++++++>+++++++++++++>++++++++++++++>+++++++++++++++>++++++++++++++++<<<<<<<<<<<<<<<<-]>>>>>>>>>>>----.++++>>.+.->+++.---<<<<<<<<<<.>>>>>>>>>>.++.---.+<-.+>++.--<<+.->>---.+++<<<<<<<<<<.>>>>>>>>>>>-.+<<<+.->>+++.-----.++<<<<<<<<<-.+>>>>>>>>>>----.++++<<<<<<<<<<<.>>>>>>>>>>>-.+<++.--<+.->>----.++++----.++++<<---.+++>--.++<<<<<<<<<<.>>>>>>>>>+.->--.++<<<<<<<<<<.>>>>++.-->>>>>>++.--<<+.->+.->--.++<--.++<<<<<<<<++.--++.--++.-->----.++++<<.>>>>>>>>>+.->>----.++++<<<<<<<<<<<.>>>>>>>>>>>-.+<<<+.->>+++.---<<<<<<<<<<.>>>>>>>>++.-->>>---.+++<<+.->----.++++>----.++++<<<<<<<<<<<.>>>>>>>>>--.++>-.+++.--<<<<<<<<<<.>>>>>>>----.++++>>.>>---.+++<<---.+++<<<<<<<<<+.-<<<<.
\$\endgroup\$
1
\$\begingroup\$

Python 2.7/><> - 160 bytes

#v"This program wasn't made for ><>, it was built for Python 2.7!"
#l
#0
#)
#?
#!
#;
#o
#!
print"This program wasn't made for Python 2.7, it was built for ><>!"

Pretty simple program. Python ignores the everything after a # cause it's a comment, while a # in ><> makes the pointer turn around.

\$\endgroup\$
1
\$\begingroup\$

Mouse-2002 / Python 2, 157 bytes

These two languages don't share much.

' ''"This program wasn"!'' "t written in Mouse, it was built for Python"33!'"!"#A;$A@$
print"This program wasn't written in Python, it was built for Mouse!"

How Mouse sees this:

' ''"This program wasn"!'' "t written in Mouse, it was built for Python"33!'"!"#A;$A@$


Broken down:

'               ~ push space charcode 
 ''             ~ push literal ' charcode

   "This program wasn"                              ~ print

!               ~ print TOS (a literal ' )
 ''             ~ push another literal ' 

   "t written in Mouse, it was built for Python"    ~ print

33!'            ~ push 33, then print that ASCII char (!)
    "!"         ~ print a newline
       #A;      ~ call a macro named A
          $A@   ~ define a bodiless macro named A
             $  ~ end the program; everything after will be pushed but not run

How Python sees this:

' ''"This program wasn"!'' "t written in Mouse, it was built for Python"33!'"!"#A;$A@$
print"This program wasn't written in Python, it was built for Mouse!"


Broken down:

# oh look, a bunch of pointless string literals and a comment!
' ''"This program wasn"!'' "t written in Mouse, it was built for Python"33!'"!"#A;$A@$
# oh look, a print statement!
print"This program wasn't written in Python, it was built for Mouse!"
\$\endgroup\$
1
\$\begingroup\$

Mouse-2002 / Factor, 192 bytes

These two languages also don't share much but this was fun.

IN: m
! '8!'"This program wasn"''!'"t written in Mouse, it was built for Factor"33!'"!"$
USING: io ;
: x ( -- ) "This program wasn't written in Factor, it was built for Mouse!" print ;
MAIN: x

How this looks to Mouse:

IN: m     ~  pointlessly assign 8 to N and push 12
!' 8 !'   ~  print the codepoint 12 (from m) and then a backspace
       "This program wasn"     ~ print this string
                         '' !' ~ push the codepoint for ', then print that 

"t written in Mouse, it was built for Factor" ~ print this string

33 !' "!" $  ~ push 33, then print that ASCII char, then print a newline, and end the program

How this looks to Factor:

! project folder name
IN: m
! comment!
! '8!'"This program wasn"''!'"t written in Mouse, it was built for Factor"33!'"!"$
! import statement
USING: io ;
! macro definition
: x ( -- ) "This program wasn't written in Factor, it was built for Mouse!" print ;
! program start
MAIN: x

This was actually quite a lot of work to get right.

\$\endgroup\$
1
\$\begingroup\$

Pyke/Foo, 71

"This program wasn't written in ""Foo"", it was built for ""Pyke"R3"!"s

Try it in Pyke!

Foo just prints everything in double quotes.

R3 rotates the top 3 items of the stack and s joins them together. It auto-prints the stack at the end

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.