Introduction
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.
Challenge
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.
Scoring
The final score consists out of several aspects:
charScore: Take your code and then (max charScore is 95)...
- 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();
- Make all strings to empty strings and all regex and literals empty. Example: "khffshiufahk" becomes "" and all regex (without string) gets deleted.
- 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).
- Delete all characters that are not unicode 32-126. Example: print(2²) becomes print(2)
- 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()); }
<body> <textarea placeholder="Insert your code here." id="code"></textarea> <br> <button type="button" onclick="showCalcScore();">calculate score</button> </body>
+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.