Search Unity

C# AND javascript

Discussion in 'Editor & General Support' started by Levelspawn, Jan 15, 2015.

  1. Levelspawn

    Levelspawn

    Joined:
    Jan 11, 2015
    Posts:
    9
    we have 2 coders one is well versed in c# and one is well versed in javascript>

    My question is, can the languages be mixed like part of the code wrote in c# and part in javascript? it could be a dumb question but I am new to the engine. and I do not know if they mix in the engine or if it has to be done completely in one language. and of course i know each function cant be split but i mean like if i add a feature in c# and they code a feature in js can they both work for the same game
     
  2. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Levelspawn likes this.
  3. Xtro

    Xtro

    Joined:
    Apr 17, 2013
    Posts:
    608
    If your experience is low on programming, maybe it's better to switch to C# as early as possible. It's definitely one of the best engineered languages. UnityScript is not even Javascript exactly. Unity team developed their own javascript version to be able to enable javascript developers to use their engine. C# must be the best way to go for a beginner.
     
    Jessy and Ony like this.
  4. Levelspawn

    Levelspawn

    Joined:
    Jan 11, 2015
    Posts:
    9
    \I know c# pretty well bro, its him he is only versed in javascript. so maybe I should just tell him to work on learning java? does he have to be really deep into advanced c# to write script for the engine?
     
  5. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,977
    You can mix the two languages as long as pretty much everything c# is in one of the special folders mentioned above.

    Where you'll start running into trouble is down the line as your project expands, if you use any outside assets (from the asset store, for instance) in it that are written in c# then you have to also make sure they are in those folders as well. That can get really messy really fast, especially if you plan to update those outside assets. It quickly becomes more of a problem than it's all worth.

    So...
    1. Your guy can learn c#, or...
    2. You can try to mix js and c# and hope for the best, or...
    3. He writes his code in js and then you convert it to c# either with a tool or by hand (with something like cSharpitron from the asset store).
     
    Last edited: Jan 16, 2015
    Levelspawn likes this.
  6. Xtro

    Xtro

    Joined:
    Apr 17, 2013
    Posts:
    608
    I advice beginners to start learning C# because I have 10+ years of experience on both C# and JavaScript. I know them better than my native speaking language. :) :)

    I hope this information helps you to get away from your prejudice of "Only people that are well versed in c# tell you to go to c#"
     
    kdubnz, Jessy and Ony like this.
  7. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,977
    I've actually spent the first several years with Unity releasing games written in Javascript because I didn't know c#. It's only with my latest game that I finally made myself learn c#, and the whole game uses that now.

    I'm not well versed in c# in the slightest, but I figured out how to do it and I've done it. My latest game released last week and everything went smoothly.

    My advice about mixing js and c# is based purely on actual production experience, not just some sort of pissing contest maneuver to prove that one language is better than another.

    I don't care what language someone writes in, if it gets the job done then that's the one. Trying to mix js and c# in one large project is difficult and frustrating once that product starts getting somewhat complicated. That's all I was trying to share.
     
    kdubnz and Jessy like this.
  8. Xtro

    Xtro

    Joined:
    Apr 17, 2013
    Posts:
    608
    @Ony,

    can we see that new game? :)
     
    Ony likes this.
  9. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,977
    I like to keep my released work separate from my public forum "persona". I just find it works best that way with less potential headaches for me. ;)
     
  10. Levelspawn

    Levelspawn

    Joined:
    Jan 11, 2015
    Posts:
    9

    Yes and thank you very much i get what you are syaing, I didnt even think bout if the "as the project expands" its going to be harder to keep together. gives me real thought into it. I didnt know they made converters though thank you for that. I think I will go by your opinion and turn there javascript into c#. because my luck it would get mixed and messed up in the later stages lol
     
    Ony likes this.
  11. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,977
    Awesome, I hope that works out well for you as that will allow everyone to code the way they like best. If you do go with a converter I very highly recommend cSharpitron - It's really good. I have no relation to the developer, I just think good tools should be promoted as much as possible. :)
     
  12. Xtro

    Xtro

    Joined:
    Apr 17, 2013
    Posts:
    608
    Oh boy oh boy...
     
    Jessy likes this.
  13. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,977
    Playmaker is indeed awesome and I use it myself to quickly and easily lay out and alter the flow of a program before committing things to code. I love it, but I don't think I could make an entire proper game with it alone. It does require coding skills if you're going to make the most of it.
     
  14. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    I started off in UnityScript, and used it almost exclusively for a couple of years. I did this because I listened to people I respected telling me C# was more complex, but they were wrong. There is more to it, but you don't need to use it all. UnityScript has no reason to exist.
     
    Ony likes this.
  15. Xtro

    Xtro

    Joined:
    Apr 17, 2013
    Posts:
    608
    @Jessy. Thank you for reflecting my feelings so directly. I just didn't want to break some people's hearth but I think you did it :)
     
  16. kdubnz

    kdubnz

    Joined:
    Apr 19, 2014
    Posts:
    177
    Jessy likes this.
  17. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    This statistics looked a bit different before the witchhunt against Unity Script started. It was 50/50 at one point. And even nowadays it's 20%. So i wouldn't exactly call it irrelevant.

    I will never get this racism against a programming language. It's a tool. Would you be rassistic against a hammer? Every language has its purpose as long as there is somebody using it happily. There are even some folks using Brainfuck for programming.

    Ontopic: try to use one language if even possible. As pointed out, using both languages in one project is possible, but makes too much trouble.
     
    Last edited: Jan 17, 2015
  18. kdubnz

    kdubnz

    Joined:
    Apr 19, 2014
    Posts:
    177
    Careful with the racism call Tiles, it's a bit emotive. I'm just the messenger ... not preaching here.
     
  19. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    And so is the whole versus debate. But i see your point. Apologies in case i did hurt you.
     
    Jessy likes this.
  20. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    http://forum.unity3d.com/threads/boo-is-core-of-unityscript.146552/#post-1002728

    I can't speak about the merits of the language. I can tell you that I didn't learn it because its documentation was abysmal, for a beginner, unlike that of the other options.

    I'm trying to figure out an analogy to how I see these two languages that I can relate to other people. I agree that they're tools, but not hammers. I've yet to see a tool that is better than a hammer for what it does, and how much it costs. For now, here's what I've got:

    UnityScript is a 2-conductor humbucking guitar pickup, and C# is 4-conductor. C# can be wired in series or parallel (or even split or out out-of-phase, if you can deal with hum), for more tonal options, but you can let your guitar manufacturer choose the wiring/tone, and never open up the cavity and see the wiring, if that's not your thing. UnityScript is what a certain player might want, but C# can give them the same tone, and leave possibilities open for future opinion changes.

    I asked my wife if she could come up with anything more relatable to anybody. I'll let you know if either of us do. The gist of it is, I don't see UnityScript as being different from C#, like actual JavaScript, C++, and Swift are. I see it as being gimped C#.
     
    Last edited: Jan 22, 2015
    cmcpasserby, Ony and Tiles like this.
  21. cmcpasserby

    cmcpasserby

    Joined:
    Jul 18, 2014
    Posts:
    315
    Don't want to bring this back up, but since I'm a sound guy and have been playing guitar most my life, I love this comparison.
     
    Ony and Jessy like this.