Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Apart from the language differences (class-based vs prototypical, strong vs weak typing), what are the differences between using Javascript and using C# when developing games in Unity3D?

Is there a noticable performance difference?

Is the javascript code packaged as-is? And if yes, does this help the game's modability?

Is it possible to use libraries developed for one language while developing in the other one?

Is it possible to mix the two languages in the same Unity project by coding some parts in C# and others in Javascript?


The next couple of questions are time-specific so feel free to ignore or remove:

If libraries are not cross-functional, which language has better library support from the game development perspective?

Which language has better game dev specific resources available (books, websites, forums)?

share|improve this question

closed as off-topic by bummzack, Josh Petrie Jul 7 at 15:56

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about "how to get started," "what to learn next," or "which technology to use" are discussion-oriented questions which involve answers that are either based on opinion, or which are all equally valid. Those kinds of questions are outside the scope of this site. Visit our help center for more information." – bummzack, Josh Petrie
If this question can be reworded to fit the rules in the help center, please edit the question.

    
There is non writing component wise. But C# allows for extra stuff like DLL imports. Other than that it's a "choice". And completely subjective. Don't forget, there is also Boo in which you can write your code. –  Sidar Mar 1 at 22:07

3 Answers 3

up vote 5 down vote accepted

Is there a noticable performance difference?

No. There technically is a very small performance difference, but it is not significant enough to base your choice of language on in most cases.

Is it possible to use libraries developed for one language while developing in the other one?

Yes. As long as you make sure to keep the folder structure recommended by the developer of the library, that library can be accessed from any language. This has to do with the Unity compilation order. Some features in IDEs, like autocomplete, may not work for the chosen library though.

Is it possible to mix the two languages in the same Unity project by coding some parts in C# and others in Javascript?

Again, yes. It gets complicated quickly though, as you have to make sure everything is compiled in the right order. While it is technically possible, I'd recommend you pick one language and stick with it.

Which language has better game dev specific resources available (books, websites, forums)?

Hard to say. From browsing the forums, I'd say Javascript has slightly more tutorials and code examples. Code is generally pretty easy to port to the other language though, and since libraries are usable cross-language, this will most likely not be a major issue.

share|improve this answer

The very first question all beginning Unity developers have is C# or JS. Always go with C#.

Now, right now you may be thinking, "But I don't want to learn C# and I already know a bit of JavaScript."

But the misleading thing you need to consider is that Unity JavaScript is not JavaScript. It is a superficial veneer of ECMA syntax over .NET CLR. It does not do any of the cool things JavaScript does like anonymous enclosures and function references the way you would use them normally. It has it's own arrays that dont match up with normal .net arrays, and you'll encounter many pitfalls and limitations that you could've just avoided by using C#. Unity JavaScript is only a candy-coated layer of syntax designed to make .NET appear less intimidating, nothing more. It will do you more harm than good.

share|improve this answer

First off, I would recommend C# over JavaScript for programming in Unity for two main reasons. The first reason comes down to the strong/weak typing difference that you kind of dismissed. I do think strong typing works better than weak typing on a conceptual level, but frankly that's a whole big argument people have and so I'll focus more on a specific practical issue: Deploying to iOS (and possibly other platforms too, but that's the only one I know for sure) requires static typing. Unity actually even has a directive "#pragma strict" that can force static typing in JavaScript for this reason, but that just brings me to my second reason...

Secondly, the JavaScript in Unity is not entirely the same as JavaScript in a browser. This creates problems when you try to apply knowledge from outside Unity (ie. the majority of resources about JavaScript) to programming in Unity. This is why many Unity developers refer to the language as UnityScript.


Now to address your specific questions:

Is there a noticable performance difference?

Not really, no (some details)

Is the javascript code packaged as-is? And if yes, does this help the game's modability?

Depends on the platform, and no this doesn't really help modability

Is it possible to use libraries developed for one language while developing in the other one?

I think so (although I've never needed to do this, because all the libraries I use were programmed in C#)

Is it possible to mix the two languages in the same Unity project by coding some parts in C# and others in Javascript?

Yes (although I try to avoid it, for consistency reasons)

share|improve this answer
    
dentedpixel.com/developer-diary/… might want to add this to your answer. Upvoted. –  Grey Mar 1 at 22:39
    
interesting linke, added –  jhocking Mar 1 at 23:56

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