Home Unity

Scripting: Javascript, C#, or Boo

LW3
LW3
I was curious who uses what for scripting: Javascript (or UnityScript since it's not exactly JS), C#, or Boo. - LW3

Replies

  • equil
    I use javascript, but i'm not a programmer or anything. I also came in with some prior experience with javascript, back when the entire documentation was all in js. There is some functionality missing from js that C# has and boo might have(?). Practically no one seems to use boo though, so it's a bit harder to find support and snippets.

    C# is probably the "best" language, since that's what everything ends up as internally anyway, but javascript is probably easier to pick up.
  • mdeforge
    Offline / Send Message
    mdeforge polycounter lvl 14
    I was pumped to use C#, but after trying to get stuff done quickly and seeing a ton of JS examples, I've only been using. I think I'll switch for my next project though.
  • commander_keen
    Offline / Send Message
    commander_keen polycounter lvl 18
    I used to use Unityscript but now I would definitely recommend C#. Unityscript might be slightly easier to learn but the only advantage it has is dynamic typing. You can pretty much do dynamic typing in C# too by casting to Object. C# also has some really nice features that Unityscript doesnt like variable accessors (get and set functions for variables).

    Also the intellisense thingy for MonoDevelop doesnt work very well with Unityscript.
  • kio
    Offline / Send Message
    kio polycounter lvl 16
    actually i use boo as i was more used to the python like syntax, worked out pretty good so far. as not many seem using it, its a bit sad that there is not so much ready to use code around, but most of the time its quite easy to convert from c# to boo.

    im thinking about switchting back to c# - but im quite happy for now with boo.
  • Elyaradine
    Offline / Send Message
    Elyaradine polycounter lvl 11
  • Maph
    Offline / Send Message
    Maph polycounter lvl 8
    C#! Very clean language and very easy to learn. And then there's this badass stuff like events and delegates, LINQ, Generics (although you can use those as well in UScript I think), etc...
  • Farfarer
    I've been using UnityScript (JavaScript) for my stuff but I kinda wish I'd started with C# - there's lots more examples of regular C# code around the place that you can use.

    I find the US syntax a lot simpler, though.
  • Peris
    Offline / Send Message
    Peris polycounter lvl 17
    I've been using unityscript as well because I already had experience in javascript. I also like the speed and that I don't have to be very strict and can be a bit messy :p. If I would switch to C#, what would be the big wins? I've been trying to figure that out, I guess I just need to try it.
  • Maph
    Offline / Send Message
    Maph polycounter lvl 8
    Talon: C# isn't all that different imho. Especially if you have a background in C or Javascript. I always thought of it as a type-safe version of Javascript.
    Granted, some of the LINQ and Lambda syntax can be a bit daunting, but you get used to it.

    Speed-wise, uscript scripts compile to a mono/.NET assembly, and so do the C# scripts, so I reckon performance will be pretty much equal. Although I have never really tested this. So don't take my word for it.

    For me personally, C# leverages you to be more considerate about what you write, how you use it and when. Due it's much less forgiving nature then Unityscript. I think this holds you somewhat back from getting super messy code really fast, although that entirely depends on the person. I myself am very prone to write messy code so I prefer statically typed languages because it makes me think before I put something down.
    There's also the much better access to delegates, generics, reflection and most importantly events. The latter is VERY important for game dev imho. Especially in a component driven model such as Unity where dependencies can become a real hurdle.
    And if you tend to use SendMessage a lot, it's actually a good idea to start checking out .NET type events. As SendMessage uses Reflection, which is a bad idea if you're pushing a lot of those to a lot of GameObjects all the time.
    You can also use the more traditional OO methods of abstract classes, interfaces, virtuals, statics, etc...

    And then there's also the tools. I absolutely despise MonoDevelop because it makes my poor little macbook slow down to a grinding halt, but Visual Studio (Express) is an absolute godsend. But that's a personal preference, what is important is that you have auto completion so you don't need to constantly have the docs on hand to see what a particular method is called, what parameters it takes and what it returns. And the auto error checking is an absolute must if you want to be productive. The time I've lost fixing Javascript syntax errors is beyond retarded. This may sound stupid, and the more seasoned programmers will mock me for this, but a good IDE is imperative to being productive with code imho.
    Auto completion is just a hell lot harder in a dynamic language like Javascript or uscript or whatever. I've still yet to find a really good Javascript editor. :(
  • r_fletch_r
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    c# + Visual Studio.

    c# may be a little more daunting but the Intelisense more than makes up for it. good autocompletion and typed variables remove a massive number of potential bugs from your code.
  • LW3
    Holy crap. What awesome feedback. Thank you all.
  • kHellstr
    Is it possible to use UnityScript and C# in same project?
  • passerby
    Offline / Send Message
    passerby polycounter lvl 12
    ya you can mix it all up kHellstr
  • Maph
    Offline / Send Message
    Maph polycounter lvl 8
    I think to be able to access UnityScript classes in c# you need to have them compiled before the c# classes compile. The other way around works fine.
  • Denny
    Offline / Send Message
    Denny polycounter lvl 14
    I believe you can only do proper hash tables in C# correct? There is a hacked version you could do in Java as well but not as efficiently. Correct me if I'm wrong.
  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 11
    this thread makes me want to finally open that C# book i bought ages ago.
  • r3spawn
    Since the performance is the same regardless of what scripting language you use (This has been officially confirmed AFAIK) I usually just use Unityscript (Javascript) since most Unity examples are in javascript.
  • Farfarer
    Denny wrote: »
    I believe you can only do proper hash tables in C# correct? There is a hacked version you could do in Java as well but not as efficiently. Correct me if I'm wrong.
    Nah, I'm using regular hashtables in Unity using Unityscript.
  • Denny
    Offline / Send Message
    Denny polycounter lvl 14
    My bad, I must have mixed something up.
  • Luxxa
  • piippo
    It's easier to write slower code with C#. No type checking means that sometimes there might be hard to catch bugs.

    Not a big difference, but I like the more clearer code that C# forces you write.
  • Snowfly
    Offline / Send Message
    Snowfly polycounter lvl 18
    Just add #pragma strict at the top of your .js scripts to switch off dynamic typing. Voila, easy to debug unityscript.

    I'm learning C# coming from an as3 background though, since it seems like a more generally useful language overall. Only so much room in my poor artist brain for computer languages.
Sign In or Register to comment.