• Advertisement
Sign in to follow this  

Unity - Script Languages

This topic is 1050 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've heard that Javascript is the easiest of the languages that Unity supports, but I was wondering what are the differences between (for example) using Javascript besides C#?, what are the pros and cons?, or does Javascript isn't able to do some task that C# does?

 

Please explain :)  thank you in advance

Share this post


Link to post
Share on other sites
Advertisement
Unity lets you use Unityscript, which *looks* like Javascript, but is not.

Unity also lets you use C#, which is *actual* C# and not a special interpretation of it.


Beware of people that tell you that a particular language is "easy". When people say "easy" when talking about programming, they *usually* mean "easy to throw code together without thinking about writing good code" and not "easy to write good code and maintain large games".

Share this post


Link to post
Share on other sites

Beware of people that tell you that a particular language is "easy". When people say "easy" when talking about programming, they *usually* mean "easy to throw code together without thinking about writing good code" and not "easy to write good code and maintain large games".

So basically... C# its better?

Share this post


Link to post
Share on other sites

 

Beware of people that tell you that a particular language is "easy". When people say "easy" when talking about programming, they *usually* mean "easy to throw code together without thinking about writing good code" and not "easy to write good code and maintain large games".

So basically... C# its better?

 

It will serve you better in the long run. Most Unity developers use c#, and by most I mean 90% or so. Plus it's a general purpose language that runs managed or native(vs 2015 .net native/IL2CPP), so you could also use it outside of Unity for anything.

 

Also since you are starting out you should watch these videos or else.

http://unity3d.com/learn/tutorials/modules/beginner/your-first-game

Edited by EddieV223

Share this post


Link to post
Share on other sites

I've used both C# and Unityscript (and even a little Boo, which is a Python-like language in the same way that Unityscript is Javascript-like), and it's very evident that C# is the correct choice. It's better supported, the documentation is better, and it has fewer strane performance quirks.

 

TL;DR? Use C#.

Share this post


Link to post
Share on other sites

Thank you Nypyren, EddieV223 and swiftcoder :)   I will try to learn C#

 

Share this post


Link to post
Share on other sites

Just to add my two cents (I also much prefer C# to UnityScript and Boo, by the way): when learning C#, do not underestimate the importance of having a strong understanding of Object Oriented Programming and (arguably to a lesser degree) the .NET framework as a foundation.  This can be the difference between "knowing" and "knowing enough to be dangerous".

 

Happy learning!

Share this post


Link to post
Share on other sites

+1 to C#...

You can use proper OO Concepts with it... that will help you become a better programmer for many popular languages like Java or C++ also. Whil you will not become a Java expert from using C#, getting your head wrapped around the concept of OO usually is the biggest bump at the beginning learning any OO language, so it will be much easier learning a new OO language in the future (also seeing how much Java, C# and C++ share in other concepts and syntax because of their common roots).

 

One thing to keep in mind is that OO programming sometimes clashes with the Component based architecture of Unity. Unity wants to enforce you using Components, which can sometimes make it hard using proper OO Concepts.

For example, you cannot call a Constructor on a Monobehaviour, if you need to hand parameters to it at start time, you need to come up with some Init() method that you call just after instantiation of the prefab containing the behaviour or adding the behaviour to an existing gameObject. It isn't really a problem, but it breaks with OO Concepts enough to be a nuisance.

And as an OO programmer, you sometimes have the habit of creating your non behaviour classes (like small helper classes that do not need to be called by the engine) as proper OO classes, which can then lead to jarring code, where first a Monobehaviour is instanciated with Unity's own method and feed with data over an Init() method, while the helper class just below is properly instantiated with a normal C# constructor.

 

That doesn't make Unityscript the better choice though, at least IMO. Just keep in mind that Unity is not REALLY using a proper OO model for its own system, and C# code from other sources might not always work without proper conversion because of that. 

Share this post


Link to post
Share on other sites

Neither of the languages is easier or better than the other.  In the context of Unity they both do the same thing.  One may have a little syntactic sugar here and there whilst another may have some built in containers or utillities.

One thing you will find though like has already been mentioned above is that nearly everybody uses C# in Unity so if you look up a tutorial it will be in C#.  If you download something from the asset store and want to fix it then it will be in C#.

Share this post


Link to post
Share on other sites

do not underestimate the importance of having a strong understanding of Object Oriented Programming and (arguably to a lesser degree) the .NET framework as a foundation.

 

I'm watching a video about OOP to understand what's that :)   (still have no idea what's .NET Framework)
 

+1 to C#...

You seem to know about this :)   (OO = OOP?,  Object Oriented Programing?), I'll note all you said and give it another read when I have a proper understanding of this subject, because at the moment I'm having a hard time understanding all that, but thanks again!, any useful information is always welcome
 

Neither of the languages is easier or better than the other.
One thing you will find though like has already been mentioned above is that nearly everybody uses C# in Unity so if you look up a tutorial it will be in C#.

Interesting :)  Yea, so I guess if I do my code with C# and ran into a problem I could easily find help since most people uses it

Share this post


Link to post
Share on other sites

 

You seem to know about this smile.png   (OO = OOP?,  Object Oriented Programing?), I'll note all you said and give it another read when I have a proper understanding of this subject, because at the moment I'm having a hard time understanding all that, but thanks again!, any useful information is always welcome

 

 

 

Sorry, dude, sometimes I get ahead of myself and forget to make sense in my posts ;)

 

Yes, OO = OOP... I like to drop the P as Object Orientation is IMO only really used in programming anyway, but yeah, it is the same thing.

 

 

The other things I was talking about is the way Unity likes to handle things, which is component based programming:

 

http://en.wikipedia.org/wiki/Component-based_software_engineering

http://thrysoee.dk/InsideCOM+/ch01b.htm

 

 

You have GameObjects as your base Game Entities, like for example a player character, or a vehicle, or a gun. Or a camera....

This GameObject has Components that are attached to it... like the graphical mesh, or a mouse controller script, or a locomotion script.

 

This GameObject - Components relationship is not REALLY OOP... it is a different way of tackling the same problem. It is not bad at all, it actually makes a ton of sense in a game engine like Unity. 

Its just that C# is an OOP language, and for someone that worked in OOP for a long time, the shift to Component base programming and using both things in parallel can be quite confusing. And its good for newbies that understand enough to start worrying about such things to know about both worlds and be able to distinguish them.

 

 

But don't worry if doesn't make much sense to you now. Just start programming and learn the language, all other things will make sense over time.

Share this post


Link to post
Share on other sites
As mentioned by other users, C# has become the most accepted language for Unity for a variety of reasons.

Not least of which being parity with Mono .NET - giving you access to the most powerful multiplatform libraries available in game development.

Also factor in the much cleaner code and strict typing in C# and you will find your Unity games have fewer and easier to resolve bugs when using this language over Unityscript.

Finally, using C# in Unity, you will inevitably learn .Net and true C# which will also open up future opportunities for you outside of Unity and game development in general.

Share this post


Link to post
Share on other sites

Everyone uses C# in Unity...

Aside from its intrinsic value and the fact that it is a typed script, it's also much easier to find help around the web (script examples) when looking for their C# counterparts (would be much harder to find anything else as a matter of fact). So, if you have no preconceived notion as to which script to use, C# is perfect.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement