Search Unity

Java JavaScript?

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

  1. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    The problem is, how many of those games have been written separately in both C# and UnityScript? We can't compare the speed of one to the other because of that. As for there being thousands of games in UnityScript, yes this is true. And yes, I agree you can probably make any game that turns out basically the same using any of the languages because the full Unity API is available in all the languages.

    It may (probably) be true there are no speed differences in the games written in the various languages (I've never tested), but that's not even really a language issue at all because they're all compiled to the same Mono DLL in the end. (A good thing.) The only reason to compare languages is to find which one makes the task of programming the game easier, faster, and less painful. Language affects the programmer's experience during coding and nothing else. By the time you compile the final game, the language you used is irrelevant. A programmer looking to compare the advantages/disadvantages of languages is interested in the whole coding experience. This experience is very important, especially if you intend on programming for years to come. Many of the points made about C# by some on this thread contribute to the experience.

    See, I thought this way too. I did my first 2 years of development on Uniscite. But as my game got bigger and bigger and I got faster I started really feeling the limitations. I started exploring alternatives and ended up using MonoDevelop for about a year. Because of how broken it is, I didn't really see many advantages over plain text editors. But eventually I tried Visual Studio and was jaw dropped at how convienient and fast it was and how it really improved my ability to get things done in a much more efficient way with far less manual mental labor. So you may feel fine in Uniscite, and I don't know your C# experience, but if you haven't seriously tried it I'd wager if you really gave Visual Studio and C# a real shot you'd be very pleasantly surprised. I just wonder how much more I would have gotten done in the last 2-3 years if I had known this in the beginning... That's the reason I feel it's worth my time to tell people my experience with both languages -- I hope to help newbies avoid wasting all the time I did by doing things the hard way. Work smarter, not harder.

    Well, dll's is only one "exotic" feature that would fit in the discussion here. (I particularly love the option of ref/out in C# for one example). But yeah, there's always a way around the missing features in US. But if you had all these nice features in US, would people use them? Probably not all of them, but I'd much rather have the option to begin with because it might make getting the task done faster and easier.
     
    Last edited: Sep 22, 2012
  2. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    I work since a pretty while at my game, and am still perfecly fine with JS and Uniscite. People and needs are simply different. What is good and true for you must not be good and true for others. That´s why we have this conversation at all.
     
  3. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,532
    See, here's the thing. That's fine and dandy. And everyone has agreed that you choose that which you like.

    All the C# people have said is they choose C#, and listed the reasons why.

    You for some reason took that as them saying Unityscript should be eradicated. Why? Why are you twisting the opinions of these people? This is why we assumed you must be a troll.


    When did I ever take anything as a personal attack towards me and C#? See that... that's where you use lies and conjecture. You don't know that... that is conjecture... you are incorrect... so it is a lie. This again is why I believe you're a troll.

    And the witchhunt? Please show me where in THIS THREAD anyone has performed a witchhunt on unityscript. Please. Cause all I see is people saying:

    PersonA: I like unityscript because blah blah blah

    PersonB: I like C# because blah blah blah

    Tiles: STOP THE WITCHHUNT, UNITYSCRIPT IS AWESOME!
     
    Last edited: Sep 22, 2012
  4. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    You use inductive reasoning but you induction is not strong/complete. All the games written in UnityScript was definitely possible to write in UnityScript, but there is no evidence that all the games written in C# is possible to rewrite in UnityScript with less or equal amount of effort. So your "thousands of games" is not an argument, there's nothing to disprove.

    All you do in Uniscete can be finely done in the notepad. Why don't you use the notepad?
     
  5. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    EDIT: Deleted my point, why am I getting involve in such a ridiculous argument. Back to writing games in both C# and JS.

    And in the spirit of love and harmony here's a prototype I was messing with last week that uses some of Tiles models, and is wrttien in both c# and JS :

     
    Last edited: Sep 23, 2012
  6. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,853
    Because he doesn't want to. Why don't you chisel yours on pine? OK.. It won't compile but it will go to the wood pile;)
     
  7. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Excuse me, but *you're* the one bringing that up. All I tried to do was point out the various differences between the two languages [both language specific and ecosystem]. Nobody has said US should be removed in this thread - other than you!


    Okay, let's go with that for now.

    Please show us this fact? Where is the verification? Where is the experience? Where is the poof?

    Please show us this fact? Where is the verification? Where is the experience? Where is the poof?

    Not according to your own definition.

    Would it be because the proof you provided for it was flawed? Or because this point is the one that actually matters, and the other two are your strawman arguments? Or because you realized there's plenty of evidence to the contrary.
     
    Last edited: Sep 23, 2012
  8. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Do NOT fall that low. Regardless of personal opinion there's no reason to attack another person.
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    You come into a thread discussing the merits/pitfalls of Unity's languages and have a hissy fit because people want to actually point out the differences. Sure. Go for it. (The OP did ask about learning C#.) You clearly don't care about the differences between languages no matter what they are. I will not get into a discussion with someone who has made himself clear that he is not interested in hearing anything but what he holds to be true. That would be about as much point as a political debate.

    What you assume doesn't matter. If you cared, you'd go to the bother to do a battery of tests like I did, but it's clear you don't.

    If I didn't see it here I wouldn't believe it possible for people to get so vitriolic and defensive about a programming language. Very sad.
     
    Last edited: Sep 23, 2012
  10. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,532
    Bullshit, he's an idiot. I'm just pointing it out. He has repeatedly failed to understand what facts are or what logical fallacies are, despite having it explained numerous times, and continues to operate to the contrary. That makes him below average intelligence, otherwise known colloquially as an 'idiot'.
     
  11. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    True, but I refuse to be associated with name-calling whether or not it's deserved. Since his arguments are so poor, it should be easy to show the fallacies. By resorting to name-calling, you've enabling him to take this from a rational debate to vitriol, which is not what I want the public [and admins, and OP, and potential future clients/employers/employees/colleagues] to see.

    In short, just because his arguments are weak doesn't mean ours have to be.
     
  12. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,532
    Well you're not associated with it. I called him an idiot, not you.

    Now by say "I refused to be associated with name-calling whether or not it's deserved". You're implying he may as well deserve it. Which in that case you are not actively associating yourself with it.

    It's like that Louis C.K. quote about the "n-word", and how not saying it but instead saying "the n-word" is just making the other person think the word that you are actually saying. By attempting to dodge calling him an idiot, you've called him an idiot.


    Lastly, my calling him an idiot has nothing to do with my "argument". I'm just pointing it out because he ignores the general argument. You can't argue an idiot who refuses to listen to any argument.
     
    Last edited: Sep 23, 2012
  13. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Okay, then I'll leave it there.

    Or I'm trying to reason with someone who does think it is deserved, so don't jump too far with your conclusions.
     
  14. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,532
    That's the thing about implications... watch what you say if you care so much.
     
  15. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    From time to time you really surprise me. Because this is something i highly agree.

    For the "weak" and "poor" arguments, see below.

    The proof is that all other facts points towards it, and that it cannot be disproven. That`s what makes a fact.

    I can travel around the earth and can reach the same point again, no matter at which point i start. Which points towards a sphere, and not a plane where you fall off the table. And we have also astronomical photos which proofs that the earth is round nowadays. Plus many other facts that points towards that the earth is round. All tries to disprove that the earth is round fails. And so it`s a fact. That`s the way how science works.

    Fact: all three languages gets compiled to cli anyways. Fact: all three languages uses the same api. Fact: i know of no game that is any better just it is made with C#. Nor do i know a game that can`t be done with JS or BOO but with C#. And there are thousands and thousands of games out there in all three languages. Fact: when there would really be a difference, then there would already have somebody found it out, and made an example to show this. So that others can benefit from this knowledge. But there is none. Since years.

    As told before, it`s really easy. When you think that i am wrong, when you think that the Unity earth is square, then disprove it. Should be pretty easy when i am really this wrong and have really this weak arguments. That you didn`t already do that just shows how strong my facts are. You don`t leave such a chance out normally.

    LOL

    That`s how it gets argued here all the time. He just MUST have asked for C# .... No. The OP did ask what knowledge he needs, Java or Javascript.

    But it`s you who still chime in where ever possible, hijacking threads, singing the C# song and provoking me. Not vice versa. And you were one of the strong supporters of this insane "make JS deprecated" thread. So why should you do that when not for this reason again?

    I would`ve been perfectly fine with your other statements. But your "Same words? That's just plain false." was a personal attack towards me again. And i reacted to that.

    Too late. You cannot fall lower than to become a fanboy and to stop to think by yourself.

    Who is twisting facts here?

    This thread was NOT a "what is better" thread. You made it to one. C# fanboy hijacking at its best.

    I didn´t hijack this thread to sing the C# song. I don`t chime in into every thread to bash JS to death. The thread was perfectly fine before the "C# is oh so much better", and the "everybody who don`t agree is an idiot" game started. And this started by npsf`s comments, not by mine. I don`t declare you to anything. Even when you act like three year old child here. And the moments when i call npsf something are the moments when he calls me something. So that equals out.

    YOU sir are the troll here. You even start me to call names because you run out of arguments.

    Now that`s an unexpected wisdom out of your mouth.

    I for myself am highly pragmatic. I use what does the job best for me. I prefer to decide and to think for myself. Not what others thinks should do the job best for me.

    I would switch to C# in an eyeblink when i would see a need and a benefit from it. And i will when i have to. But i don`t see this need, and i don`t see a benefit in doing so. I have of course compared the languages in the past years, i am not talking out of the blue here. You cannot tinker around with Unity without to stumble across C#. I have enough C# knowledge to translate available snippets to JS without problem. And i could do vice versa when i would want to.

    The step to write in C# then is not this big, i already did that when i did some tests to find out if C# is something for me and my needs. I even use the one or another C# script in my project because there was no need to translate them to JS. It`s just that i personally find C# highly uncomfortable and slower to use compared to JS. And why should i bother to use the for me weaker tool?

    The differences between the languages are there, but they are not this big. You can at any point switch to C# or JS. Unity eats both, and even works with both languages in one project. And in fact there`s more than one C# user, even here in this thread, that still uses JS too. Why should they when JS is really this useless as always pointed out?

    Fact is i can do my job perfectly fine with JS. Fact is others can do the job with JS too, and they do. Fact is the Unity userbase that uses JS is big. Fact is that JS is a supported language, and it will stay supported. And not abandoned as some of you wish here. But this experience and facts doesn`t count, right? It`s not YOUR experience and not YOUR facts. How could i even overlook this important bit ...

    I couldn`t care less what one prefers. As long as i can use what i prefer. I even stated very early in this thread that i am not interested in a dick comparison between the languages, even when i got forced to do that then. But that`s exactly the problem. I can be sure that somebody known in this thread jumps in to declare that i am totally wrong, use strawman arguments, and so on, starting to sing the C# song, and provoking me in the moment when i enter a thread where it`s about a language. I guess i could even state that C# is the best language, and still get provoked and bashed now.

    @ all C# fanboys: I have no problems when you point out the strong sides of C#, but stop this insane JS witchhunt.
    @ npsf: please stop to provoke me again and again. You waste our time. You will not convince me, i will not convince you.
     
  16. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Except you haven't actually provided these facts, you've just made a bunch of claims and ignored most of criticism against said claims.

    Undisputed.

    Within unity, undisputed.

    This is a fact. However the fact here is about your knowledge - so you have to remember its limitations. http://en.wikipedia.org/wiki/Anecdotal_evidence

    Furthermore, we've highlighted several problems with making games in US alone. Games that need C# server aspects, games that need native code transition etc are area's where we are still looking for practical US alternatives.

    To make that a 'fact' you'd have to present some evidence.

    This is not a fact - you've been arguing with me an many others because we can demonstrate clear examples of where C# outperforms US in terms of development. These are not new differences.


    Or alternatively how weak they are.

    Just because no one can prove to me that pink bunnies don't live on the moon, doesn't make that a strong factual statement.

    Oh so I should pick C# right?

    That's a FACT.


    Excuse me? Have you read this thread?

    • You posted in it before I did.
    • You brought up C# before I did.
    • You make factually incorrect statements before I entered.

    And when did I 'provoke' you? What did I say that would do such a thing?

    What does that thread have to do with this thread? You keep brining it up... but why? Did I tell OP that US was about to become depreciated?

    You made a factually incorrect statement. I brought up that that statement was factually incorrect. How is that personal? How was that an attack? Why did you feel the need to react?

    This is an excellent example of a personal attack. Again, how does my statement appear anything like the above?

    -----

    Again, why do you keep blaming me?

    Go on. Find a list of all the times I've called you 'something' in this thread, and then make a list of all the times you've called me something.

    I will pay you $100 if you can prove, to an independent observer [say JohnnyA] that that's even remotely true.

    One of the first things you did in this discussion with me is call the discussion childish, and me a fanboy. Does that mean you ran out of arguments then?

    So a pragmatic man ignores the advice of his peers? I assume I missed the point. Regardless... as a pragmatic man who thinks for himself... how much C# have you done?

    Yet when we've provided various C# snippets for your viewing you don't try to provide the US alternative. Interesting.

    Then don't use it. The argument isn't that one must use C#, rather that there are a bunch of differences between those languages and those differences should be taken into account before choosing to learn or recommend one.

    We wish here? Where do we wish that?

    Yet your experience and facts are overruling?

    Read through this thread again. Where is the witchhunt? Pinpoint the post's please.

    Please stop accusing me of provoking you when you've not provided any good evidence that I have done anything of the sort.
     
    Last edited: Sep 23, 2012
  17. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    I save me a reply. it`s wasted time. Because we go in circles as usual. Who has thrown the first stone is not longer of interest. We have both thrown. The arguments are long known and named. And as told, i will not convince you, you will not convince me. Just this:

    Because you already showed that you are not interested to show how strong C# is, but interested in killing JS. And you do harm me with that. Stop your witchhunt and i am quiet. Go on with your witchhunt and i will resist.That easy.
     
  18. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577


    I brought enough popcorn for everyone.
     
  19. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Go on, show us this witch-hunt you are so obviously afraid of. I mean, I must have made a least a dozen threats to kill US in this thread to get the reaction I have - all you have to do is quote me.

    You are claiming that you're only interested in the defense of US... but this very thread shows your efforts are misguided. When I attempted to show how strong C# is, you were 'provoked' and decided to attack me. The persecution you are resisting cannot be found in this thread.

    Find some evidence to support your version of events, or apologize.
     
    Last edited: Sep 23, 2012
  20. Tiles

    Tiles

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

    I apologize that i have even answered to you, playing your childish polemic game.

    I`m definitely not so good in splitting hairs and twisting facts like you. You are definitely the better demagogue. And unbeaten in this area.

    Still needs to be disproven. No matter how hard you try to avoid that ...
     
  21. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Thank you.

    I know how hard it must be for you to admit to making a mistake, and understand you feel it necessary to attack me even as you admit your errors, and I forgive you for that.

    That's the wonderful thing, it doesn't.
     
    Last edited: Sep 23, 2012
  22. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    And still at twisting words and playing polemic games. I didn`t apologize to you. But to myself.

    What about your apologizes? You wasted my and many other readers time, accused me, insulted me, twisted my words in a permanent way, refused to listen to arguments and so on. You better apologize for that.

    And just to remind ...

    Disprove it when you can. But you can`t.
     
  23. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Sure, you might want to say that you didn't apologize to me, and that I'm wrong... but at the end of the day you had a decision to make. The decision made was not to provide proof of your claims, but to apologize.

    Here's a pretty image of it:

    $TilesApology.png

    You made a decision, now you have to live with it.

    No Need.
     
    Last edited: Sep 23, 2012
  24. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    The decision was to not longer waste my time with your methods of discussion. Nor to waste my time with you at all.

    The proof is there. But you don`t want to accept it. You play polemic games instead.

    Indeed. Same for you. That you are not this happy to read the truth is clear. And that you try all tricks now to point away from that is understandable. But that`s the way it is.

    Indeed again. Why try the impossible.

    I still wait for your apologizes. But i guess that`s already as close to an apologize than you can go. So thanks and forgiven :)
     
    Last edited: Sep 23, 2012
  25. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Any Unity game that consists of more than a thousand lines of UnityScript code could be written in C# with less time, effort, and amount of hidden bugs.
     
  26. Batzarro

    Batzarro

    Joined:
    Apr 22, 2012
    Posts:
    51
    But which one is better, salted or sweet? Which one should I choose?
     
  27. Loius

    Loius

    Joined:
    Aug 16, 2012
    Posts:
    546
    You should choose the salted popcorn. If you choose sweet popcorn you lose the ability to have little grainy bits of goodness on it and you're also dumb. /metaphor
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Now you are splitting hairs. Because the first post or title doesn't mention C# you think he's not interested in hearing one word about it? This is a forum which is a place for discussion. Discussions go beyond one initial sentence.

    It is never inappropriate to give advice. This is a support forum. The OP asked about languages. The OP did ask about C# before anyone ever recommended a language.

    Look for yourself at the chronology:

    Post #1 (spiderclan123):
    The OP asks whether knowledge of Java or Javascript language would be more useful to him when learning Unity.

    Post #2 (SkaredCreations):
    The first reply tells him that Javascript is very similar to UnityScript and Java is very similar to C#. In other words, if want to use UnityScript, learn JavaScript. If want to use C#, learn Java because its similar.

    Post #3 (lordofduct):
    Lordofduct tells the OP, if you are planning to go learn Java or Javascript before coming to unity, do not go out and learn Java (<--- JAVA -- He said do not go learn JAVA , NOT do not go learn JavaScript).

    Based on SkaredCreations' statement that JAVA is close to C#, lordofduct tells him, if he is considering to learn JAVA, that to instead learn C# because it would be a waste to go learn JAVA first and then switch to C#. He made NO mention of Javascript/UnityScript. He was giving the OP advice commenting on SkaredCreations post trying to clarify it so the OP wouldn't think learning Java would help him make a game in Unity.

    This is NOT lordofduct telling him to pick C#. He is clarifying SkaredCreation's post trying to help the OP and keep him from making a mistake by learning JAVA thinking it will help him make games in Unity. Nobody told him to pick C#. lordofduct said, if you're going to learn or already know JAVA, learn C# instead. He did not tell him to just go learn C#.

    Post #7: The OP replies to lordofduct's post #3:
    This IS the OP asking if he should pick C#. I don't see how you can believe otherwise. He asked it. Up to this post NOBODY has told him what language to pick or that either is better. Morning made the comment that future tutorials will be in C#, that is all, and the OP didn't even seem to understand that.

    The OP's reply to SkaredCreations is:
    It's clear by now that the OP is confused based on this post, but also asked a confusing question. It seems he does not know the difference between Java, Javascript, and UnityScript and doesn't even seem to know what languages Unity supports.

    The language comparison debate:

    Actually, you were the first one to start comparing languages:

    Post #9 (Tiles):
    You replied to his question "Oh so I should pick C# right?" by telling him that he could also use JavaScript or Boo. Then you followed it up by listing two advantages of JavaScript/UnityScript over the other languages. You also stated that all the languages are pretty much equal which something that many do not agree with, so of course that statement is going to be challenged.

    So the very next post (BlakeChristensen):
    Then you reply:
    Do you not realize that you both started the language feature comparison AND subsequently (indirectly) asked BlakeChristensen for his reasons for suggesting C#?

    In the next post, lord of duct even clarified his previous statement so as to not confuse the OP:
    It's at that point that the language comparisons begin between npsf3000 and you, directly challenging to your language comparison.

    You laugh and try to say I'm making some kind of excuse to justify talking about C#, well I am not. It's up there plain as day that the OP asked about learning C# before anyone ever suggested that he learn C#. I'm not trying to trick, manipulate, or twist anything.

    It's also clear how the conversation got to the point of debating the merits of the languages. You mentioned advantages of UnityScript as you saw it. Why is it wrong for C# users to then respond and talk about the advantages of C#? I joined this thread after you mentioned (and minimized) the compile speed difference issue, which I very recently discovered and posted my findings about after I converted my entire game to from UnityScript to C# and ran a battery of tests. (Something I haven't seen anyone else bother to do.)

    My feelings in general about the bad air throughout the forum on this topic:
    (Note this is how I feel about this topic and is not meant to be directed at you Tiles.)

    Why is it wrong for someone to give their honest opinion and suggest one language over another? Nobody needs a justification why they give advice. This is a support forum. I did not advise the OP to use C# over UnityScript in this thread, but I have done so in others. There is nothing wrong with that at all. And I believe I'm in a pretty good position to do so having used UnityScript for almost 3 years and have run into many problems with it which were easily solved by switching to C#. That's my experience. Everyone is entitled to share their experience and advise others without having to get the approval of the majority or having to walk on egg shells for an angry minority.

    There's something seriously wrong if everyone on this forum who wants to give their opinion about the merits/pitfalls of languages has to worry about setting off someone who is overly sensitive about the topic (as seen with ippdev's extremely inappropriate post [which has now been deleted]). After seeing the highly defensive reactions to people regarding UnityScript here and and a couple of other threads I posted my opinions on, it makes me not want to even say anything for fear of being attacked. That's a TERRIBLE environment for a forum. Suppression of opinion or ideas is wrong whether you agree with them or not.

    I don't doubt there really are some language "fanboys" out there (as I have clearly seen), but I'm not one of them. I'm just someone who has a whole lot of experience with UnityScript and switched over to C# and truly believes there are a number of great advantages to the language and some very annoying downsides to UnityScript as I have experienced. I would be remiss if I did not share my experience and conclusions if I feel it could help others. Everyone who decides something is better than something else is not a "fanboy" -- in other words, someone who irrationally defends something in the face of facts because of an emotional attachment. I got to the point of deciding C# was better because of my own experience and findings, not because I'm blindly following some emotion or movement. If Unity fixed many of the problems I found with UnityScript while using it, I'd recommend it. (Unity, fully support your language, dang it!) I'm not brand loyal, never have been.
     
    Last edited: Sep 24, 2012
  29. kingcharizard

    kingcharizard

    Joined:
    Jun 30, 2011
    Posts:
    1,137
    omg this pointless argument is still going on... interesting..
     
  30. Batzarro

    Batzarro

    Joined:
    Apr 22, 2012
    Posts:
    51
    I'm sure the original poster is soaking up all this info, and his final decision will change his life forever... or he stopped reading this thread a week ago.

    Indeed. Though I feel it is winding down, such a shame.
     
  31. CrazySi

    CrazySi

    Joined:
    Jun 23, 2011
    Posts:
    538
    This is so set up for a sequel...
     
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    That's what's sad about it. The OP (and any other newbies browsing) will never be able to get good information in ANY language discussion here because there's just too much personal crap flooding the boards that keeps getting in the way. I do not think it's pointless trying to help newbies and give them the benefit of your experience by pointing out how one language or another has advantages/disadvantages, but it all gets lost in the mess of defensiveness and hurt feelings.

    No, the choice of language won't affect the rest of your life, but it may affect the next few years if you plan on seriously using it. And if you do, you deserve to have as much information as possible so you can make an informed choice. (Because I faced the same confusion ~3 years ago when I came here and I wish I had had more information before I decided.)

    I don't understand why anyone would get angry because someone says the language they like isn't perfect. Language comparison has become a taboo topic and I think that's totally wrong.
     
    Last edited: Sep 23, 2012
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    I know everybody hates this thread, but this part of the discussion really piqued my interest. It's been tossed about for a long time that the languages are all compiled and end up the same in the end, but I've never seen any real data to show this. Since I'm in a pretty good position to do so having just recently converted my game to C#, I decided to do a little investigating.

    I prepared two identical projects of my game, one in C# and one in UnityScript. (Sorry, I don't have time to try Boo.) No special language optimizations were made during the conversion to C#. Here's what I found:

    Code (csharp):
    1. Loading and processing one level:
    2.    
    3.     In Editor: C#: 7.08s = (baseline)
    4.                US: 6.20s = 114.19%
    5.    
    6.     In Build:  C#: 4.33s = (baseline)
    7.                US: 5.06s = 85.57%
    Each test was run several times and averaged one after the other on the same boot. (The first load was discarded so that disk loading would not be a factor.) I even re-ran the tests again just to make sure there wasn't any issue being run in some particular order. There was very little variance.

    Two interesting findings:
    - UnityScript version loads in the editor about 14% faster than C# in this test.
    - C# version loads in final build about 14.5% faster than UnityScript.

    I'm very surprised to see this, especially the 14% margins. There actually are differences in speed among the languages, and not that small either. But what could be causing the difference? It's really strange one would run faster in the editor and the other would run faster in a final build. (I haven't done enough testing to determine why... that will be an ongoing investigation.)

    It got me thinking and I decided to do some benchmarks of some very basic processes:

    (Note: I included both for and while loops for Boo because of the speed difference I noticed using the for loop in some tests.)

    Writing to an int variable inside a for loop (15000000x / update)
    Code (csharp):
    1. RESULTS (fps):
    2. C#:          26.1 - 26.2 = (baseline)
    3. US:          26.1 - 26.2 = 100%
    4. Boo (for):   19.4 - 19.6 = 74.8%
    5. Boo (while): 21.2 - 21.4 = 81.68%
    Writing to a string variable inside a for loop (15000000x / update)
    Code (csharp):
    1. RESULTS (fps):
    2. C#:          26.1 - 26.2 = (baseline)
    3. US:          26.1 - 26.2 = 100%
    4. Boo (for):   19.4 - 19.6 = 74.8%
    5. Boo (while): 23.5 - 23.6 = 90.07%
    Appending a string variable inside a for loop (5000000x / update)
    Code (csharp):
    1. RESULTS (fps):
    2. C#:          16.3 - 16.4 = (baseline)
    3. US:          11.9 - 12.0 = 73.17%
    4. Boo (for):   11.9 - 12.0 = 73.17%
    5. Boo (while): 11.9 - 12.0 = 73.17%
    Writing to 100 indices in a string array (50000x / update)
    Code (csharp):
    1. RESULTS (fps):
    2. C#:          13.6 - 13.7 = (baseline)
    3. US:          10.3 - 10.5 = 76.64%
    4. Boo (for):    9.7 -  9.8 = 71.53%
    5. Boo (while):  9.5 -  9.6 = 70.07%
    Add to generic string list (1200000x / update)
    Code (csharp):
    1. RESULTS (fps):
    2. C#:          26.5 - 28.0 = (baseline)
    3. US:          26.5 - 28.0 = 100%
    4. Boo (for):   26.6 - 27.6 = ~100%
    5. Boo (while): 26.5 - 28.0 = ~100%
    Getting a component and casting to transform (100000x / update)
    Code (csharp):
    1. RESULTS (fps):
    2. C#:          34.2 - 34.5 = (baseline)
    3. US:          34.2 - 34.4 = ~100%
    4. Boo (for):   34.2 - 34.3 = ~100%
    5. Boo (while): 34.2 - 34.3 = ~100%
    Getting a component using generics (100000x / update)
    Interesting note: Using generics is slower than casting. Runs at 84.34% speed compared to casting.
    Code (csharp):
    1. RESULTS (fps):
    2. C#:          28.9 - 29.1 = (baseline)
    3. US:          28.8 - 29.1 = ~100%
    4. Boo (for):   28.7 - 29.0 = ~100%
    5. Boo (while): 28.7 - 29.0 = ~100%
    Here's the code for the first test for anyone interested in trying it. I have the code for all the others as well, but I will post those at a later date (and a more appropriate thread) after I do some more testing.

    Code (csharp):
    1. // C# TEST
    2. using UnityEngine;
    3. using System.Collections;
    4. public class SpeedTest : MonoBehaviour {
    5.     void Update () {
    6.         int x;
    7.         for(int i = 0; i < 15000000; i++)
    8.             x = i; 
    9.     }
    10. }
    11.  
    12. // UnityScript TEST
    13. #pragma strict
    14. function Update () {
    15.     var x : int;
    16.     for(var i : int = 0; i < 15000000; i++)
    17.         x = i; 
    18. }
    19.  
    20. // BOO TEST (for)
    21. import UnityEngine
    22. class SpeedTestBoo (MonoBehaviour):
    23.     def Update ():
    24.         x as int
    25.         for i as int in range(15000000) :
    26.             x = i
    27.  
    28. // BOO TEST (while)
    29. import UnityEngine
    30. class SpeedTestBoo (MonoBehaviour):
    31.     def Update ():
    32.         x as int
    33.         i as int
    34.         while i < 15000000:
    35.             x = i
    36.             i += 1
    (Edit: The preceeding tests were tested in the editor. I have only done a few of tests in the standalone player and the results are not always the same as in the editor. In a couple, all the languages came out even when that wasn't the case in the editor, but another test came out with a much bigger difference of 200%. Just FYI.)

    So it seems that on a very fundamental level, the languages do not perform uniformly. I will certainly be doing more benchmarks (I enjoy this kind of thing, believe it or not) and try to really determine where the differences among the languages. (I also like to do intra-language benchmarks -- I have a lot of data from the past few years on tests I've done with UnityScript to determine the most optimal code for certain tasks. I'd like to update all that with C# at some point and maybe post it for any optimizer-geeks out there.)

    It seems to me that the idea that all the languages produce the same code in the end is really just an urban legend. I certainly didn't think this would be the case. This definitely warrants more investigation.

    Note: This post is not meant to prove any kind of point other than our collective assumption that all languages end up performing the same in the end is false.
     
    Last edited: Sep 26, 2012
  34. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    That assumption has always been flawed because it assumes that each language has the same idiomatic way of solving a problem. However, performance comparisons can be interesting in the data they present, for example - I did this comparison earlier in the year:

    http://stackoverflow.com/questions/11572635/5x-performance-with-parallel-for-on-a-dual-core

    And found that there were some pretty massive differences between 32 bit 64 bit compiler, manual inlining no inlining, and F# compiler.

    With unity, we have the difficulty of multiple platforms and potentially different compilers [by using DLL's] to factor in.

    Using a slightly modified version of your tests:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class SpeedTest : MonoBehaviour
    6. {
    7.     void Update()
    8.     {
    9.         var sw = System.Diagnostics.Stopwatch.StartNew();
    10.  
    11.         int x;
    12.         for (int i = 0; i < 15000000; i++) x = i;
    13.  
    14.         sw.Stop();
    15.  
    16.         guiText.text = "C# " + sw.ElapsedMilliseconds.ToString() + "ms";
    17.     }
    18. }
    19.  
    I got these quick results.

    Editor - Both equal at ~ 40ms.
    Standalone [Win7] - C# 8ms, US 4ms.
    AoT [NaCL] - 14ms each.

    I discovered something interesting though - in Unity I get warnings that The variable 'x' is assigned but its value is never used for the C# script, but not for the US script. This means that if this, or a similar snippet occurred in a real world setting the actual value for C# would be 0ms because the programmer has been alerted to the useless code.

    Oh, and wondering how to improve C#'s performance when standalone?

    Code (csharp):
    1.  
    2.         int x;
    3.         System.Action action = () => { for (int i = 0; i < 15000000; i++) x = i; };
    4.         action();
    5.  
    Brings it back to par.

    If you want to investigate further, consider opening a new thread.
     
    Last edited: Sep 24, 2012
  35. Loius

    Loius

    Joined:
    Aug 16, 2012
    Posts:
    546
    I have a love/hate relationship with that post.

    I love that you're providing the information, but I hate that at some point I'm going to want to use it and to do that I'll have to learn Boo. xD
     
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    That's very interesting and informative. Thanks for that link! I didn't realize structural differences in code like that could make that much difference.

    True. My game level loading test was done with only a couple of minor (and not often used) externally compiled DLLs, so it's 99% Unity compiled code. But I get your point that the number of platforms and factors involved would make a thorough comparison extremely time consuming and potentially costly.

    That's odd. I just ran the same tests using your modified code and got 8ms for all 3 (standalone, Win Vista 64). I wonder what could account for the discrepancy in US between our runs? The System.Action version runs a few ms faster in the editor, but still at the same 8ms in the standalone.

    I agree. This is the wrong place for this.

    :) Boo looks interesting, but I'm so used to braces that I feel lost. Quite a departure from CS and US, that's for sure.
     
    Last edited: Sep 24, 2012
  37. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    [Deleted. I must be did something wrong.]

    Right now both C# and US show 7ms in standalone build (x86 and x64). CIL code is identical, no performance difference.
     
    Last edited: Sep 24, 2012
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    I don't mean to post too many of these here, but I find it interesting that the int test ends up equal in the final build. However the string append test does not. The gap actually widens in the standalone build. (Just posting so there's one example where a difference actually occurs in a standalone build and not just the editor).

    Editor:
    C#: 60ms - (baseline)
    US: 82ms - 73.17%
    Boo:82ms - 73.17%

    Standalone:
    C#: 18ms - (baseline)
    US: 37ms - 48.65%
    Boo:37ms - 48.65%

    Sources:
    PHP:
    // C#
    using UnityEngine;
    using System.Collections;
    public class 
    SpeedTestCS MonoBehaviour {
        
    void Update () {
            var 
    sw System.Diagnostics.Stopwatch.StartNew();
            
    string x;
            for(
    int i 05000000i++) {
                
    "";
                
    += "test";
            }
            
    sw.Stop();
            
    guiText.text "C# " sw.ElapsedMilliseconds.ToString() + "ms";
        }
    }

    // UnityScript
    #pragma strict
    function Update () {
        var 
    sw System.Diagnostics.Stopwatch.StartNew();
        var 
    String;
        for(var 
    int 05000000i++) {
            
    "";
            
    += "test";
        }
        
    sw.Stop();
        
    guiText.text "US " sw.ElapsedMilliseconds.ToString() + "ms";
    }

    // Boo
    import UnityEngine
    class SpeedTestBoo (MonoBehaviour): 
        
    def Update ():
            
    sw System.Diagnostics.Stopwatch.StartNew()
            
    as string
            
    for as int in range(5000000) :
                
    ""
                
    += "test"
            
    sw.Stop()
            
    guiText.text "Boo " sw.ElapsedMilliseconds.ToString() + "ms"
    (I posted as PHP code because copying/pasting from the code window, at least in IE, pastes the line numbers too. Silly.)
     
    Last edited: Sep 24, 2012
  39. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,532
    I think that's because the type difference.

    If I remember correctly...

    'string' in C# is a synonym for System.String

    where as in unityscript String is translated to System.String somehow (I don't know exactly, not super knowledged in unityscript). This is one of the reasons that 'String' in unityscript doesn't have all the same members as string in C#. And I'm betting the appending (which is the creation of new strings as they are immutable) may be effected by this.

    You should decompile the result and take a look at the CIL.
     
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    That makes sense. So I just tried using System.String in all 3 to declare the variable and the results came out exactly the same as before in both the editor and the standalone. (US and Boo being 73%/48% the speed of C#.)

    I'll look into the CIL. Thanks!

    (BTW, I realize these tests are completely synthetic and pointless, but they do at least show that the final code is not identical in all cases. A better example was my complete game [real-world test] that came out with a 14% difference in loading/processing.)
     
    Last edited: Sep 25, 2012
  41. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    C#'s IL code calls System.String.Concat(string, string)
    US's code calls Boo.Lang.Runtime.RuntimeServices.op_Addition(string, string) which then calls System.String.Concat(string, string)
     
  42. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,532
    Hrmm... so there's an abstraction layer with unityscript. Well there's another reason I might avoid it.
     
  43. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Just for fun:

    PHP:
    // C#

    using System.Diagnostics;
    using UnityEngine;

    public class 
    SpeedTestCS MonoBehaviour
    {
        private 
    void Start()
        {
            var 
    stopwatch Stopwatch.StartNew();
            for (var 
    015000000i++)
            {
                var 
    result Test("1""2""3""4""5""6""7""8""9""A""B");
            }
            
    stopwatch.Stop();
            print(
    string.Format("CS: {0}ms"stopwatch.ElapsedMilliseconds));
        }


        private 
    string Test(string a1string a2string a3string a4string a5string a6string a7string a8string a9,
                            
    string a10string a11)
        {
            var 
    s2 a1 a2;
            var 
    s3 a2 a3 a4;
            var 
    s4 a4 a5 a6 a7;
            var 
    s5 a7 a8 a9 a10 a11;

            return 
    s2 s3 s4 s5;
        }
    }
    PHP:
    // UnityScript

    #pragma strict
    import System.Diagnostics;

    function 
    Start()
    {
        var 
    stopwatch Stopwatch.StartNew();
        for (var 
    015000000i++)
        {
            var 
    result Test("1""2""3""4""5""6""7""8""9""A""B");
        }
        
    stopwatch.Stop();
        print(
    String.Format("US: {0}ms"stopwatch.ElapsedMilliseconds));
    }


    function 
    Test (a1:Stringa2:Stringa3:Stringa4:Stringa5:Stringa6:Stringa7:Stringa8:Stringa9:String,
        
    a10:Stringa11:String) : String
    {
        var 
    s2 a1 a2;
        var 
    s3 a2 a3 a4;
        var 
    s4 a4 a5 a6 a7;
        var 
    s5 a7 a8 a9 a10 a11;

        return 
    s2 s3 s4 s5;
    }
    CS: 8223ms, US: 15031ms (standalone)

    C# uses
    String.Concat(string, string)
    String.Concat(string, string, string)
    String.Concat(string, string, string, string)
    String.Concat(string[])


    UnityScripts still calls Boo.Lang.Runtime.RuntimeServices.op_Addition(strin g, string) for uncountable amount of times.
     
  44. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    PHP:
    // C#

    using System.Diagnostics;
    using UnityEngine;

    public class 
    SpeedTestCS MonoBehaviour
    {
        
    void Start()
        {
            var 
    stopwatch Stopwatch.StartNew();
            for (var 
    0150000000i++)
            {
                
    Test();
            }
            
    stopwatch.Stop();
            print(
    string.Format("CS: {0}ms"stopwatch.ElapsedMilliseconds));
        }

        
    void Test()
        {
        }
    }
    PHP:
    // UnityScript

    #pragma strict
    import System.Diagnostics;

    function 
    Start()
    {
        var 
    stopwatch Stopwatch.StartNew();
        for (var 
    0150000000i++)
        {
            
    Test();
        }
        
    stopwatch.Stop();
        print(
    String.Format("US: {0}ms"stopwatch.ElapsedMilliseconds));
    }

    function 
    Test ()
    {
    }
    C# 37ms, UnityScript 291ms (standalone)

    The reason is that UnityScript's functions are virtual by default.

    C#'s IL code
    Code (csharp):
    1.  
    2. ...
    3. call instance void SpeedTestCS::Test()
    4. ...
    5.  
    UnityScript's IL code
    Code (csharp):
    1.  
    2. ...
    3. callvirt instance void SpeedTestUS::Test()
    4. ...
    5.  
    Declaring the function as final eliminates the performance difference between the languages. Declaring the function as private also does the trick, because private-virtual combination makes little sense, so the function becomes non-virtual.

    Code (csharp):
    1.  
    2. final function Test() { }
    3. private function Test() { }
    4.  
    PS
    Another possible reason of performance difference could be not call/callvirt instructions themselves, but that virtual functions can not be inlined.
     
    Last edited: Sep 25, 2012
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
    Ahh, that's the kind of discovery I like to see because it has actual implications and can be corrected if known about (for the optimization nuts out there).

    My results with Boo added:

    Calling a method:

    Results (Standalone):
    C#: 83ms (private)
    C#: 83ms (public)
    C#: 294ms (public virtual)

    US: 83ms (private)
    US: 295ms (public)
    US: 83ms (public final)

    Boo: 87ms (private)
    Boo: 87ms (public)
    Boo: 296ms (public virtual)

    PHP:
    // C#
    using UnityEngine;
    using System.Collections;
    using System.Diagnostics;
    public class 
    SpeedTestCS MonoBehaviour {
        
    void Start () {
            var 
    sw Stopwatch.StartNew();
            for (
    int i 0150000000i++) Test(); 
            
    sw.Stop();
            
    guiText.text "C# " sw.ElapsedMilliseconds.ToString() + "ms";
        }
        private 
    void Test() {}
    }

    // US
    #pragma strict
    import System.Diagnostics;
    function 
    Start () {
        var 
    sw Stopwatch.StartNew();
        for (var 
    int 0150000000i++) Test(); 
        
    sw.Stop();
        
    guiText.text "US " sw.ElapsedMilliseconds.ToString() + "ms";
    }
    private function 
    Test() : void {}

    //BOO
    import UnityEngine
    import System
    .Diagnostics;
    class 
    SpeedTestBoo (MonoBehaviour): 
        
    def Update ():
            
    sw Stopwatch.StartNew()
            for 
    as int in range(150000000) :
                
    Test();
            
    sw.Stop()
            
    guiText.text "Boo " sw.ElapsedMilliseconds.ToString() + "ms"       
        
        
    private def Test() as void:
            
    pass
    I'm going to start a new thread on this and summarize what we've found so far so we can have a more appropriate place to post. I'll post the link back here.
     
  46. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    The performance difference is caused by inlining:
    PHP:
    using System.Runtime.CompilerServices;
    ...

    [
    MethodImpl(MethodImplOptions.NoInlining)]
    void Test()
    {
    }
    With NoInlining attribute non-virtual function calls become as "slow" as virtual ones.

    PS
    Or you can insert an empty loop inside Test function - functions with loops are never inlined (at least by Microsoft's jit-compiler.)

    Code (csharp):
    1. for (var i = 0; i < 0; i++) ;
     
    Last edited: Sep 25, 2012
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,627
  48. Myhijim

    Myhijim

    Joined:
    Jun 15, 2012
    Posts:
    1,148
    Am I too late?

    Which one is salted again?

     
  49. Batzarro

    Batzarro

    Joined:
    Apr 22, 2012
    Posts:
    51
    Yes you're too late. My ingenious joke which started with the reply to TylerPerry could have been continued if you'd been here earlier. I even had a long, thought out reply, pre-written, waiting for a mssg such as yours. Though the main reason why I didn't post it was because it kinda sounded like I was taking the piss out of someone, which was not intended because I didn't want to choose sides. Unfortunately the discussion become all serious like, and involved actual intelligent musings among fellow users, no insults what-so-ever!