UnityScript vs. C# - Some Questions

Hey gang,

This is probably a very “n00b” post, but it’s just for conversation’s sake.

Is there anything that UnityScript (aka JavaScript) can’t do that C# can, and vice-versa?

I also ask this because I’m wondering if it might be better to use UnityScript for my projects, because I’m not having too much luck with C# (too many weird errors that never occurred in UnityScript despite the syntax being identical).

What’s your favorite language to use? What’s better for cross-platform releases?

Post away!

There are about a million threads on this but I’m at work with not much to do so…

I think as far as unity is concerned either one is about the same in functionality. If you wanted a language for general purposes and didn’t want to only use Unity for programming C# would be the better choice I think.

If you want to learn from video tutorials for unity specific questions it seems JS is a better route. I constantly find myself searching through loads of JS tutorials when looking for a C# one.

Solution? Learn a bit of both, they aren’t too much different. If you have been learning C# you should be able to read JS at least.

I use both. Either one is fine on any platform that I know of (Windows Store stuff had issues with Unityscript and Boo but I gather that’s been fixed). Functionality is mostly identical, but there are some things C# can do that Unityscript can’t; the main ones that I care about are being able to declare ref and out parameters in functions, and declaring namespaces. Because of those two I use C# for “library” code. I use Unityscript for “game” code, because it integrates with the Unity API more directly, so there’s less extraneous fluff and I can write code more quickly. Unityscript can also import classes in addition to namespaces, such as “import UnityEngine.GUILayout”, which I use a lot when writing editor scripts that have heavy use of GUILayout. That way I can just write “Button”, “Label”, etc. instead of having “GUILayout” repeated everywhere.

–Eric

Yeah, anytime I look for scripting tutorials I always find them in JS/UnityScript first, and have to dig a bit for C# variants.

I’m thinking about relearning a fair bit in JS because it’s so much more common than C# for some reason. It also seems a tad friendlier, though that may just be my interpretation. :stuck_out_tongue:

this blogpost has a good summary.

that more unity-related stuff appears to be in us is unfortunate and i have read that this paradigm is about to change ( see last review + reply on page ). but they show ONLY the usage of the unity api anyway. for general programming you will find way more c# tutorials (and almost none for us) and these are required in the long when it comes to organizing the project or specific aspects.

i think this is because unityscript hides some aspects from you making it a bit more “idiot proof” but also takes much controll away. and who want’s to be an idiot? for example i’m not aware how to declare a class in us which is NOT a monobehavior. i use them quite often when i use data driven approach as not everything must be a gameobject all the time.
when i startet with unity i also tried unityscript but once had a bug where i misspelled a variable name and unity silently defines a new one. i searched for days. now a script has pragma strict by default but i don’t trust a language where i must tell the compiler explicitely that he shall not implicetly take the wrong variable, i prefer one who takes the right variable explicitely and complains about it when i do crap so i have a chance to fix it. the compiler is the best debugging tool you have at hand.
so when you have errors in c# they tell you that something is wrong where us simply hides some away from you and you wonder what happens. so from my experience c# is the more precise and logical language. and when you struggle with it its a normal learning process and nothing prevents you from overcome it.