Differences of C# and JS

helloo… i’m wanna ask this …
i see they want to convert JS script to C# or C# to JS…
what’s the differences of JavaScript with CSharp ?
i think C# was more complicated…
thanks for your answer…

There was a note I found once in the manual that explained that Javascript was something about 5 or 10 times slower than C# (as it’s not a compiled but an interpreted language), thus C# is twice slower than C++…

Personnaly (Coming from C++), I prefer C#, for speed but also for coding flexibility and visibility, and I find it much “cleaner” when it comes to Object Oriented programming.

This is somewhat outdated by the look of it but a lot of it is true.
JS has support for most of the generically typed stuff now thru syntax: List.( ) and what not.

The 2 biggest losses that javascript doesn’t support from C# are function Delegates/Events and Extensions. If you don’t know what those are you’ll be fine :stuck_out_tongue: They’re extremely handy though.

Prime31 did an excellent job showing these features off and making his case for ensuring no one ever used JS again :slight_smile:

Beware, Javascript for Unity3D is definitely not your usual JS for browsers. In fact it shouldn’t be called Javascript but Unityscript which looks like a lot like JS at first sight but is not the same thing. Once compiled by Unity3D, wether you use “JS” or C#, you’ll get pretty much the same speed of execution because the two of them use the same Mono environment.

Now when you use javascript for Unity3D which is lot more permissive than C#, you may tend to use unoptimized code which leads to lesser performances but it has nothing to do with the language itself. This permissive aspect is why a lot of people find javascript easier than C#.

Javascript for beginners and actually i will also say depends on your preference. There’s no which is better than which thats why we have choice in Unity. But personally i am using C#, switched from js because i think c# is more organized and easier to read the variables. Anyways don’t forget boo which is also IMO a good language and neat too. But i am just not prepared to jump right in to boo but i might try it some time.

Javascript uses dynamic typing, which has lower performance than static typing. However, you can decide to type statically in JS, it just takes more writing. To force yourself into static typing put
#pragma strict
in the first line of code in the script. More info:

http://unity3d.com/support/documentation/ScriptReference/index.Performance_Optimization.html

http://unity3d.com/unity/engine/programming.html

“Scripting is frequently thought of as limiting and slow. But in Unity the blazing fast iteration times and ease of use of scripting languages are paired with compilation to native code and thus run nearly as fast as C++. And Unity’s JavaScript implementation runs the same speed as C# and Boo.

Wow, must be an improvment since the Unity 3 version then, I’m still sure of having seen this once :wink:
But I still find C# more user friendly (coming from C++ though) than JS.

Hi I am currently integrating Prime31 Game Center Plugin into my game and I am using javascript. Does anyone know how to modify the following code into Javascript/Unityscript: Its the standard Start function from the GameCenter demo scene.

Thanks in Advance