Hi guys-- I’ve been going back and forth with scripts between C# and JavaScript and was wondering if there are real advantages and disadvantages to picking one and sticking with it?
I don’t say for sure but logically in my eyes using C# will be alot more efficient for performance wise as it is closer to c++ than a scripting language as javascript. So the compiler will take longer translating JS than it would CS. But I would assume on PC’s these days the timing difference in those will be so tiny there is not a real useful performance gain.
So I guess to your question I will say it is all preference
The language really makes no difference for speed as it is all compiled into IL. I personally use C# (because i used it before for Windows software) and it feels natural to me.
You should use a language you feel comfortable using and pick up easy. If you really wanted to push yourself and learn a language not just for Unity but for future stuff, then go C#.
Like EliteMossy says, there’s no speed advantage either way. The only times I’ve run into language barriers, I’ve been able to find a JS equivalent pretty easily, so I don’t think there’s much of an argument for CS being more powerful.
For me, it’s kind of like this :
Pros for JS
- simpler to get into, especially if you come from a scripting / tech art background
- more examples around
Pros for CS
- closer to C++, better for people with a programming background or who are looking to follow that path
- better debug integration (from what I’ve seen, I’m mostly JS)
The main thing is once you’ve settled on one, stick to it for the whole project It’s possible to mix CS and JS, but it’s a pain (because of compile order)
I just switched to C# after a year in JS. My initial switch was due to some plug ins semi forcing me to. And now, I just prefer it. However, I would compare JS and C# like this. Both are bikes but JS has training wheels. JS takes care of a lot of little behind the scene things for you, so as I say, when you switch over, you must better understand what is really happening in the engine.
So, if you are just starting I would say JS, as there is no difference in ultimate performance.
Here is an article written by Daniele from Holoville, stating why he prefers C#. He makes a solid case. But again, to learn, I think JS, as it will save a lot of bewilderment for a beginner. Loading...
This myth will never die it seems. This is simply wrong because we talk about Unity here, and not an external IDE. A Unity game made with any of those languages will have the same performance. They all gets compiled to CLI when building the game. You win nothing at the speed end, you win nothing at the features end. You can make the very same game with all of them. There is simply no loss.
This “wihat is the better language” issue has been discussed to death a thousand times now. With always the same result: its mainly a thing of personal flavour. And your background. When you already know C# then there
s no need to learn Unitys JS. When you already know Javascript, then Unity
s Javascript is the normal choice. When you already know Python, then BOO could be a good bet.
Try it by yourself, find out what picks up best for you. Then decide with what you want to continue.
With UnityScript / Js it seems that there are less hoops to jump through. (eg)
(0) You don’t have to import / using as many libraries to use the language.
(1) You don’t have to worry about your plugins / .dlls having to be in a Plugins folder.
(2) You don’t have to worry about the C# code compiling first in order to work with Js / UnityScript.
There are many great editor and runtime assets created with C# and in order to use them with other great assets created with UnityScript you will have to take some of the above measures. And then you still may have problems / hoops to jump through getting those assets to communicate with each other. As many have said " Quote - I well had to switch to C# because of some cool plugin not being able to work with the other Js scripts " .
It seems that a lot of coders who come from an app creation background uses c# as thats the popular language with popular IDE’s like visual basic.
Those who come from a web design background most the time are ofc skilled in HTML and use Js a lot cause it can be used in HTML.
Whatever language looks like it makes sense when you’re reading over it is the right choice I always say - lol .
Like someone said in the above replies if you plan on using another engine some day C# is more universal among popular IDE’s.
Yeah, I was wondering when we would have another language debate. Has the C++ even died yet?
Like tiles said…use whichever language you are most productive with. Unity doesn’t care, performance wise.
I prefer using C# and I suggest you to do the same. It’s easy and has some great features, like lists(well, it can be used in javascript too). Also, you may probably use C# or very similar languages in future projects(not in Unity engine), so skills you learned might be useful in future, because the language is more practical.
There are many topics like this one, so you should just google it.