Hi, all
i want to start learn making games with unity, but i have a question in mind which is: What is the difference between using C# and JS for making games with unity?
Thank you for your time
Hi, all
i want to start learn making games with unity, but i have a question in mind which is: What is the difference between using C# and JS for making games with unity?
Thank you for your time
c# is widely documented and fully supported with support all over the web. js is a made up abomination that stupid people like me use sometimes.
Apart from some minor variations in syntax, not a lot.
Personal preference would be the main driver for choosing either, however, as c# is an established language, knowledge you gain of c# within Unity, can be used for non-unity windows development.
For Unity’s implementation, there are also certain features in C# missing from JS. C# also forces you to write cleaner code than JS (which is not to say you can’t still write sloppy code).
javascript: Easy to get started, very minimal coding for simple things. Familiar to anyone doing web applications.
C#: Requires a bit more code, but also is a lot more powerful. It has advanced features such as events, LINQ and interfaces.
My recommendation is to not mix them. For small things is fine, but when your project starts to grow, dependency between js and C# classes can be a real pain with unity. In my opinion, JS is best for simple quick games with not much logic behind them, where you just want to get some behavior done quickly. C# works best for large complex projects with lots of code behind them where you might benefit from the advanced features.
Some people will be passionate about this subject and defend their language of choice. I am sure someone will disagree with my assessment which is fine, since this is just an opinion.
Programming in C# let’s you look down your nose at people.
Seriously though, with C#, in addition to Unity’s reference material, you get great documentation like this.
Enough that you don’t want to mix them, even if you are a seasoned profession so pick one and stick with it.
As to claims of snobbery I’ve seen it both ways but the fact of the matter is knowing C# will get you more jobs than UnityScript which has enough difference with real JavaScript to make it a no-go were you wanting to migrate into html/js/php/sql development. Just being practical.
I guess if you’re not interested in getting a job elsewhere using C# ie time spent learning it goes towards some external activity beyond Unity, then there’s not a whole lot wrong with going with Javascript. It’s what I prefer, I like things to be simpler and easier for usability reasons and find C# a little bit longwinded perhaps, but I also don’t know enough about it.
Well if comparing C# vs unityscript (and not javascript) then they’re not too diferent, with unityscript missing some features, so if you know neither pick C#, if you already know js pick unityscript
JS compile slower than C#
JS can’t deal with the GL class.
What version of C# is Unity using?
C# 3 (the version of c# used il .net 3.5)
Thanks
Why do you say that?
Okaaaay, then why is this doc page in js? Unity - Scripting API: GL
I personal use Unityscript, but I am starting to transition to C#. As others have said, it is more powerful both in Unity and out. Unityscript is not JavaScript. They just share a similar syntax. Also, if you’re a beginner, unityscript may be easier to use, but more and more beginner tutorials are being made in C#. It is not much harder to use. It just requires a bit of extra effort. In the end, choose whichever you like using the most (even if it’s Boo).
About compiling, are both C# and Unityscript not based on Boo in Unity, which is what is compiled in the end?
It should be noted that using JavaScript in unity is very different from using it for, say, web development. In my experience, it is closer to ActionScript than JavaScript. Personally, the main reason i stick to c# is the atrocious type system of the JS-implementation. I really cannot see why allowing dynamic typing makes sense at all in the context of Unity. It bloats the syntax, giving us the horrible “var x : int”-style notation.
If you have never done programming before, JS can be slightly easier. However, for the long run, there is very little reason not to use c#.
Having coded in a lot of programming languages over the last 25 years I think C# is the easiest yet most powerful general language, so it’s well worth learning it. Another point that often got forgotten is readability: If you use a minimum of personal coding standard, you wouldn’t have any problems to understand your own C# written 5 years ago. My advice: forget Unityscript, use C#.
Does UnityScript have generics? If not, that’d be a good reason to go with C#.
The main reason to stick with C# is simply that it’s more documented, more standardized.
JS in Unity is actually their own variant called UnityScript rather than true Javascript, there’s also a variant of Python called Boo which is completely undocumented. What this means is that on the surface these languages may look and appear like JS or Py, but in reality there’s no way of knowing how deep or full that support goes, how it’ll react to JS or Py libraries (if at all) and so on, there are idiosyncrasies that basically mean you’re that little bit more isolated and on your own when using these.
Meanwhile with C# while the version isn’t the official MS NET model it is still from the Mono project, meaning that it’s widely distributed and in use not just within Unity, it’s thoroughly documented, the areas where it isn’t fully up to scratch with the NET version are known, documented, and being fixed, elsewhere it’s the same, and you can make use of the same libraries and language features in relative security that it’ll work as described in the myriad of tutorials, examples and plain documentation out there.
In terms of actual features and speed, there shouldn’t be too dramatic a difference between any of the languages, none of them are that low level, they all offload a lot of their behaviors to the compilers, garbage collection etc, not all offer much in the way of thread control (not that you can really od much with that unless you’re incredibly careful), how you code can impact things obviously and so there will be some differences based on the strengths of the individual language when in the right hands, however for most users and most of the uses that they’ll be put to in Unity you shouldn’t expect to see such a dramatic difference in speed between similar scripts written in each.
You can make the very same game with all three available languages in Unity. They have the very same functionality in Unity. They will have the very same performance and the very same look. JS is as good or bad suited for big or small games as C# or BOO. And you can of course mix the languages.
The main difference is that it looks different when written.