Search Unity

Which Scripting Language?

Discussion in 'Editor & General Support' started by J Dog Hombrey, Jun 18, 2008.

  1. Heagon

    Heagon

    Joined:
    Jun 26, 2008
    Posts:
    15
    I kinda like to go with learning JS route because most examples I see are in JS. I can learn from them at first. I personally will go that direction until I'm familiar with it then slowly migrate over to C#.

    Its only my two cents because it takes me a bit while to understand scripting and I think its easier to learn JS than C#.
     
  2. slippyd

    slippyd

    Joined:
    Jun 11, 2005
    Posts:
    129
    I say go with Boo.

    I started with UnityScript/JavaScript and kept hitting walls when I needed features that were only offered in C# and Boo. I wasn't digging having to wear my fingers out typing C# (I'm not a big of Java for the same reason), and I already knew Ruby, so I figured Boo wouldn't hurt that much, so I tried it.

    It's brilliant; I type less and it's cleaner and does more. It's truly a "wrist-friendly language for Unity". (To steal some of Omar Rojo's formatting from earlier in this post):

    Pros:
    • easier to use than C#; easier than doing convoluted hacks in UnityScript (for things like Singletons)
    • very fast to code
      [list:7e3c634312]
    • the only slow-down is renaming the class when I change a filename

    [*]source code is the smallest of all three
    • I use the extra space to help separate concerns with blank lines and for documentation comments.

    [*]very little required to get started
    • Just be aware of required indenting and what kind of errors Unity gives you when you miss a colon.

    [*] documentation at http://boo.codehaus.org/ is dead-on and relevant to Unity

    [*]simple to understand
    • assuming you're not tied to a curly-brace and semicolon C-ish background

    [*]I know Boo so feel free to ask the forum or me directly for help.

    [*]There are some great Unity Boo scripts out there already to learn from.

    [/list:u:7e3c634312]


    Cons:
    • doesn't work on iPhone
      [list:7e3c634312]
    • We plan on getting around this like any agile developer these days; develop in the quickest, best environment, then once we've hit gold, figure out the rest. My team plans to write everything in Boo, then when iPhone support is needed, write a tool that runs a series of regular expressions to parse a whole project's Boo into C#. Not perfect, but it's better to get a game up and running than ponder over implementation details.
    [/list:u:7e3c634312]
     
  3. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    924
    C# has many other advantages.
    1 there are many good books about it.
    2 it has some helpful language features like interfaces and they save you alot of time in big projects.
    3 if you know C# you can use it for many things in any .NET/MONO based technology.
    do you want embeded programming? it's ok .net micro framework and C#. another game engine? XNA and C# again. windows/windows mobile programming? visual studio and C#. robotics!!?? microsoft robotic studio and C#. it can go for ever beleave me
    4 it's a Microsoft language and Microsoft will improve it time to time and Mono implement it and unity use it and you will get new features. take a look at past years, generics, LINQ and now with C# 4 we will have ... unity will change the mono version in sime time
    5 people that they know C# are pro ones and can help you better than those casual javascript programmers.
    6 if you want to work with unmanaged libraries you should use C#.
    7 Mono has a C# compiler that compiles your source code at runtime and you can add scripting feature to your game with that compiler service easily. i think someone implemented a debuger for unity with that compiler. that's about 3MB so it's not so good for web players.


    i am sure there are other advantages that i forgot.
     
  4. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    924
    C# has many advantages
    1 there are many good books about it, if you don't know the language and want to learn.
    2 it has many helpful language structures like interfaces that can save you alot of time in big projects.
    3 it's Microsoft language and they will improve it time to time and mono implements that and unity use it so you will have new language features. take a look at past years and new features of C# 2 and 3, generics and LINQ are the most importants. unity will change mono version at a time.
    4 you can use C# for any programming task but js is mostly used in website's client scripting. if you learn C# then you can use it on any .NET / Mono based technology. do you want embeded system programming? .NET micro framework and C# are for you. other game engines? XNA and ... use C#. robotics? Microsoft robotic studio and C#. windows/web/windows embeded? ASP.NET and .NET and .NET compact framework and surely C#. i can list more but,!
    5 mono has a C# compiler as a class and you can use it at runtime to execute C# source codes. you can use it for in game User generated scripts, someone made a debugger for unity with that compiler. that's 3MB and is not so good for web players.
    6 you need C# to communicate with unmanaged code.
    7 C# programmers are more professional than javascript's casual programmers in most cases and they can help you in a better way. altho it's not always the case
     
  5. aerospace

    aerospace

    Joined:
    Oct 27, 2009
    Posts:
    1
    By learnig C# you can use the power of unity and xna game engines.You can also write .net programming,....
     
  6. AlbertoT

    AlbertoT

    Joined:
    Mar 27, 2009
    Posts:
    159
    I want to develop a simulation with an heavy use of sophisticated AI (neural, genetic algo , agents etc)

    I get started from original code written in C++ and I adapt it for my needs

    Do you think that for this specific application C# give significant advantages over JS ?
     
  7. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    You may want the option of doing your GA runs and neural net training from a command line program (actually, I've found Unity suprisingly good for this kind of thing, but the command line is sometimes more convenient). You can compile and run C# on the command line with the Mono system, but Unity JS is only available from within Unity itself.
     
  8. scionwest

    scionwest

    Joined:
    Dec 19, 2009
    Posts:
    26
    For those not familier with how .NET/Mono works, it takes the source code and compiles it into Common Intermediate Language (CIL), which the Framework then executes during runtime within a Virtual Machine that compiles and executes the CIL into Native Machine Code that the CPU then executes.

    Unity uses Mono, which all three of the scripting languages use. C#, Mono and Boo(Correct me if I'm wrong regarding Boo). Since all three use the Mono Framework, that means that all three are compiled into the exact same language in the end. CIL.

    Is there a performance hit from using C# over JS? No. Having to write...
    Code (csharp):
    1.  
    2. public class Character
    3.  
    or
    Code (csharp):
    1.  
    2. public string Name = "Billy";
    3.  
    instead of
    Code (csharp):
    1.  
    2. var Name = "Billy";
    3.  
    will result in the exact same performance.

    When you write code using a language that gets compiled into CIL, there should be very little performance difference between the languages. The only difference in performance will be how the code is wrote by the developer.
    Again, correct me if I'm wrong, but since JS compiles into CIL with Mono, then it should contain a Garbage Collector. This isn't language specific. This is tied into the Mono Framework, so regardless if you use JS or C#, you should have access to the garbage collector.

    Anyone know any differently?
    Thanks.[/code]

    edit:
    after reading the performance optimization page on the Unity scripting I notice it mentions that dynamic typing in JS will run slower than C#. I suppose I should clarify my previous statements by stating that if you use strict typing, then the performance should be the same.
    Personally dynamic typing is a lazy approach IMO, and makes it difficult to understand the flow of the application when you share the code with others, as they have to figure out what each var is supposed to represent without looking at their assigned values.
     
  9. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,203
    Used properly it can lead to simpler and more elegant code, and shorter development time. Witness the confusion C# users have had regarding the usage of GetComponent in these forums, for example. However, it's best to actually understand what you're doing, so you know ahead of time the tradeoffs regarding speed, and can use it appropriately.

    --Eric
     
  10. Zender

    Zender

    Joined:
    Jan 3, 2010
    Posts:
    11
    Correct me if im wrong but.. No Breakpoint in C#. I heard that there is breakpoint in JS.

    I'm using C# cause it's my favorite langague but i got to debug using Debug.Log()

    It's kinda annoying :(

    - Zender
     
  11. UnityFiend

    UnityFiend

    Joined:
    Mar 27, 2010
    Posts:
    9
    C# has no break points? First time I've ever heard that. It usually depends on your IDE/debugger, not the language.

    Rest assured you can insert breakpoints into C# code with MonoDev.

    :D
     
  12. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,124
    A debugger is said to be available for Unity in 3.0, and it in fact has nothing to do with the language but with the runtime / development environment.

    Also, the issue with "GetComponent" in C# where you had to write

    Code (csharp):
    1. MyScript script = (MyScript) GetComponent(typeof(MyScript));
    is history since Unity 2.6 that introduced generics for GetComponent and a few other alike methods. So now, you can conveniently write:

    Code (csharp):
    1. MyScript script = GetComponent<MyScript>();
    I'm pretty sure that when Mono is updated to the current version in Unity 3.0, you'll even get dynamic typing in C#, so from then on, you'll likely be able to even write:

    Code (csharp):
    1. var script = GetComponent<MyScript>();
    in C# (I personally prefer using the actual type for variable declarations instead of "var" because I find that to be more readable - but I guess that's a matter of taste).
     
  13. flim

    flim

    Joined:
    Mar 22, 2008
    Posts:
    324
    I really hope Unity will support Java language.

    From the Mono website I saw that Mono is support Java by default, so I believe it is not so hard to incorporate Java in Unity.

    http://www.mono-project.com/Java

    Please add Java language in Unity.
     
  14. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,124
    While I really like Java (it's the language I've been using before getting into C#), I don't feel it's really that important to have it as another language in Unity. If it's a low-hanging fruit that would be nice, of course ... but going from Java to C# is so easy (seriously, I didn't even feel I had to learn C# - I just wrote my code and then fixed the few issues ... and that was back in the times of C# 1.1 where the languages were much more different than they are now).
     
  15. ProjectOne

    ProjectOne

    Joined:
    Aug 9, 2010
    Posts:
    442
    Hi everyone, I am new here and as a new user (only bought Unity 3 pre-order a few days ago) 'which language to use' is something I have been asking myself :)

    I think I will be starting trying with C#. As I am not a programemr I am not familiar with the differences in style/formatting/features between C#/Boo/JavaScript but I am not too concerned about it because there weill always be workarounds if you try hard enough.

    The main reason why I am keen on C# is simply because it is a languange/skill you can then use outside Unity without need of converting to a different style/etc... sort of high level/long term usefulnes of time invested in learning a language.
    That is assuming I will find it ok to learn and make decent use of it.

    I know there is no visual studio for MAC OS, but does Mono offer intellisense for C# autocompleting your typing?

    Cheers
     
  16. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,124
    MonoDevelop is pretty useable and runs smoothly on Mac OS X. It will also be the IDE that supports the new debugging feature of Unity.

    Personally, I really prefer using Visual Studio ... and have a Windows installation running on VMWare Fusion for that purpose. It's not perfectly convenient (e.g. you can't easily have double-clicking on code files in Unity open Visual Studio with the correct line number selected) but "good enough" (and I guess eventually, there will be ways to handle the "jump to correct line number"-issue as well, even when it probably requires some Xcode-coding and a somewhat tricky set up).

    There's a nice article on the UnifyCommunity Wiki on how to set up Visual Studio for use with Unity in a Mac environment. Unfortunately, that Wiki seems to be down at the moment, so I can't post a link.
     
  17. ProjectOne

    ProjectOne

    Joined:
    Aug 9, 2010
    Posts:
    442
  18. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,124
    Hey, thanks for looking up and posting the link ... and I'm glad to see the Wiki's up again :)
     
  19. DigiLusionist

    DigiLusionist

    Joined:
    Apr 30, 2007
    Posts:
    213
    I am a complete programming novice. I have always wanted to learn, but, after a brief stint looking at Pascal twenty-five years ago, I decided I wasn't cut out for programming.

    After all this time, however, I have decided to hunker down and learn programming in order to be able to code my own game prototypes.

    This thread has been very, very helpful! Thank you all for your input and explanations.
     
  20. POLYGAMe

    POLYGAMe

    Joined:
    Jan 20, 2009
    Posts:
    196
    Wow... too many answers to go through but I'd like throw in that I am studying game dev in C++ full time but when I leave, I'd like to use Unity for my projects, for ease of use and multi-platform distribution. My question is, which is closer to C++, C# or UnityScript? I have only been studying for a couple of months and it's hard enough getting my head around this without having to learn another language when I finish the course! lol.
     
  21. jonbonazza

    jonbonazza

    Joined:
    Nov 6, 2010
    Posts:
    453
    C# is very similar syntaxially to C++, however conceptually there are some pretty major differences (Such as the fact that, like Java, everything is a pointer). Javascript on the other hand was never meant to be a programming language, but was alwasy destined to be a scripting language. because of this, it is MUCH different than C++, C#, or even its big brother, Java. It is, however, more relaxed syntaxially, thus many noobs find it easier to learn and roll with.
     
  22. POLYGAMe

    POLYGAMe

    Joined:
    Jan 20, 2009
    Posts:
    196
    Thanks for that... might pay to stick with C# then, I guess... I seem to be able to understand the code, both JavaScript and C# (thanks to learning C++), so I guess I'll just see how I go...
     
  23. jjsuperspy

    jjsuperspy

    Joined:
    Oct 11, 2011
    Posts:
    71
    im new to scripting and would love to do scripting but what scripting language would be good for a new comer and also i use a mac so i dont really know which language of script works with a mac so if someone can help me that would be very helpful :)
     
  24. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,603
    if you are totally new to programming C# might be easier to pickup due to the largest number of resources.

    if you have a python / ruby background then going with boo is likely easiest.

    if you have a web programming / flash background then going with unityscript is easiest

    generally: all 3 can do more or less the same with some specific things that are explicitely c#*only like LINQ and higher end .NET capabilities that shouldn't worry ya at the time (when you need them you will be able to work in more or less any language anyway)
     
  25. Benjamin6817

    Benjamin6817

    Joined:
    Aug 17, 2012
    Posts:
    4
    Each language has pros and cons. JavaScript is good because its easy to understand and it takes less code to write than other programming languages, however C#, being Object Oriented (a fancy word that means nothing to beginners) will produce less errors and glitches because there are some things about JavaScript and the way things are typed that confuses me. Coming from C++, I personally prefer C# because its more like C++ being that C++ is also Object Oriented. Even though by now seeing that this topic was posted 4 years ago; I hope this helps anyone who wishes to be a Unity3d programmer decide on the right scripting / programming language for them. If simple is what you like go for JavaScript. If you like Object Oriented Programming maybe C# is for you.
     
  26. 3

    3

    Joined:
    Sep 16, 2012
    Posts:
    387
    First starting, javascript hands down. Eventually I'd move on to C# though. I'm just a beginner too, so for me, trying both, javascript was simpler.
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,923
    I've used UnityScript for almost 3 years and recently switched to C#. Now that I switched, I really feel I made the wrong choice with UnityScript. I chose to learn it because many on this forum advocating UnityScript as the easier/simpler choice for beginners and making C# sound terrifyingly complex, which I eventually learned is not the case. (Syntax-wise, the differences are trivial.) I don't agree with the assessment that UnityScript is better for beginners for many reasons. I now believe C# is the best choice for beginners. See my post here for my feelings on the matter.
     
  28. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    4,966
    I agree, but you will probably get some flak - some people for some reason take it personally when you show that C# is better. Another important thing I think is that all the new tutorials coming from Unity will be in C#. So learning UnityScript will be even harder, while C# (already easy) will be easier. It's clearly where everything is headed:

    http://blogs.unity3d.com/2012/08/29/learn-unity-coming-soon/
     
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,923
    I know, but that's okay. I'm just stating my experience after having thoroughly used both languages. I know the tone of the linked post was a little harsh because it was originally part of a forum "discussion". I'm just sharing my experience with the languages to hopefully give the newbie some info so they can make an informed decision.

    Didn't know that. Interesting. That goes along with general my impression that Unity isn't really that dedicated to supporting UnityScript. It's sad because there are a lot of things I liked about US, but Unity's lackadaisical attitude toward the language is really hurting it.
     
  30. Armitxes

    Armitxes

    Joined:
    Nov 20, 2012
    Posts:
    16
    I like LINQ, hope that Microsoft keeps working on it to make it usable not only for SQL and XML would safe people some learning ;P However i dislike that MS is trying to force you to use the LINQ syntax (for example on Windows Phone 7)

    About the JS vs C# vs Boo.
    I love C# but that's only because I'm very used to it. I never really worked with JS but it's very supported for almost everything (Web, Smartphones, Unity...) declaring variables seems as easy as in PHP, just with var instead of $ However, I dislike that it looks much more disorganized what makes it harder to understand when it comes to longer scripts.
     
unityunity