C# or Javascript as an entry point for programming?

So I guess I have some background with programming. I learned and used Visual Basic back in High School and learned basic Java in the later part of highschool. I recently just graduated from highschool actually and I just learned C++ these past 2 months, however I am not THAT used to using pointers.

So I just recently found out about Unity and I decided that I wanted to try it out. I was kind of sad to find out that the main languages are C# and javascript because it would have been easier to be able to simply start right away rather than starting to get familiar with the differences with the languages I know and what I have to learn.

Javascript or C#?
And what are key differences in javascript and C#?

There are a lot questions like that on this site.

Here’s an overview of the differences.

However it’s always a metter of personal choice. I prefer C# for many reasons. C# is also a true language standard. UnityScript (Javascript) is juat an artifical language :wink:

It depends what you like more. Just as a side note: C# is more like Java than UnityScript is. C# and Java are very similar. Both lanuages are compiled to CIL (common intermediate language) so in the end there’s no difference at all. Just the compiler optimisations and the language features make a difference.

C# has also not that much in common with C++, but any programming background is helpful.

I started off in UnityScript because I was curious and because it seemed like all of the Unity people suggested UnityScript. When I ran into its limitations and realized that C# didn’t have them (weak support for inheritance, interfaces or generics), I decided to go straight to C# and haven’t looked back. I’ve read quite a few testimonials saying that all serious game development ends up migrating to C# because UnityScript just doesn’t have all of the features yet. And honestly, both are pretty simple to pick up.

Some or most of the official Unity tutorials may be Unityscript, but they are few and far between imo. There is a lot more content out there for C# than for Unityscript. Mainly because C# is used everywhere and Unityscript is only used with Unity.

For example Microsoft XNA uses C# and has a ton of tutorials, there’s also some massive Unity tutorials written in C# like BurgZerg’s hack & slash tutorial, and most of the scripts and examples I see from other Unity users are done in C#. But anyway you’re not going to need many tutorials to get started and converting scripts from one language to another takes no time at all. Just start with whatever language the tutorial you want to follow is written in and go from there. :slight_smile:

I usually write in Unityscript because it’s better for scripts - the compiler takes care of many annoying things for you. Another reason: the C# compiler is cranky like an old lady, complaining about everything all the time - and with such enigmatic error messages that require a Rosetta stone to be deciphered! But C# is more powerful, allowing things like linking to external DLLs, control the serial interface and many others.

I would recommend you to start with Unityscript, but learn C# too - you will eventually need it!

Anyway, the main differences are in the class, variable and function declarations. Expressions and statements are basically the same, except for some C# idiosyncrasies: float constants must have a f appended, and structures must be created with the new keyword. There are some other keywords (like out) necessary in some function calls, and the generic functions are different.

The example below is a stupid and useless code containing the most popular pitfalls in both, Unityscript and C#:

// useless function in Unityscript:

  function Example(y: float): Vector3 {
    var x:float = 0.5;
    var dir:Vector3 = Vector3(0, 1.5, 0);
    Physics.Raycast(pos, dir, hit);
    var rb:Rigidbody = GetComponent(Rigidbody);
    var clone:Rigidbody = Instantiate(rb, pos, transform.position);
    return Vector3(x, y, 0.5);
  }

// same code in C#:

  Vector3 Example(float y){
    float x = 0.5f;
    Vector3 dir = new Vector3(0, 1.5f, 0);
    Physics.Raycast(pos, dir, out hit);
    Rigidbody rb = GetComponent< Rigidbody>();
    Rigidbody clone = Instantiate(rb, pos, transform.position) as Rigidbody;
    return new Vector3(x, y, 0.5f);
  }