Nonsyntactical difference betwee C# and Javascript

I was wondering if the choice between using Javascript or C# would affect somehow the outcome of the project. Javascript is more web technology therefore I was thinking at first that if project is a web game, then it is better to chose Javascript over C#. On the other hand Unity web player probably converts both C# and Javascript into bytecode, so maybe there is no difference which one to use. Please correct me if I am saying something wrong here.

Then the question is, what if I make a mobile game (or a game for some other platform) - does it make a differnce if I chose Javascript over C#? In general I want to figure out, If the language can affect the outcome and when you - experienced people, would chose one over another?

Both languages get compiled into IL code (otherwise known as “.NET binary dll’s”) by the mono.exe compiler (not the web player).

If you target IL2CPP, the IL code gets further mangled into CPP. If you target WebGL, this CPP code is then converted into JavaScript.

This happens long before any player later sees the code. There is literally not a single line of C# or UnityScript code present in the final game anymore - even if the end-product is JavaScript again. (Note: That is not true for *.jslib assets containing JavaScript for the browser. These are always plain JavaScript and have nothing to do with “UnitScript vs. C#” decissions. Except for my second point below)

So from that point of view, it does not matter. In fact, you can use any language that compiles to a IL binary. Boo, VisualBasic, F#, IronPython, BrainFuck, whatever…

That said, there could still be reasons to choose the one language before the other:

  • If you are firm in one of the languages, choose this one.
  • If you have tons of JavaScript/C# code at some other place (e.g. a server running JavaScript/ASP) then it might be wise to use the same language in the client, so its easier for you to share some small pieces of code (like data structure definitions or some Unity-independend helper classes / libraries).
  • UnityScript is an order of magnitude slower to compile than C#. So you might not use it solely in a project with 100k lines of code.