Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Prospective Unity dev - is C# a "second-rate citien"?

Discussion in 'General Discussion' started by Palimon, Mar 25, 2014.

  1. Palimon

    Palimon

    Joined:
    Apr 18, 2013
    Posts:
    225
    Hey, I'm looking at Unity to dev a game, and I'd like to ask those of you with experience how creating complex Unity games using C# feels. As I take a brief look through the tutorials and reference manual, I see lots of JS code, and no C# code. Do you feel like C# comes second in Unity dev? Do you have difficulty finding examples or reference material? Must you still do some dev in JS because C# is limited to certain areas?

    Love you perspectives. Thanks!
     
    Last edited: Mar 25, 2014
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Last we checked, 60% use C#.

    1. It's the best.
    2. It's got the most features.
    3. It compiles faster.

    JS is a bit of a red herring - it's syntax is almost the same but it doesn't give you the same power. I loved it for a while but switched as projects started getting slightly more serious. Boo is for fun as well. I believe these languages are supported purely just to give people options.

    You can select
    C# from the drop down widget in the manual to see C# example code.
     
  3. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    No, its quite the opposite. In the old days Unity used JS for most things but now all their tutorials and such are done in C#. If you are in the scripting reference theirs a button to change between languages in the top left hand corner.
     
  4. Palimon

    Palimon

    Joined:
    Apr 18, 2013
    Posts:
    225
    Awesome! I had thought I'd start by walking through the http://docs.unity3d.com/Documentation/Manual/index.html to learn Unity, which was where I saw all the Javascript. Good to see that serious Unity dev is done in C#. If it was JS I'd move on :p

    Thanks for the quick replies!
     
  5. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    Its not even JS... its some half-cocked language that's Unity specific which loosely resembles JS.

    Well, IMO at least. haha.


    C# fo lyfe*



    *I realise this comment discredits anything I say
     
  6. TrentSterling

    TrentSterling

    Joined:
    Jan 4, 2013
    Posts:
    99
    Which really should be called UnityScript to stop all the confusion.

    But then again- maybe that'd scare away potential customers. :confused:
     
  7. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,617
    ... because it's not actually JavaScript?

    To be honest, that was one of the main points against for Unity for me back when I first started using it. It just shot their credibility in the foot.
     
  8. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    There's a little dropdown menu in the upper left of the page where you can choose which language it shows you the examples in. Change it to C#.
     
  9. Graham-Dunnett

    Graham-Dunnett

    Administrator

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    @Jeddak - all of the tutorials on our Learn site use c#.
     
  10. Vanamerax

    Vanamerax

    Joined:
    Jan 12, 2012
    Posts:
    938
    Like said before, back in the old days JS was the most popular scripting language in Unity, but everything is now turning towards C#, even the official tutorials from Unity themselves. I rarely see someone using Boo, but if you're from a phyton background, I imagine it's nice to have the option.

    My advice is to go with C#. Once you understand how to write the syntax, it all makes a lot of sense, while JS can sometimes be confusing if you look at it (part of it by dynamic typing, or trying to hide away internal workings as it does with coroutines)
     
  11. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    Yeah, a lot of people call it UnityScript because it's pretty wildly different from a browser's JavaScript. Pretty much, UnityScript is a classical language, not a functional/prototypical language like JavaScript (and, that's a pretty big point, because the prototypical and functional nature of brower JavaScript fundamentally changes how you code.)

    There some other minor syntactical differences on top of that, but the point remains: it may look sort of like JavaScript...it may smell sort of like JavaScript...but it's not JavaScript. Oh, and speaking of, it dosen't support duck-typing like JavaScript.
     
  12. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    I also believe that Unity's C# is not fully up-to-date with current revision/standard... so i'm not so sure it can be considered a fully 100% C# at this time. There's been a lot of advancements for C# just in the past couple revisions (parallel processing comes to mind as does easier async/await methodology)

    perhaps Unitys' version can be called C#
     
  13. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,617
    Well, no, their C# is actually C#. It is the same language. Yes, it's an older version that's missing some features from newer versions, but that's not the same as their JavaScript being fundamentally different than the thing everyone else calls JavaScript.
     
  14. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    so, ≅JavaScript ?

    ;)
     
  15. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    c# all the way :)
     
  16. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    You can still make the same game with all three available languages. It will look the same, it will run the same, it will have the same development time.
     
  17. jackmott

    jackmott

    Joined:
    Jan 5, 2014
    Posts:
    167
    Exactly what Tiles said. It just doesn't matter. C# is convenient because there is a large general base of both talent and tutorials out there. It also very closely resembles Java syntax. But in the end, after a short adjustment period to the syntax, productivity and capability is not substantially different no matter what language you use among the 3 options.
     
  18. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,687
    +1
     
  19. Deleted User

    Deleted User

    Guest

    C# is better, because err I say so :D.
     
  20. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    That's not fair to Boo. Boo allows you to fart rainbows. ;)
     
  21. Deleted User

    Deleted User

    Guest

    Nah, that's because you're a lucky charms and skittles addict. Boo does give you superhuman fingers though, so I've heard..
     
  22. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    Egads! That means yoiu've found my hidden base!

    On topic, though, I like Boo because of the Python-like syntax, but I don't use it because I use C# more. It's a shame that it's not more widely used, but that's also what I say about Dart and ECMAScript.
     
  23. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,628
    C# is awesome for game dev....no trouble finding reference material, no need for JS/unityscript. You can do the entire game and networking using C#.
     
  24. LAUDSOFT

    LAUDSOFT

    Joined:
    Jan 5, 2014
    Posts:
    102
    From what I understand, C# was Microsoft's answer to Sun Microsystems Java. Developers wanted something that handling garbage collection automatically and was overall cleaner, more elegant, so Java catered to that. And C# is basically a form of Java. Am I wrong?

    I don't think anyone considers it second rate.
     
  25. Kinos141

    Kinos141

    Joined:
    Jun 22, 2011
    Posts:
    969
    Most people here use C#. I think it's the go to language because C# is widely known, more than Boo, and "javascript" aka unityscript is custom made, so it's not well known.

    I do use both for different things. For example, if I need to create a small script that doesn't ever interact with another script = unityscript.
     
  26. sandboxgod

    sandboxgod

    Joined:
    Sep 27, 2013
    Posts:
    366
    Interesting I didnt know that about UnityScript (Javascript variant).
     
  27. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    I'm making a game that I consider to be fairly more complex than your average 2D platformer, and I'd say I've coded about 90% of it using Unityscript ("Javascript"). Just saying that to show that there are those of us out there that use Unityscript still.

    I definitely would not consider C# second rate at all. Even though I learned Unityscript first, and it's my go-to language now (because it's what I know the most of), I still dabble a little in C#, and technically I consider C# to be slightly more powerful than Unityscript. But not enough to be game-breaking at all.

    Just my experience. I just really hope Unityscript doesn't disappear yet. At least, not for awhile. I still use it extensively.
     
  28. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    I generally consider C# more powerful and expressive. It opens up a lot more knowledge on the internet, as you can get general-purpose C# knowledge and apply it to Unity, but if you search for UnityScript help you only get Unity-specific topics (because it's a proprietary language essentially).
    C# is really the best language in Unity IMHO. Boo is OK. UnityScript is an half-baked absolute abomination that has no reason to exist, but that's just my opinion ;)
     
  29. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,687
    It has at one damned good reason to exist: I'm using Unity Script since more than 6 years now and I love it… and I don't like C# :)

    The whole discussion is pretty useless - if using C# would be that super extraordinary superior then no one would use Unity Script.
    What comes next? "why does Unity support the Mac"?
     
  30. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    That's why I followed up with "that's just my opinion" ;)
    I don't expect everyone to think the way I do. I just personally do not care for UnityScript as a programmer. C# has a *slightly* steeper learning curve, but I think is a lot more powerful and expressive. It's also significantly faster to compile.
     
  31. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,687
    If someone posts something on internet forums then it is usually always just his opinion :D - and everyone's opinion is bound to be subjective. Exceptions are things like formulas, hard facts, company statements etc.

    The power of a language is limited by the user. It's a tool to create something, you can build a whole house with a $19 cordless screwdriver from the next DIY Store (I did, it survived the job) or you can build it with a $300 Makita - what's counts is the final result. And the result won't be better with a better tool unless you are trying to do it with a tool that just can't do the job at all.
    Someone might answer "blah, blah but with a better tool you will be faster and time is money!" - when someone thinks this way then he did the first mistake because creating games is (should be) a creative task, creativity does not work this way - soulless products works this way.

    Usually I had my best ideas because something did NOT work but I never had a good idea because the language I've used was "powerful and expressive".

    I recently saw a posting in some of the millions UE4 vs Unity threads: it was like "Unity 5 does not come with subsurface scattering blah!" - I instantly thought "hell, if he needs subsurface scattering why doesn't he just write a shader???"
    And this Playmaker Co! Isn't it stupid to talk about C# vs Unity script while a whole army of unity users is really using stuff like that? How often have I seen threads with the title "Do I really need to learn scripting to make a game?" ("Do you really need an oven to bake a cake?") - This stuff scares me because UT could waste resources on those kind of users! But not if someone prefers to write his code with whatever language he prefers.

    I don't care how fast it compiles - the difference is not that huge that it can be called a show stopper.
    The only real annoying show stopper is the endless build run when doing the shader optimization and performance testing on iOS which takes a huge portion of my development time and using C# won't help with that at all. It takes so long that I usually end reading the news or visiting the unity forums which takes more time again because I frequently miss that the built is ready to test :D
     
    Last edited: Mar 27, 2014
  32. metaphysician

    metaphysician

    Joined:
    May 29, 2012
    Posts:
    190
    for me, i think they should just call it UnityScript. JavaScript is totally different, being much less type specific. i ran into some really excellent Javascript programmers and they ended up being soooo frustrated with Unity's version of it they almost didn't make their game.

    i also think it comes down to employability. C# can be applied in a few other situations besides just in Unity, and as others have pointed out, you can look up generic C# documentation in books and various websites to help you understand the syntax and the approach. it's structurally quite similar to Java and not too far from C++ or Objective C. UnityScript only works in Unity, period, and only the most basic syntaxes will transfer to other situations.

    anyway that's my .02.

    scott
     
  33. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    I don't think anyone is a second rate citizen with unity. This engine is better documented than literally any application I've ever scripted for. Additionally, in my experience js and c# look almost exactly the same when it comes to Unity scripting. Nearly all the function calls are the same. I never even consider what language an answer is in because the solution is usually identical, save some variable declaration differences or type casts.
     
  34. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Have fun :)

    Code (csharp):
    1.  
    2. public class GenericPool<T>
    3. {
    4.     Stack<T> store = new Stack<T>();
    5.     public int MaxStored = 100;
    6.     public Func<T> CreateLogic;
    7.     public Func<T, T> SaveLogic;
    8.     public Action<T> DestroyLogic;
    9.  
    10.  
    11.     public T Get()
    12.     {
    13.         if (store.Count > 0) return store.Pop();
    14.         else if (CreateLogic != null) return CreateLogic();
    15.         return default(T);
    16.     }
    17.  
    18.  
    19.     public void Save(T item)
    20.     {
    21.         if (store.Count < MaxStored)
    22.         {
    23.             if (SaveLogic != null) item = SaveLogic(item);
    24.             store.Push(item);
    25.         }
    26.         else if (DestroyLogic != null) DestroyLogic(item);
    27.     }
    28. }
    29.  
    30.  
    31. //...
    32.  
    33.  
    34. var goPool = new GenericPool<GameObject>()
    35. {
    36.     MaxStored = 10,
    37.     CreateLogic = () => new GameObject(),
    38.     SaveLogic = x => x,
    39.     DestroyLogic = x => Destroy(x)
    40. };
    41.  
    42.  
    43. var intPool = new GenericPool<int>()
    44. {
    45.     MaxStored = 10,
    46.     CreateLogic = () => 0,
    47.     SaveLogic = x => --x,
    48. };
    49.  
    -------

    TL;DR C# is not a second rate citizen. All languages are suitable for most of Unity Dev. However this does not mean that languages are made equal (to the dismay of some idealists :p).
     
    Last edited: Mar 27, 2014
  35. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    That's the weird side of C#
     
  36. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    Indeed. Non the less, I often find my answers in JS, despite the language I use being C#. In any case, in my game makings so far, not finding a solution because everything is JS hasn't been an issue.
     
  37. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    And Booberry Crunch. :)
    $boo-marvel.jpg
     

    Attached Files:

    Last edited: Mar 27, 2014
  38. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    No, that's the awesome side of C# :D
     
  39. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    That's the power of generics (Foo<Type>, much like C++'s templates), and lambda expressions (a functional concept, similar to how one uses functions in Web JavaScript, noted by the weird () => ops or x => ops notation)
     
  40. Deleted User

    Deleted User

    Guest

    AHA, BOOBERRY Crunch..! I think we should start a random cereal thread.
     
  41. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    You will have to do it, I did my 'random thread' service when I started the Washing Machine meme thread for Aurore.
     
  42. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Or a random "boo" thread.

    $BooRadley.png

    (No relation)
     
  43. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    Yes, yes, very nice Atticus Finch. ;)