Considering C# for scripting, is that a good decision?

Hi,

I am considering C# for scripting since I feel strongly typed languages are more suitable for tracking errors in large projects, What do you think? is it going to be a good choice? (I am new to Unity)


Regards,
MI

Apparently C# results in a little smaller executables since it doesn’t have to include some code needed for Javascript. However, Javascript in Unity iPhone is strongly typed anyway (there is no dynamic typing), so that’s not an issue. I find Javascript in Unity much easier to code with, but different people have different approaches so you might as well try both for a while. (Outside of Unity I don’t have a strong preference; I find “web” Javascript to be kind of annoying in some ways, but Unity Javascript is nearly a different language.)

–Eric

ahan? Well that’s great insight, I didn’t know it was strongly typed in Unity.

Let me try both for a while, my preference would still be C# (but then again, may be it is just because I don’t know Unity Javascript as much)


MI

Just to clarify, in regular Unity Javascript you can have dynamic typing, although you normally don’t–it uses type inference to statically type most things that you don’t specifically type yourself. ‘var foo = “hi”;’ and ‘var foo : String = “hi”;’ are the same thing. You can disable dynamic typing per-script though. In iPhone Unity, dynamic typing is permanently disabled for speed reasons.

–Eric

I prefer C# because I come from a C++ background and it seems more homy plus the .net API is documented on msdn in VB, C++ and C# - not JavaScript.

Also C# behaves like normal C#
Means in Short that you can use google to find world wide answers

if you use UJS, you have to translate the found results from C# into UJS first

This has another advantage: There is a specification for C#, and C# as implemented by Mono for Unity adheres to that specification. With UnityScript/JavaScript or whatever one may call it, you need to rely on information from the forums, the Wiki, JS-specifications (that partially say something about Unity’s dialect of the language) et al.; it’s there, but it’s pretty much scattered all around.

Agh - I just can’t resist these threads :wink:

But in the end, it’s simply different styles. Whichever style you prefer should determine the language you use (so if you like it “more explicit, more code, more academic”, go for C#, if you like it “more implicit, less code, more options to write code that’s harder to understand for some people while it seems to be easier to read for others”, go for JavaScript … and if you want to be really special, go for Boo :wink: ).

Coming from a Java background, I’m heavily biased towards C# :wink: