Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
31
Question by Lucas Meijer 1 · Oct 18, 2009 at 01:08 PM · languagejavascript-specificboolanguage-comparison

How should I decide if I should use C#, JavaScript (UnityScript) or Boo for my project?

Surely C#, JavaScript (sometimes referred to as UnityScript) and Boo each have their strengths. How do I find out which is most suitable for my project?


See also: Is there a performance difference between Unity's Javascript and C#?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image cregox · May 07, 2012 at 05:19 PM 0
Share

See also yet: http://forum.unity3d.com/threads/18507-Boo-C-and-JavaScript-in-Unity-Experiences-and-Opinions

avatar image cregox · Jun 21, 2012 at 06:26 PM 0
Share

Let's push Boo forward! http://feedback.unity3d.com/forums/15792-unity/suggestions/2944879-flawless-different-script-languages-integration :P

14 Replies

· Add your reply
  • Sort: 
avatar image
40
Best Answer

Answer by AngryAnt · Oct 19, 2009 at 08:55 AM

I would say it depends very much on your past experience. If your background is in C++ or Java, you will likely feel most at home in C# - however if you're experienced with dynamically typed languages such as JavaScript / Basic or PHP, chances are you will prefer JavaScript.

If you have no previous experience with programming - JavaScript might be an easier introduction - given that you do not need to worry about types and casting.

Do note that writing JavaScript in Unity is not the same as writing it for web browsers (which is why it is popularly nicknamed UnityScript in the community). You should check out the tutorials to familiarise yourself with it if this is the route you're going to take.

If you are planning to work with other programmers on a Unity project, I very much recommend that you decide from the beginning to work in the same language. While it is completely possible to combine scripts written in multiple languages into one project, you will very likely at some point run into issues due to the nature of the task of compiling and linking multiple languages.

Finally do notice that all documentation and tutorials for Unity are currently written in JavaScript and of the three available languages for Unity, only C# examples are given in the .NET documentation (since you are working with mono, you have full access to the mono port of the .NET library).

Comment
Add comment · Show 13 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Gab Steve · Jul 13, 2013 at 07:50 PM 0
Share

hey can i use normal javascript in unity? or is it a speacial unity javascript? pleas reply fast

avatar image Pnvanol Gab Steve · Jan 18, 2016 at 05:35 PM 0
Share

its called unityscript, a bit different

avatar image JavierIvan Pnvanol · Jan 24, 2017 at 08:41 AM 0
Share

Another year has past and, that is correct!

avatar image Nition · Jul 09, 2014 at 10:46 PM 4
Share

Co$$anonymous$$g a year later, this may not fit your definition of "fast", but the answer is no. It is indeed a "special Unity JavaScript"

avatar image goreacraft Nition · Jan 13, 2016 at 09:53 PM 1
Share

i am reading this after another year, and seems fast reply for me

avatar image JavierIvan goreacraft · Jan 24, 2017 at 08:41 AM 0
Share

indeed...!

avatar image sidhi · Aug 02, 2014 at 12:05 AM 0
Share

Is there any easy way for script/syntax translation from C# to JS or JS to C# ?

avatar image flaviusxvii · Aug 02, 2014 at 02:15 AM 0
Share

@sidhi It doesn't make much sense to post a question like that on a 5 year old answer to another question. Also.. you could use google.. http://lmgtfy.com/?q=convert+between+c%23+and+unityscript#

avatar image TechnoRazor · Nov 12, 2015 at 02:32 AM 0
Share

I am so late... Can C# do things JS can't?

avatar image RaoulWB TechnoRazor · Dec 30, 2015 at 05:47 PM -1
Share

I'm not expert, but this question has been answered before, just search on google.

avatar image cregox TechnoRazor · Jan 14, 2016 at 08:59 PM 0
Share

The answer should be "no", last time I've checked. Plus, JS and Boo can all use C# libraries as well. But, if you're going to make a big project filled with collaborations I wouldn't use anything other than C# due to community collaboration alone.

avatar image Bunny83 cregox · Jan 14, 2016 at 09:55 PM 0
Share

Actually there are some things you can't do in UnityScript which you can in C#. Like wise you can do some thing in UnityScript which you can't in C#

Examples:

  • You can't declare a class with generic parameters in UnityScript.

  • You can't declare a delegate type in UnityScript or event properties.

  • In UnityScript there's no syntax for auto - properties (properties are supported).

  • I'm pretty sure UnityScript doesn't allow a partial class declaration

  • In UnityScript you can't declare "ref" or "out" parameters.

  • UnityScript doesn't have a short delegate syntax like lambda expression and doesn't support the Linq query expression syntax.

  • UnityScript has the eval method, C# has not.

  • In UnityScript anonymous methods can be generators (methods with yield) , in C# that's not possible.

Show more comments
avatar image
27

Answer by benblo · Oct 20, 2009 at 04:24 PM

Ah, thanks Lucas for this invite to flamewars :) !

After over 2 years working with Unity, I've come to the conclusion that using UnityScript is a Bad Idea. Always. I've started by using US, switched after a couple months, then a year later worked in US again with a different team... and we ended up porting all of our code to C# after 6 months (oh the joy), and fixed a billion bugs in the process.

Yes, C# has some overhead, its syntax is a tad more verbose (although you save all those useless vars and functions), and using typeof() is a bore (but as the API is ported to generics, this quickly disappears).

But US has so many shortcuts that are just invitations to make mistakes, you'll lose the time tenfold just tracking bugs! The biggest, most awful thing is implicit variable declaration. Can you spot the error in there?

var myVar;

function Update() { if (myvar > 0) { // bla bla bla... } }

I've mispelled myVar to myvar in Update, so the compiler will create a new local variable (that will default to 0), so the if will never happen, regarless of what you set myVar to in the editor. Happy head-banging. You will get NO WARNING WHATSOEVER from the compiler, since implicit declaration is legal (even with #pragma strict), effectively forfeiting the benefit of using a compiled scripting language instead of an interpreted one. There are tons of others pitfalls, but this one alone is worth using C#.

The number 2 reason is Visual Studio: with Intellisense and inline help, you'll be learning and discovering the API as you type. Visual C# Express is free (as in beer not speech). There is simply no better code editor on the market, at least for .NET development; if someone tells you otherwise, they're either misinformed, or fanboys of some other tool. Or just hate MS or non-open source.

Less notable: you can get lower performance if you use US the wrong way... you can prevent yourself from using it the wrong way by using #pragma strict (but by using C#, you can prevent much more!)

And lastly, with C# you have access to some .NET mechanisms than haven't been ported to US: properties, delegates, lambdas, generics... not something that will really affect you when you start programming, but once you taste their power you sorely miss them.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Lipis · Mar 19, 2010 at 11:59 PM 1
Share

@benblo Actually in real JavaScript maybe this is ok... and you will never go into bla bla bla but in Unity I'm getting a really cool message that says: $$anonymous$$ identifier: 'myvar'

avatar image fireDude67 · Nov 17, 2010 at 04:35 AM 1
Share

Delegates are probably the most important thing I have used when creating menu systems...so don't overlook it....

avatar image Mikbe · Oct 07, 2011 at 08:07 PM 1
Share

I have to agree about Visual Studio. For all the amazing software Apple creates Xcode is horrible; Xcode 4 is so buggy and slow it's ridiculous. This is the one place where they should copy from $$anonymous$$icrosoft since $$anonymous$$S really got VS right.

avatar image podperson · Feb 18, 2013 at 03:26 AM 0
Share

Implicit type declaration is easily avoided by using pragma strict. The biggest issues with UnityScript are the overhead (file size and $$anonymous$$or performance) for mobile in particular and problems interoperating with C# libraries such as UI$$anonymous$$it that are based on C#'s delegate pattern (you can use them, but you need to write helper code in C#).

In the end C# is better supported than UnityScript and properly documented, but in terms of bugginess, I think that's more the coder than the language.

avatar image
10

Answer by PsychicParrot · Oct 21, 2009 at 11:54 PM

When I started using Unity, for ease of use, I opted for Javascript. Having come from Director Lingo, VB, ASP and some Lua I expected the learning curve to be steeper than it actually was.

Using Javascript introduced me (via tutorials and help files) to the foundations and principles Unity employs. From there it was much easier to switch over to C# since I had the engine side covered and it was just a case of figuring out the new syntax.

To me, Javascript is much easier to learn than C#. C# seemed intimidating when I started out - probably just because it had a C in the title ;) - it's also a lot stricter on the formatting, though now I've switched over I wouldn't want to go back. I'm finding it to be a real joy working with c# but I am really glad I started in javascript and eased over.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MaverickMode · Aug 14, 2015 at 09:00 AM 0
Share

When you say you started with JavaScript, do you mean Unityscript? The JS you use in Unity?

avatar image
9

Answer by Ricardo · Oct 20, 2009 at 01:38 PM

See also this question on the performance difference.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Cyclops · Mar 19, 2010 at 01:55 PM 0
Share

@Ricardo, you could rename the URL to indicate what the Question is - would make it more clear.

avatar image Ricardo · Mar 19, 2010 at 03:08 PM 0
Share

Good point, thanks.

avatar image Cyclops · Mar 19, 2010 at 03:45 PM 0
Share

@Ricardo, Cool, +1. :)

avatar image
8

Answer by abdullah.ahmed · Nov 09, 2009 at 06:54 PM

Depends on a few factors

1- Do you know any of the languages to begin with? Or if you know more than one then are there any of the languages you are more comfortable with? If so start learning using that language in the short term atleast.

2- IDE: Visual Studio is generally known as the best development IDE out there and Visual C# Express is free. I find intellisense and the features provided by C# tend to save me a lot of time and effort. I am equally comfortable in JS or C# but C# takes the cake in terms of performance and productivity. I really dont think there is much of an overhead (if any at all) associated with c#.

3- Code Examples: There tend to be more examples out there in Javascript but C# is gaining pace at good speed and I think it will take the lead in the near future specially since Visual Studio is properly supported now. I find that I have no problem translating code from an example in JS to one in C#, but if you are less comfortable with C# then you may find this a bit challenging.

4- If you find C# a bit daunting because you find C/C++ to be difficult, then you may psychologically find it harder to learn C#. I myself hate to work with C or C++ but love C# and I had no difficulty picking it up at all whereas C/C++ always gave me a lot of trouble.

I think in the short and long run it will pay off to use C#. However I know a lot comes to personal preference.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • 3
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What are the Syntax Differences in C# and Javascript? 7 Answers

Script translation 2 Answers

Is it necessary to use both Javascript and C# 6 Answers

Question regarding this line of code 1 Answer

Is there a performance difference between Unity's Javascript and C#? 6 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges