13
\$\begingroup\$

Other than the obvious language differences, how do UnityScript and C# differ when developing games in Unity3D?

  • Is there a noticable performance difference?
  • Is the UnityScript code packaged as-is? If yes, does this help the game's moddability?
  • Is it possible to use libraries developed for one language while developing in the other one?
  • Can the two languages be mixed in the same Unity project; coding some parts in C# and others in UnityScript?
\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Sidar Mar 1 '14 at 22:07
  • 2
    \$\begingroup\$ Helpful question with objective answers - seems unfair that it was closed. \$\endgroup\$ – UpTheCreek Nov 11 '14 at 13:16
  • 1
    \$\begingroup\$ There are two main reasons this question was closed, and they don't have to do with the utility of the question or the objectivity of the answers. First, the post asks more than one unrelated question. Second, some of the questions asked are too discussion oriented and/or two broad to be appropriate as-written. How "helpful" or popular a question is, or how good the answers are, are both independent from whether or not the question is appropriate for the site. \$\endgroup\$ – user1430 Nov 11 '14 at 22:39
12
\$\begingroup\$

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. (EDIT: this can be fixed by using the free plugin UnityVS for Visual Studio.)

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.

| improve this answer | |
\$\endgroup\$
8
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
7
\$\begingroup\$

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)

| improve this answer | |
\$\endgroup\$

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