Search Unity

C# vs Javascript

Discussion in 'Scripting' started by Rockhem, Jul 31, 2013.

  1. Rockhem

    Rockhem

    Joined:
    Jul 30, 2013
    Posts:
    5
    Which should i learn to start out in unity, i want the simplest programming language that will be easy for beginners. So which one?
     
  2. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    There are many threads on the topic which should give you all the information you need. The general consensus though is that Unityscript is slightly "easier", but C# is a "real" language and therefore it is more beneficial to learn. There are many arguments on either side though.

    https://www.google.com.au/search?q=...0.69i57j69i58.9481j0&sourceid=chrome&ie=UTF-8
     
  3. Rockhem

    Rockhem

    Joined:
    Jul 30, 2013
    Posts:
    5
    I am probably going to be sticking with unity for awhile so by a "real" language you mean a language that wouldn't be just for unity?
     
  4. exiguous

    exiguous

    Joined:
    Nov 21, 2010
    Posts:
    1,749
    yes. UnityScript can only be used within unity. C# is universal and can be used for many other stuff. that also means you find way more tutorials, documentation and (non-unity)code examples in the internet.

    i'm not really aware why us should be easier than c#. for some expressions its a bit less verbose but imo also less precise. and you are quite limited in us as fe all scripts implicitely inherit from monobehavior and that is something you don't always want. also you are not forced to use the "complicated" c# features from the beginning. but you can use them when you want. on a basic level both languages are only syntactically different.

    another consideration must be the environment you want to code inside. for c# you can visual studio (express) which does a great job and automates many stuff for you.

    also most packages in the assetstore are written in c#.

    so i see no advantage in learning us. i have read many people who started in us and changed to c# anyway so why waste time and learn the "wrong" language. stick to c# and learn it independent from unity first. google c# yellow book. when you feel save in it read the unity api to know what it has to offer.

    but SteveJ is right. there are plenty of threads on that topic so search for them if you want a more complete list of pros and cons.
     
  5. Maklaud

    Maklaud

    Joined:
    Apr 2, 2013
    Posts:
    551
    This question is some kind of holywar :) Some people will tell you "learn C#" while the others will tell "learn JS". And both of them will be write and wrong, because they will tell you only their own opinion. I didn't have this question, because I'm a bit bad at JS, and work with C#, so I use C# with Unity. And if you want particular advice - I may tell "learn C#". Frankly, it isn't because C# is better (I don't even know their pros and cons, and don't even want to compare), I just like C#'s syntax (it's similar to JS but a bit different), I like this language. But in the end - you lead!
     
  6. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
  7. BlackMantis

    BlackMantis

    Joined:
    Feb 7, 2010
    Posts:
    1,475
    Fundamentals of code are the same with (ie) functions, variables, if and else statements, classes and all that good stuff to get you coding. You can code your ass off for years without ever needing to get into advanced levels of programming that everyone complains about one language having over the other. Don't believe that if you learn Js / u-script and the basic fundamentals of scripting with Js that you're stuck with Unity (though not a bad thing), as you can take the Js knowledge and use in in other Js IDE / compilers, and for embedding into HTML docs, etc.

    Who wants to be told after discovering Unity to not use it till they go and learn c# from some old c# book - lol. Unity is the best environment to learn what ever language you go with cause you can learn the unity relative syntax while learning unity at the same time.

    I know a little c# ,but for me Js looked easier to read and understand as it reads like what it does, while c# looks backwards when reading it like from right to left - lol.

    So I hope it all works out for you - Good Luck
     
  8. OhiraKyou

    OhiraKyou

    Joined:
    Mar 27, 2012
    Posts:
    259
    C# is an external (not tailor made) language that has been used a great deal in a great many places. It has accumulated a number of features that have yet to make their way into UnityScript. While using C#, you must be more explicit in telling the engine what you want it to do, because C# offers less implicit access to engine features. Be prepared to type an exceedingly large amount of fluff to get your point across. Although I haven't tested this, C# scripts are likely to compile faster due to them assuming less. If you require C#'s additional features or feel as if you need to know more about what the engine is doing at any given moment, C# may be for you.

    UnityScript is very custom and nearly tailor made for Unity. You will likely find it far more pleasant to use, because the language makes certain assumptions and implicitly handles a ton of stuff that you really don't need to know. In many cases, you may find that the explicit knowledge you gain from using C# is unnecessary. In much the same way as you don't need to know which sector is being written to while saving an XML file, you often don't need to know what Unity is doing behind the scenes. If you just want to quickly bang out your logic, UnityScript may be for you. I use UnityDevelop 4.0.

    In short, C# feels like a slightly lower level language. UnityScript is more abstract and human readable, but it lacks a few features. My advice is to code your complex, stand-alone libraries in C# to take advantage of delegates and such while using UnityScript for everything else; the vast majority of the time, you won't be using C# exclusive features anyway, making it a matter of personal preference.
     
    Last edited: Jul 31, 2013
  9. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    The important bit is: you can make the very same game with all three available laguages. It will run at the same speed, will have the same look, you don`t loose anything with either of it.