A known fact is that Jon Skeet can code Perl and make it look like Java. In this challenge you will try to do something similar.


Write a piece of code of any length that can be executed without any errors/exceptions in two different languages. Your program can take inputs, give outputs, whatever it wants.

The code has to be executed with interpreters/compilers of your choice one after another (with basic settings, means you are not allowed to adjust the compiler/interpreter settings).

Note that the source code and any used sources (files, libs and so on) are not allowed to change during the execution of the script with the compilers/interpreters.

But which languages are "different"?

Two languages are different from each other if they are not the same language without looking at the version. Example: Python 3.5 is not different to Python 2.7.


The final score consists out of several aspects:

  • charScore: Take your code and then (max charScore is 95)...

    1. Look at every function and delete all arguments (in echo "Hello" "Hello" counts as an argument). So now only keywords and functions count. Example: System.out.println(1+1); becomes System.out.println();
    2. Make all strings to empty strings and all regex and literals empty. Example: "khffshiufahk" becomes "" and all regex (without string) gets deleted.
    3. Delete all comments. Example: //Jon Skeet would also do this becomes [nothing] _Definition of "comment": _ Anything that doesn't change the execution of the program (So you could simply leave them out and nothing would change).
    4. Delete all characters that are not unicode 32-126. Example: print(2²) becomes print(2)
    5. Count only the occurrences of the letters. Example: hiiiiiii-thhheeeree has the same score as hi-there (means score of 8)

    Here is a StackSnippet to do step 3 and 4 for you (report me if there is a bug):

    function calcScore() {
    	var onlyValidChars = "";
    	var code = document.getElementById("code").value;
    	for (i = 0; i < code.length; i++) {
    		if (code[i].charCodeAt(0)>=32 && code[i].charCodeAt(0)<=126) { //step 3
     	 		if (onlyValidChars.indexOf(code[i]) === -1) { //step 4
      			  onlyValidChars += code[i];
      return onlyValidChars.length;
    function showCalcScore() {
    	alert("Your charScore: "+calcScore());
        <textarea placeholder="Insert your code here." id="code"></textarea>
        <button type="button" onclick="showCalcScore();">calculate score</button>

  • +20 if your code is still executable in both languages now (after the charScore-changes)

  • +50 if running the code with the different interpreters does different things (eg order change, prints other things etc)
  • +15 if your languages are Perl and Java

The answer with the highest score wins.

EDIT: I don't think that this is a duplicate (but very releated) because it has no "different language" limits and no score. On the other hand, I didn't know about so-called "polyglot"-code so maybe I am wrong.

  • \$\begingroup\$ This is my first question on this site. If anything is unclear feel free to ask or edit. (I'm not sure if everything is clear in this challenge.) \$\endgroup\$
    – palsch
    Jan 30, 2016 at 20:07
  • \$\begingroup\$ What tags should I use for this question? \$\endgroup\$
    – palsch
    Jan 30, 2016 at 20:07
  • \$\begingroup\$ @Mego It it very releated but not the same I think. \$\endgroup\$
    – palsch
    Jan 30, 2016 at 20:10
  • 1
    \$\begingroup\$ The polyglot tag applies, and I would also recommend looking over existing polyglot challenges if you haven't already done so. \$\endgroup\$
    – PhiNotPi
    Jan 30, 2016 at 20:13
  • 2
    \$\begingroup\$ Also, Pyth and Python 3 are very different. One is specifically designed for golfing, and the other isn't. Pyth was originally derived from python, but now is its own language. \$\endgroup\$
    – Riker
    Jan 30, 2016 at 20:24

1 Answer 1


PHP + Lenguage, 165

Scoring calculation: 95 + 20 + 50.


In PHP, this outputs the string verbatim (since there is no <? to signal for the preprocessor functionality).

In Lenguage, this is an infinite loop.

The charScore changes do not affect the program, as it consists of all 95 printable ASCII characters once, so it is eligible for the +20 bonus.

  • \$\begingroup\$ Pig does not seem to fulfill the requirements of a valid programming language. \$\endgroup\$
    – PhiNotPi
    Jan 30, 2016 at 21:05
  • \$\begingroup\$ @PhiNotPi This has been rectified (s/Pig/Lenguage/). \$\endgroup\$
    – Doorknob
    Jan 30, 2016 at 21:24
  • \$\begingroup\$ I guess it's a lucky coincidence that lenguage program #95 is an infinite loop. \$\endgroup\$
    – PhiNotPi
    Jan 30, 2016 at 21:32
  • \$\begingroup\$ @PhiNotPi Not really. Anything that doesn't output that string would have worked anyway. \$\endgroup\$
    – Doorknob
    Jan 30, 2016 at 21:41

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