Search Unity

Java JavaScript?

Discussion in 'Scripting' started by spiderclan123, Sep 15, 2012.

  1. spiderclan123

    spiderclan123

    Joined:
    Aug 7, 2012
    Posts:
    49
    hi I'm a newbie and I just want to know when using unity what knowledge would I likely used? Java or JavaScript?
     
  2. SkaredCreations

    SkaredCreations

    Joined:
    Sep 29, 2010
    Posts:
    296
    Javascript if you're planning to use UnityScript (that is almost Javascript) and Java if you're planning to use C# (that is very similar)
     
  3. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,539
    In which case though... don't bother learning Java before coming to Unity if you plan to use C#. Just learn C#.
     
  4. Batzarro

    Batzarro

    Joined:
    Apr 22, 2012
    Posts:
    51
    I'm no expert but I would say learn C# or UnityScript (sometimes referred to as 'JavaScript for Unity'). But if you choose UnityScript, I'd say use tutorials that are for Unity, because if you start going through "JavaScript" tutorials on other, non-Unity related sites, you may find yourself learning about JavaScript for totally unrelated things, like web design. I've never touched JavaScript outside of Unity before, but apparently it's a bit different from what is used in Unity.

    If you're now thinking "what is the best one to learn?", before asking it, perhaps have a read on the following simular thread. Read at least the entire first page though. Short answer is that it doesn't really matter at this stage;

    What is the best FPS language?" thread

    That thread starts off with a bit of an odd question, but changes into a discussion about what is the best language to use in Unity in general.
     
    Last edited: Sep 15, 2012
  5. Morning

    Morning

    Joined:
    Feb 4, 2012
    Posts:
    1,141
    Future tutorials on that unity study site will be in C# so that might be worth the wait.
     
  6. spiderclan123

    spiderclan123

    Joined:
    Aug 7, 2012
    Posts:
    49
    what?
     
  7. spiderclan123

    spiderclan123

    Joined:
    Aug 7, 2012
    Posts:
    49
    Oh so I should pick C# right?
     
  8. spiderclan123

    spiderclan123

    Joined:
    Aug 7, 2012
    Posts:
    49
    what? cant get your point.
     
  9. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    You are fine with Javascript too. Or BOO. You don`t win or loose anything of Unity with one of the languages, featureswise. All three languages runs in the same speed, uses the same words, and works just fine with Unity.

    I would suggest to do a forum search. This topic is discussed to death. With always the same result: it`s a thing of personal preference. And where you come from. The different languages are made so that somebody with a Javascript background or a C# background or a Python background can pick up Unity immediately without the need to relearn a new language.

    Unity`s Javascript is a bit easier to learn than the other two languages, and is a bit more forgivable. That`s the biggest difference.

    Java and Javascript are two completely different languages. That`s the point.Java points more towards C++ or other strong programming languages. And Javascript gets usually used for web development needs.
     
    Last edited: Sep 19, 2012
  10. BlakeChristensen

    BlakeChristensen

    Joined:
    Sep 18, 2012
    Posts:
    1
    Learning C# would be your best bet for Unity.
     
  11. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    I just love your clear explanation for your reasons :)
     
  12. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,539
    I was saying that if you wanted to learn C#, don't start with Java, just go with C#.

    But if you wanted to use unityscript, it's based on javascript, so start there.
     
  13. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Tiles conveniently forgets that you can lose out on a ton of features by choosing US over C# - by carefully choosing his words to refer to the unity API alone [one small aspect of programming IMO].

    Same words?

    That's just plain false.

    It's also far less featured, far less supported outside of unity, and lacks the vast quantities of resources that C# has.

    It may be a personal preference - but that doesn't mean one should ignore the very real differences between the two languages.
     
    Last edited: Sep 20, 2012
  14. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Saying it's "far less featured" is not true either. How about we not descend into Language Pissing Match #2,573, K? Thanks.

    --Eric
     
  15. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    I'm happy to have a C# vs US language feature show down, but unless I'm suddenly shown a dozen or so US features that I didn't know existed [thanks to non-existent documentation] it'll be short and brutal.
     
  16. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,539
    ummm

    unityscript is certainly a far less featured language than C#

    It's not to say unityscript is crap or anything. It just lacks certain features.

    unityscript is based on javascript and it lacks many of the following:

    delegates
    events
    method overloading
    structs (technically)
    strict anonymous functions
    full strict typeing in general (is kind of there in unityscript, but with a few oddities)

    note though, C# lacks dynamic typing... as well as the eval(...) funciton (which is very nice)


    I personally prefer C#, but that's only because I come from a .Net background. I write C# and VB for work, as well as a few other languages (C++, BASIC, PHP, python, lisp, etc), none of which are javascript. So unityscript is the odd one out for me.
     
    Last edited: Sep 20, 2012
  17. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Has those.

    Indeed not.

    Of course it has that (but not named parameters).

    It has those, technically. They are real structs exactly like C# even if it doesn't use the "struct" keyword.

    It has anonymous functions; not sure what you mean by "strict".

    Certainly has that.

    So...1/6. Better luck next time. ;)

    Doesn't work on iOS though. However there a number of other things that Unityscript has that are nice to use which C# lacks, but again, it's kind of pointless getting into it. One thing that's true is that US still doesn't have official documentation, which is a drawback, and contributes to the myth that it has "far less features", since people (understandably) can't just look them up.

    --Eric
     
  18. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Anonymous Types.
    Named, Optional, and 'param' parameters.
    Extension Methods.
    LINQ keywords.
    Partial Classes [Unless US has this?]
    Shorter Lambda's.
    Properties. [esp. Auto Properties]
    Cool Object Collection Initializers.
    Implicitly typed arrays.
    Full Generic Support.
    Nullable syntax [int?, ??]

    C# actually does have a bunch of dynamic features, though not in U3D's version IIRC.

    Another feature not yet included is async.

    While we are at it... does US have support of operator overloading et al? And how does one define an interface?

    Now I await your list of awesome US features. I can think of 2~3.
     
    Last edited: Sep 20, 2012
  19. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
  20. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,539
    @npsf3000 - I was only naming a few, but thanks for the extended list.

    the dynamic features though are a new .Net 4.0 thing, and not available in mono 2.1 which is what unity uses. I didn't mention those kinds of features because unity doesn't have them available... this includes optional params too.




    @Eric5h5 -

    delegates - nope, doesn't have them. It has a Function type for referencing functions, but it lacks delegate typing.

    events - lacks it, you agreed

    method overloading - new to me (it's not part of the ecma standard, which I'm more familiar with)

    structs - note I said technically, just like you did... hrmmm

    strict anon functions - I mean type safety you dingle nut... strict should have been that key word

    fully strict typing - no it doesn't, unityscript, based on javascript is a dynamic language. It's one of it's features that makes js/us a useful languages. It has a strict pragma, but it isn't fully featured like C#'s is. (note my ref to strict anon functions)

    also note the many features npsf3000 pointed out as well...



    Keep in mind, I have no problem with unityscript/javascript. I personally don't use it, but think it's a very powerful language. It just lacks certain features C# has (and vice versa). It may have hack ways to pull off certain aspects, or you can use alternate design patterns to work around others, or you can forfeit certain strict features that I personally like to get them. But in the end, they are features it doesn't have. Note what the word 'feature' means.

    feature - a prominent or conspicuous part or characteristic

    As I already said, lacking said features does not make it S***. It makes it unique. It's WHY there are multiple languages available. We don't want every language to be identical... otherwise what's the point of having different languages.
     
    Last edited: Sep 20, 2012
  21. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Correct that Unity doesn't support dynamic C# [as I noted], but it *does* include optional params!
     
    Last edited: Sep 20, 2012
  22. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Hello my friend :)

    And again we lead this childish discussion. We lead this discussion since months and years now. Without result. And you still didn`t learn from it.

    When i would listen to you then it`s virtually impossible to make a game with Javascript at all. Because C# is the one and only holy grail. And everybody else who doesn`t use it is a moron and will never finish a game.

    What i have seen in this thread is a fake account by a C# fanboy. Nobody registers at the Unity board just to post a sentence like " C# is your best bet "

    What i have seen is that fanboy folks like you tried a direct attack to remove Javascript from Unity. Can be found in the Wish List section, and is still active. Some of you even entered a request at Unity Feedback for that.

    What i permanently see is that always the same few folks like you jump at the table to defend C# as the "better" language where ever possible. And to declare Unity`s Javascript as crap. I guess this is the second best method to kill Javascript, now that the direct plan did fail. Convince the newbies to the dark side ...

    What i see is that you permanently declare everything written by me as nonsense, just to put your own nonsense as the only truth into focus. Nonsense like above. And i have seen all possible and impossible dirty tricks from you so far. Like talking about stuff that has nothing to do with the issue. For example talking about F# and its behaviour outside of Unity to defend C# inside Unity. Or splitting hairs.

    What i see is that C# seems to make you agressive, narrow and intolerant, not accepting that there is more than one solution. Not accepting that somebody else is even happy with this other solution.

    What you permanently overlook is that Unity is no C# IDE. It`s a game engine, which can be used with C#, Javascript and BOO. With BOO and Javascript as the house languages. And C# is the exotic language in this trio.

    Now for the interesting part. As told, we discuss since years:

    I have yet to see a single game that can be done with C# but not with Unity`s Javascript. Show me a single one. But you can`t. There is none.

    I have yet to see a single example where a game made with C# is noticeable better, faster, smaller, whatelse, than the same game made with Javascript. And again you can`t.

    I have yet to see a PROOF that Javascript is disfunctional and C# the only possible choice as you describe. But even after years and lots of discussions the count in this area is zero, nada, nothing. Besides that after years you finally found out that C# seems to compile a bit faster than JS and BOO. Great proof, really. Makes a big difference if my scripts needs 2 seconds to compile or 4.

    The result of a game made with C#, Javsacript or Boo is so close that you cannot really say C# is better or faster. All three languages are made to work with Unity. That`s a Unity promise,and they fulfill it. Javascript is a valid Unity language, which gives you the same results (plus minus a few gimmicks that doesn`t really matter). You can make the same games with all three languages, and the result is equal fast (plus minus a few eyeblinks that doesn`t really matter). But i am sure that you will again find a nonsense example just to try to prove me wrong. What fairy tale is it this time? That it is impossible to make a Pong clone with JS?

    I think it is save to say that we two will never be friends. I give a fart what you do and use. Nevertheless, when you are happy with C#, then fine. And best of luck with it. That`s the difference between us, it`s called tolerance. But as told in the other thread, i will resist in case you want to harm me and what i do. And you do harm me here with your permanent tries to make Javascript bad and declare it to disfunctional. Because that`s the language i use, happily.
     
    Last edited: Sep 20, 2012
  23. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Hi Tiles. I expect you're going to go on your usual rant? A mix of 'I'm the innocent victim', strawmen and general bashing of those who do not agree with you?

    Bashing Check.

    Strawmen Check.

    Victim Check.

    ----

    Nope, it's called reason.

    You like US for various emotional reasons, and therefor feel the need to defend it to death using whatever emotional tactics you can. I have used both languages, helped teach beginners, released applications, debated with peers and community and decided that there are many clear advantages of C# vs US. Debate the facts, not the people.
     
  24. CrazySi

    CrazySi

    Joined:
    Jun 23, 2011
    Posts:
    538
    I don't think JS/US will ever be treated as seriously as C# in this domain.

    The attitude of a lot of employers will be: If get a CV for an application programming job and it says C# I might look at it. If it says Javascript, its going in the bin, because C# points to application development, Javascript points to Web development.

    Outside of Unity im not sure if JS is really used to develop standalone applications as far as I'm aware...so for that reason I think C# is a better choice because of its association with app development.
     
  25. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    LOL

    It does the job. Nothing emotional.

    I am not interested if C# or Javascript is better or worse in this or that case, someting that you permanently repeat here. I don`t defend a language like you.

    What i defend is the freedom to use what fits my needs. And not what you think should fit my needs. What i defend is my freedom of choice. And what i defeat is your permanent repeated personal attacks into my direction to let your C# god shine.


    Stop ranting and trolling. Proof please!

    Says the one who already has started the personal attacks again.
     
    Last edited: Sep 20, 2012
  26. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Great. Then help the OP make an informed decision over which language he should choose.

    Even in the very same sentence you ask me to stop attacking you... you attack me twice! When have I personally attacked you? When have I ever said C# was my god?

    1) Why accuse me of ranting and tolling? How does that help?

    2) Why are you ignoring the many thread's we've had of this we've I've given proof - you're already mentioned them!

    3) Why are you ignoring the points I've brought up in this thread?

    4) Why should I attempt to prove strawmen arguments?

    5) Why aren't you providing any proof of your claims?

    6) If you truly believe a US app is going to be just as x, y, z as a C# app... how about making a US demonstration? Maybe you're right and it's simpler/smaller/faster etc.

    7) Even if I'm completely wrong, and you're completely right about its usefulness in unity... what about VS integration, MSDN, the libraries of video's and books, the other applications that can be made with C# etc. that simply don't apply to US?
     
    Last edited: Sep 20, 2012
  27. Batzarro

    Batzarro

    Joined:
    Apr 22, 2012
    Posts:
    51
    "Why are Mummy and Daddy fighting? Make them stop, make them stop!"
    "Because rats and skeletons are natural enemies, dear."

    [What I don't get is that npsf3000 should prefer BOO, because he's a skeleton]

    What is a strawmen argument?
     
    Last edited: Sep 20, 2012
  28. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    I will not play your game here. I am NOT interested in a dick comparison between the languages. And that`s the difference between us two. Again you try to let your C# god shine here.

    There are very valid reasons to use JS as there are very valid reasons to use C#. But those very valid reasons are a personal decision. Not a global one. And not one that you have to do for me or any other user here at the board.

    My advice is and stays: when you come from one language then go on with this language. When it`s C#, then use C#. When it`s Javascript, then use JS. When it`s Python, then use BOO. You will miss nothing. Unity works with all three languages in a similar way. No matter how much hair splitting you do here. There is absolutely no need to learn C# when you already know Javascript. And vice versa. And in case you have never programmed before then try which language fits best for you. Do some beginner lessons and you will quickly find out what works for you and what not. Nobody can do the decisions for you.

    That`s my advice. And not a "C# is your best bet". No defending of a special language. A language is a tool. And the needs are different. You have your toolset, i have mine.

    The decision is not the problem by the way. But you have already provided the proof in several other threads that you do everything to discredit and kill Javascript. That`s the part that makes me angry. Not that you try to convince people to use C#. You want to take something away from me. You harm me. And so i resist. And i will continue to resist as long as you play the JS killing game.

    In nearly every thread where we two meet each other there is minimum one attack from your side. Of course i will react to that. And attack back. And sometimes attack first. I don`t forgive this easy. But first attack here happened with your words "that`s just plain false". And on it went with "strawmen" and similar nonsense to discredit me because you couldn`t discuss away facts. And the listed points are facts.

    Virtually in every thread where you enter the discussion: No, beware of the evil JS, use C#, it`s sooo much better, you know. Noo, don`t listen to this other moron, what he says is just plain false.

    You still haven`t answered this part by the way. A proof would end this discussion forever.

    Proof please.
     
    Last edited: Sep 20, 2012
  29. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    I think I owe you a beer :p

    Plural of straw man argument - albeit probably spelt/pluralized incorrectly.
     
  30. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Since when is it a 'dick' comparison? This is *exactly* what I mean by emotional not rational discussion. You're apparently afraid I'll be damaging your manhood, while I'm trying to give the OP the best advice possible.

    Again, referencing your 'god' construct.

    So what you're saying is that there are valid reasons to choose one over the other, that that choice is a personal one, but you're against providing evidence of US's benefits? This isn;t a lucky draw - one can actually sit down and do comparisons on the languages.

    Except it's not hair splitting. Sure, the unity API's work in a similar fashion for all the languages... our code is not limited to just the unity API's. Ignoring the other aspects of programming such as language features, IDE, resources, other platforms, external tools/services etc. is not smart. You don't have to use them, or decide to go with C#, but ignoring them is foolish.

    False. In fact - I recommend learning *both* - if for nothing else as to be able to access resources made in both. And learning 'proper' JS can be incredible useful.

    Again, that doesn't mean we can give recommendations or information beyond 'it's a personal choice'. For example, in my experience people often get into JS a lot faster... until they get beyond trivial problems and realize that the lack of US resources greatly hinders their ability to progress. Then they run into problems of US hiding key concepts from them - making it harder to make those critical insights about how code works. Finally, they realize they are writing more verbose code that needed - costing substantial time and introducing more bugs.

    Again, not all tools are created equal. Some have more functionality, some have better construction. Some can be useful in limited work environments while others can be useful in many environments.

    First off, that's completely false - I'd not do 'everything to discredit and kill Javascript'. I believe US has a variety of problems - for example read the OP - and make my opinions based on the evidence I have. Secondly, if it's making you angry... isn't that an emotional reaction?

    Again, isn;t this purely emotional? I mean, in my discussions I clearly outline a rough CBA for and against US C#. However your main argument appears to be 'it's mine, leave it alone'. Where's the reason in that?

    Ahh, you have confused disputation of key facts with an attack.

    You claimed that all three languages:

    All three languages runs in the same speed, uses the same words, and works just fine with Unity.

    I responded with:

    All three languages runs in the same speed, uses the same words, and works just fine with Unity.

    This is a disputation of the facts - primarily your assertion that all three languages use the same 'words' - this is simply not true each language has it's own keywords. For example US has the word 'import' while C# has the word 'using' - same job different words. There are also words that do not have equivalents - such as C#'s LINQ keywords.

    You'll note that:

    A) I didn't attack you as a person.
    B) My argument is based in fact.

    On the other hand, here is an example of a personal attack:

    What i have seen is that fanboy folks like you

    You'll note that:

    A) You attacked me as a person.
    B) Your argument has no basis in fact - I am not: Someone who is hopelessly devoted to something and will like anything associated with thier particular thing.

    This is another example of an attack on my person. I never called you a moron - but you claim that I did.

    I note that:

    1) You make yourself out as a victim.
    2) You probably aren't doing your self-esteem any good.
    3) You need to read up on defamation.

    I note you ask me to provide proof of claims I never made... yet you refuse to provide proof of your claims?

    If you want to read my arguments that are available. If you want to dispute them that I've got open ears. If you want to do a comparison or test I might be interested - but it'll require you to do some work as well as me.
     
  31. kingcharizard

    kingcharizard

    Joined:
    Jun 30, 2011
    Posts:
    1,137
    I use both UnityScrit and C#.. If i cant figure out how to do something in C# I try it out in UnityScript then if it works I convert it.. Unityscript allows alot of lead way when you write a script, your scripts can be vague.. C# doesn't allow this lead way and you need to be more specific. that is the differences use what you want.. good day sir...

    @Tiles and npsf3000

    You two really need to stop, C# is not better that Unity Script nor is UnityScript better than C#. The argument is not needed and neither of you will prove the other wrong.. Its pointless and is no help to the OP
     
    Last edited: Sep 20, 2012
  32. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,539
    Just looked up, it does use mono 2.6, I thought it used 2.1 for some reason. So yeah, it does have optional params. Awesome!
     
  33. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Oddly enough that's basically Tiles argument... and something I fundamentally disagree on.

    Out of interest, could you take a look at that list of C# language features I outlined on the page before and tell me how many of them you understand and how many of them you use on a regular basis?
     
    Last edited: Sep 20, 2012
  34. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Splitting your hairs like you did with mine doesn`t lead to anything. An answer to your tale would fill the rest of the thread. You have insulted me and i have insulted you. I think we had a fine discussion.

    One point is left. And this time i don`t let you go.

    So ...

    Asking for a counter proof to prevent an answer is no valid answer. But okay. My proof is that there are tons of games out there that are made with Javascript. Means there is no need for C#, no game that can just be done with C# in Unity. And JS just worked fine to finish those games. And we have the promise from Unity that all three languages are valid languages that can be used to make games with. I have never seen a game that can just be made with C#, nor do i know a game that runs faster, is smaller or what else compared to a JS game just because it is made in C# under Unity.

    Now your turn. You permanently repeat that C# is the better language. Proof please.
     
  35. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    That`s my point. I know. You know. npsf not ...

     
    Last edited: Sep 20, 2012
  36. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,539
    I'll give basic reasons to choose one over the other. This is intended for OP to make a reasoned choice for which language to use.

    Unityscript/Javascript -
    dynamically typed (though if you plan to target mac devices, you don't get to fully utilize it)
    smaller keyword pool making it easier to learn the language itself
    though based on javascript, it's oddities set it apart and make interpreting general js tutorials difficult with out advanced knowledge. So the vast amount of js reference material is useless. These oddities exist because the language needs to be compiled to CIL for mono.

    C# -
    strong typed
    several explicit features that require complex design patterns to pull off in us/js.
    due to the extended explicit feature list it may take a little longer to learn the language
    is barely modified (really only the standard library is modified) as it is intended to compile in mono independent of unity. This allows a lot of the mono/msdn resources for C# very useful for learning the language.
     
  37. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    JS is equal strong typed with #pragmastrict tag from what i know. And that gets added automatically when you create a Js file in Unity.
     
  38. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Again, read up on straw man. You cannot hold me accountable for something I don't dispute.

    I've given plenty of evidence in this thread, so I shall quote it:

    Or let's put it this way, which of these do you dispute:

    • C# has books written on the language. US does not.
    • C# has many video tutorials on the language. US has few.
    • C# has an established and extensive body of work on blogs and sites like stackoverflow. US does not.
    • C# has the MSDN reference materials. US does not.
    • C# is used in the majority of .NET documentation. US is not.
    • C# is used in a myriad of applications beyond U3D alone. US is not.
    • C# is very useful when building services and tools for games that exit outside of U3D. US is not.
    • C# has a wide range of powerful language features to help empower developers. US misses out on many of these.
    • C# is a well established language. US is often confused with Javascript and Java. [Which confuses noobs].
    • C# has a large and extensive exiting code-base for developers to dig into. US's code base is vastly smaller.
    • C# has Visual Studio Express support. US does not.

    Id you do dispute these things then we need revise them. If you don't dispute these things, my question is then:

    • Given the large and substantive list of advantages C# has over US, why do you feel this isn't something that's important to bring up when recommending a language? I quote:

     
    Last edited: Sep 20, 2012
  39. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,539
    javascript is designed to be a dynamically typed language. It's one of its selling points. C# is designed to be strong typed, and you can't turn it off (and the fact you can't turn it off is a bad thing to some people).

    Note I pointed out you plan to target mac devices, you can't use the dynamic typing (you must turn on strict mode with its pragma). But this isn't a selling point of unityscript/javascript as it LIMITS one of its features.

    When strict is turned off and removes the dynamic typing it actually makes hack ways to pull off strong typing in special areas to create things like delegates. See in C#, because it's strong typed by design we have delegate declarations so that our function references stay strict. US/js lacks this feature, instead you have the Function type which is dynamically typed. So instead compiler tricks have to be used to create the strong typing when compiling into CIL.



    Note - I don't think dynamic typing is bad. Dynamic typing can be a GOOD thing. Don't short sell your F***ing features you dolt. I'm not trying to say unityscript sucks, I'm drawing a laymen comparison so OP can make their own informed choice.
     
  40. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    They are delegates though. It's kinda hard to argue that they're "not really" when they do exactly what the definition of a delegate, in the computer science sense, says they do.

    It's really, really not. If it was, it wouldn't work on iOS. Unityscript delegates work on iOS (and with #pragma strict), ergo they are not dynamically typed.

    We're talking about Unityscript, not web Javascript.

    Arguing about what exact keywords are used is pointless, since they are in fact structs, technically. If Unityscript used the word "whifflefoop" to indicate structs, they would still technically be structs. That's what "technically" means.

    See, this is the problem I'm talking about--you're not familiar with Unityscript, so you're not really in a position to say what it has and what it doesn't. The reality is, Unityscript is not Javascript, and it's not in any sense a dynamic language if you don't use dynamic typing--and not using dynamic typing is enforced on mobile or if you use #pragma strict (which is the default).

    Now that I agree with. I find C# to be better for "backbone/library" code, and Unityscript to be better for "game" code, when you're doing general game logic and heavily interacting with the Unity API.

    --Eric
     
  41. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Nice list of programming language specific lametta. And not a single valid answer to my question. As usual.

    And another big list of programming language specific lametta. And not a single valid answer to my question. As usual.

    I could argue against every single point at this two lists. Some of them are, let`s say, not this correct. But i repeat here what i have stated before. I am NOT interested in a dick comparison between the languages. Not with you. I will not play your game here.

    Just to remind, THIS is the question, the only really valid point:

    I resume: there is not a single game that you can do with C# but can´t do with JS. There is not a single game that would run faster with C# code, would look better, or would show any other real benefit.

    So it stays as it is: it`s a thing of personal preferences what language to use. You loose nothing with either of the available languages. JS is as valid as C# as a programming language in Unity.

    That`s all i wanted to know, thanks.
     
    Last edited: Sep 20, 2012
  42. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,539
    @eric

    no, they're not delegates in the computer sciencey sense. 'delegates' were designed for CLI (.net), they didn't have a "computer sciencey" place prior to it. Delegation, as a design, is part of computer science and has to do with using one object to define functionality for another... think prototypes. It is something different from .net/mono delegates.

    US/js Funciton acts more like a function pointer does from C++. Though not implemented the same way underneath, they just act similarly (how C++ function pointers don't let you contract the shape of the function).

    You can get similar functionality using the Function type. But they are NOT delegates. Though when compiling unityscript to CLI they use compiling tricks to make them compatible with the mono runtime. Compiling tricks is not a language feature, it's compiling tricks. (this is how it gets mac support)

    Key point in this... you can't say in unityscript:

    Code (csharp):
    1.  
    2. public delegate float FooMethod(string input); // <--- this, this here is a delegate!
    3.  
    4. public float FooImp1(string input) { return float.Parse(input); }
    5.  
    6. FooMethod f = FooImp1; // <-- this here, this is a function reference... using a delegate
    7. f("1");
    8.  
    In unityscript I can define an interface, a class, enum... etc. But I can't define a delegate. I have to use the Function type which is abstract and let the compiler take care of the rest.

    Code (csharp):
    1.  
    2. //note the lack of a delegate declaration that would be right here
    3.  
    4. function FooImp1(string input):float { return float.parse(input); }
    5.  
    6. var f:Function = FooImp1;
    7. f("1");
    8.  
    Same end result, but still a lacking feature. I'm not saying delegates are better, just saying it's some C# has and unityscript doesn't.

    Dude, that was me saying I was wrong. Yes, I know unityscript is not web javascript. I was pointing out my experience is more with ecmascript, so that's why I was wrong. What you weren't pleased with me admitting I'm wrong that you had to repeat what I said?



    structs - we both use the word "technically"... technically they're there, I said that from the get go before you even posted.


    fully strict typing - strict/strong typing is the design of C#, dynamic typing is a feature of javascript/unityscript. This is FACT. Unityscript supplies a strict pragma (making strict pragma a feature of unityscript), but it isn't as feature rich as C# because C# as a language is designed strong typed. This strict pragma is to work around the inherit design of javascript being dynamic!



    I also love that you fail to approach the other list npsf3000 posted. Sorry I missed a longer list and nod the remainder of the list to npsf3000, I wrote those first 2 posts last night S*** faced drunk.



    Note I am not of the opinion more features means better. I'm of the opinion that C# has more features. These greater list of features is actually one of the things that makes it more difficult to completely learn. People love the friendliness of javascript, it's probably why unityscript was designed to be like javascript.
     
    Last edited: Sep 20, 2012
  43. kingcharizard

    kingcharizard

    Joined:
    Jun 30, 2011
    Posts:
    1,137
    I'd prefer not to get involved but I've used at least half the features and understand all but 2 on your list.. However that still doesn't change the fact inside unity neither language has a real advantage over the other..

    To be perfectly honest these two points aren't facts they are opinions and in my opinion they are wrong
    Most books for unity are written using Unity Script, The Tornado Twins and Walker bros have also made a large amount of videos with Unityscript, that is just to name the few..
     
    Last edited: Sep 20, 2012
  44. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Do no confuse books written in US with books about US.

    Interesting.
     
  45. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Ahh, I understand. Here we are trying to note the differences between two languages but of course, the differences between both languages is completely irrelevant.

    http://en.wikipedia.org/wiki/Strawman_argument
     
  46. kingcharizard

    kingcharizard

    Joined:
    Jun 30, 2011
    Posts:
    1,137
    I don't really see the difference, because they teach you the fundamental concepts of the language in the books.

    Indeed it is...

    A few I dont like are:
    Anonymous Types, Partial Classes, Nullable syntax.

    Perhaps there are benefits to using such features but I've yet to discover them....

    Now I will go back to reading my C++ primer 5th Edition and no longer post in this topic I've said all I needed to.
     
    Last edited: Sep 20, 2012
  47. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Code (csharp):
    1. #pragma strict
    2.  
    3. var lol;
    4.  
    5. function Awake()
    6. {
    7.     lol = 45 + 5;
    8.     print(lol.GetType());
    9.  
    10.     lol = "wtf";
    11.     print(lol.GetType());
    12. }
    prints
     
  48. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Fundemental concepts != detail concepts.
    Fundemental concepts != advanced concepts.
    Fundemental concepts != detailed language reference

    etc.
    .
    Put it this way - if you want to learn about spelling and/or grammar do you pick up the latest home renovation DIY... or do you get a book on spelling and grammar?

    Anonymous types:

    For a start, without them LINQ wouldn't be easy as it is today.

    Code (csharp):
    1.  
    2.             var sqrNums = from root in Enumerable.Range(0, 10)
    3.                           let sqr = root * root  //uses Anonynmous types behind the scenes.
    4.                           select new { root, sqr };  //I use Anonymous types to define a quick class
    5.  
    6.             sqrNums = sqrNums.Where(x => x.root % 2 == 0);  //Processing based on strongly typed value.
    7.  
    8.             sqrNums.ToList().ForEach(Console.WriteLine);  //Output the value.
    9.  
    Secondly, they are *great* for things that need reflection.

    Code (csharp):
    1.  
    2.         public ActionResult MyConfig()
    3.         {
    4.             return Json(
    5.                     new
    6.                     {
    7.                         Name = "This is a config",
    8.                         Description = "Strongly typed, yet no need for a seperate class declaration",
    9.                         Numbers = Enumerable.Range(0, 10)
    10.                     });
    11.         }
    12. ...
    13.  {
    14.     "Name": "This is a config",
    15.     "Description": "Strongly typed, yet no need for a seperate class declaration",
    16.     "Numbers": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    17. }
    Partial Classes

    Not something you think you'd use every day - but very useful when working with code generating tools - e.g. windows forms.

    User Code:

    Code (csharp):
    1.  
    2. namespace TestApp
    3. {
    4.     public partial class Form1 : Form
    5.     {
    6.         public Form1()
    7.         {
    8.             InitializeComponent();
    9.         }
    10.  
    11.         private void button1_Click(object sender, EventArgs e)
    12.         {
    13.             MessageBox.Show("Amazing");
    14.         }
    15.     }
    16. }
    Behind the scenes code:
    Code (csharp):
    1.  
    2. namespace TestApp
    3. {
    4.     partial class Form1
    5.     {
    6.         /// <summary>
    7.         /// Required designer variable.
    8.         /// </summary>
    9.         private System.ComponentModel.IContainer components = null;
    10.  
    11.         /// <summary>
    12.         /// Clean up any resources being used.
    13.         /// </summary>
    14.         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    15.         protected override void Dispose(bool disposing)
    16.         {
    17.             if (disposing  (components != null))
    18.             {
    19.                 components.Dispose();
    20.             }
    21.             base.Dispose(disposing);
    22.         }
    23.  
    24.         #region Windows Form Designer generated code
    25.  
    26.         /// <summary>
    27.         /// Required method for Designer support - do not modify
    28.         /// the contents of this method with the code editor.
    29.         /// </summary>
    30.         private void InitializeComponent()
    31.         {
    32.             this.button1 = new System.Windows.Forms.Button();
    33.             this.SuspendLayout();
    34.             //
    35.             // button1
    36.             //
    37.             this.button1.Location = new System.Drawing.Point(98, 128);
    38.             this.button1.Name = "button1";
    39.             this.button1.Size = new System.Drawing.Size(75, 23);
    40.             this.button1.TabIndex = 0;
    41.             this.button1.Text = "button1";
    42.             this.button1.UseVisualStyleBackColor = true;
    43.             this.button1.Click += new System.EventHandler(this.button1_Click);
    44.             //
    45.             // Form1
    46.             //
    47.             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    48.             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    49.             this.ClientSize = new System.Drawing.Size(284, 262);
    50.             this.Controls.Add(this.button1);
    51.             this.Name = "Form1";
    52.             this.Text = "Form1";
    53.             this.ResumeLayout(false);
    54.  
    55.         }
    56.  
    57.         #endregion
    58.  
    59.         private System.Windows.Forms.Button button1;
    60.     }
    61. }
    Nullable syntax

    Error handling, DB interaction, Default value for optional params etc.

    Code (csharp):
    1.  
    2. var i = struct.TryParse(myString);
    3. if (i == null) /*error*/;
    4. else /*success*/;
    5.  
    Code (csharp):
    1.  
    2. public static void SetPos(this Transform trans, float? x = null, float? y = null, float? z = null)
    3. {
    4.     trans.position = new Vector3
    5.     {
    6.         x = x ?? trans.position.x,
    7.         y = y ?? trans.position.y,
    8.         z = z ?? trans.position.z
    9.     }
    10. }
    11. ...
    12. transform.SetPos(y: 10);
    13.  
     
    Last edited: Sep 20, 2012
  49. CrazySi

    CrazySi

    Joined:
    Jun 23, 2011
    Posts:
    538
    I wouldn't use many features in C#, and I think linq stinks as well. A lot of its snake oil.
    But for the most part C# syntax is quite neat and it suits me for some reason as long as I don't confuse myself with all the fancy features.

    I like everyone have my hangups and I guess one of them is anything web, so I have this aversion to Javascript. I doubt its really any worse than C# in Unity.

    This is one of my favourite articles actually (kind of related to this thread) I wonder if the Unity designers read this before designing how their scripting system would work :)
    http://www.geocities.com/tablizer/oopbad.htm
     
  50. kingcharizard

    kingcharizard

    Joined:
    Jun 30, 2011
    Posts:
    1,137
    @npsf3000

    You dont have to sell me on C# I use it regularly and its my first language of choice in Unity and in other situations permitting.. However I have used UnityScript in the past and from time to time revert back to using it for certain things.....