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
    
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
add comment

2 Answers

up vote 4 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
add comment

alright first off, I would recommend C# over JavaScript for programming in Unity. There are two main reasons I recommend that, and one 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...

Two, 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 a lot of 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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