Unity 5 and Mono Runtime

Discussion in 'Unity Gossip' started by Infernno, Mar 19, 2014.

  1. Infernno

    Infernno

    Member

    Joined:
    Dec 15, 2012
    Messages:
    63
    Hi everybody,
    I watched a video about the new version of Unity, and really looking forward to its release.
    And one thing that makes me sad is that there is no information about Mono Runtime update.
    I know that upgrade to latest Mono runtime is not that easy due to licensing issues =/
    But Unity still uses the old version of Mono 2.x, which has terrible GC, a lot of bugs and performance problems. Current version of Mono 3.x made great progress but it seems to be Unity will work on this...let's say old junk.

    So, i'd like to hear your opinion on this..and preferably an official comment:)
    P.S. I'm sorry, I did not notice that there is another post about it.
    Last edited: Mar 19, 2014
  2. ShadowK

    ShadowK

    Member

    Joined:
    Sep 5, 2013
    Messages:
    1,381
    n
    Yes everyone is going flappy birds on the situation, between me you and a rather delicious looking lamp post. A birdy (Figure it out for yourself) let drop a secret about removing mono completely. Because let's face it, nobody wants mono it's a horrible affliction.

    P.S Unity people, be careful what you post on that bird resemblance place . There are people who look at it, when their very very very, very bored...
  3. Chariots

    Chariots

    Member

    Joined:
    Sep 29, 2013
    Messages:
    308
    Well, that is certainly not going to open up a can of worms :)
  4. cynic

    cynic

    New Member

    Joined:
    May 21, 2013
    Messages:
    142
    Yea well, the last official comment on this is pretty much that they -are- working on it. Whatever that might actually mean for the future. :p

    Hahaha.:D
  5. Arowx

    Arowx

    Member

    Joined:
    Nov 12, 2009
    Messages:
    2,194
    Interesting if they are using asm.js which is currently setup for C/C++ to javascript compilation, what are they doing about Mono?

    They could write a converter but then they are back to the problem of trying to drag everything and the kitchen sink in Mono / .Net into javascript. Which is technically challenging but could also produce more licensing problems?

    Remember the issues they had with Flash, some features were compatible between languages but some are not and would throw out lots of errors from the actionscript compilation process.
  6. ShadowK

    ShadowK

    Member

    Joined:
    Sep 5, 2013
    Messages:
    1,381
    So from the birdy in the sky, (Also mentioned at GDC) so if anyone was there they'll know the same anyway. Unity are supposed to have a .Net to C++ converter in the works.. Which makes perfect sense really, you have Xcode for Mac deployments, GNU compiler stack wrapper / C++ for PS4, windows is obvious etc. etc. (I only dev for them so I don't know the rest :D).

    Well spank my buttocks and call me charlie, GC may be a thing of the past.. Also they can take that money and spend it on some terrain UPP-GR-AA-YY-EE-DD-S?

    You have to admit, one reason why CryTek made a killing was due to everything being proprietary pretty much. So it's not a bad idea for Unity to take the core in that direction.. Then again, it's not a bad idea to have tea and biscuits which is next on my list to do.
    Last edited: Mar 19, 2014
  7. Chariots

    Chariots

    Member

    Joined:
    Sep 29, 2013
    Messages:
    308
  8. jonas echterhoff

    jonas echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Messages:
    450
    So, yes, as ShadowK has been hinting at, we have built a new technology to take .NET bytecode and emit corresponding C++ code over the past two years. This lets us get your code to JavaScript + asm.js by then compiling the emitted C++ code using emscripten. All of this is transparently part of the build process. While we don't expect 100% code compatibility, we are already in a state which is much better then what our Flash code converter could ever do. It will always be restricted to AOT compilation, however (similar to iOS), so anything which requires dynamic code features in .NET will not work.
  9. Nasarius

    Nasarius

    New Member

    Joined:
    Oct 1, 2012
    Messages:
    17
    Yeah, so even if this all works out well, we're still mostly stuck with .NET 2.0 and no compatibility with a lot of third-party libraries.

    Which is absolutely fine if you're considering that .NET will become a legacy or supplementary solution for Unity, and that writing C++ code directly is the preferred solution for performance. I'd be perfectly happy with that. Just give Pro users a C++ API and I won't particularly care about Mono anymore.
  10. Chariots

    Chariots

    Member

    Joined:
    Sep 29, 2013
    Messages:
    308
    Is this just a special case for WebGL, or can desktop developers benefit from it as well? I'd imagine even C# converted C++ code would run way faster than what we currently have.
  11. ShadowK

    ShadowK

    Member

    Joined:
    Sep 5, 2013
    Messages:
    1,381
    Well were stuck with a god old version now anyway, might as well remove the garbage collection from the equation..
  12. jonas echterhoff

    jonas echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Messages:
    450
    In 5.0 this Technology will only be used for WebGL. We are aware that it has more potential then that and you may see it on other platforms at some later point, but we have no specific roadmap for that yet.
  13. jonas echterhoff

    jonas echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Messages:
    450
    It is true that some .NET features and some third-party libraries won't work with AOT. That is the same as using AOT platforms (like iOS) in mono, really (even if we used the latest mono). How does the AOT approach limit you to .NET 2.0, though?
  14. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Messages:
    10,333
    But also secures the source code better - so people who release demo assets or their games, do not have red gate pull it all apart again? If this is something that would work on any target platform it would be fantastic.

    Even more fantastic? The ability to directly inject your own C++ right there in the editor. Perhaps with a compiler directive. Attract the world's C++ programmers because even though I wouldn't - I'm sure many would.
  15. JonathanBolten

    JonathanBolten

    Member

    Joined:
    Dec 15, 2012
    Messages:
    41
    I'm probably in a minority camp, but I actually ENJOY programming in C++ more than C#. There's too much hand holding, and garbage collectors are so annoying.

    I know C# is too big of a selling point for Unity to ever remove, but I can always dream about the addition of more direct C++ support. :)
  16. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Messages:
    10,333
    Indeed, seems senseless not to now things are vaguely moving in this direction. Long term, Unity needs to be self sufficient.
  17. Arowx

    Arowx

    Member

    Joined:
    Nov 12, 2009
    Messages:
    2,194
    It opens the way to potentially bypass mono on every platform, allowing for compiled build targets. While still allowing developers to script in C# and the possibility of adding C++ in the future.

    Nice one UT ;)
  18. joncham

    joncham

    Unity Technologies

    Joined:
    Dec 1, 2011
    Messages:
    31
    Just to be clear, the generated C++ still executes in a 'virtual' environment (our own equivalent of the mono runtime). It's just that C++ source is produced from the IL and compiled with a C++ compiler to produce the native code, rather than using the mono JIT or AOT compiler.

    A GC is used to managed memory, as the source IL doesn't contain enough information to manage memory like traditional C++ development. For example, cycles are allowed and a GC is the only mechanism to handle something like this.
  19. Gigiwoo

    Gigiwoo

    Member

    Joined:
    Mar 16, 2011
    Messages:
    1,517
    Does this mean C# will go away in Unity? I'm hoping I'm reading too much into all this, cause after 20 years of C++, I'm sick of it.

    Gigi
  20. joncham

    joncham

    Unity Technologies

    Joined:
    Dec 1, 2011
    Messages:
    31
    This technology is used to support WebGL and it is completely transparent to the user. You write everything like normal in your choice of C#, UnityScript, etc and everything is converted at build time. It is analogous to current AOT platforms like iOS where .Net assemblies get converted into native binaries.
  21. Nasarius

    Nasarius

    New Member

    Joined:
    Oct 1, 2012
    Messages:
    17
    Sorry, I meant .NET 3.5 and C# 3.0, which is before the "dynamic" type. I'm just saying that it doesn't really offer a path forwards from the status quo of Mono 2.6.5.

    Really there are two possible ways to take this news: either that we're truly stuck with nothing but Mono 2.6 and this is just a workaround for WebGL, or that you're actually working on long-term alternatives. UT doesn't seem to be willing to comment on this at all.
  22. Doddler

    Doddler

    Member

    Joined:
    Jul 12, 2011
    Messages:
    176
    It seems more likely that at the current stage, they don't know if it will ultimately be used for anything beyond WebGL. On paper it sounds like it has a lot of potential, but I kind of agree that they wouldn't want to commit to any of those potential avenues unless they were sure they were moving in that direction.
  23. Marionette

    Marionette

    New Member

    Joined:
    Feb 3, 2013
    Messages:
    153
    one of the main reasons that unity attracted me was that i, and others, could leverage their existing C# knowledge, as well as those learning C# to use with unity could also leverage some basic knowledge in the real world.

    i came up through C++ and i hated it the entire time. i spent more time screwing around with includes, and strings, and unicode vs widechar/_MCBS and just general 'cobbleware' and the multitude of compilers.. what a complete pain in the a**...

    don't even get me started on ATL/COM/IDL, reference counting etc etc.. folks not understanding the basic differences between releasing and deleting etc.. wacked out string libraries, and home grown smart pointer implementations..

    all of that frustrating crap went away when C# came on the scene. true, there were trade offs, multiple inheritance, templates, macros etc but i could focus on what the code is supposed to do.

    for example: take 2 developers. 1 using C++ and 1 using C#. have them create the same type of project and let them at it. which do you think will get to be able to compile something useful faster?

    when i found unity used it as a scripting language, i was ecstatic since it made complete sense to me. even using mono made sense. what doesn't make sense is using a version of mono that completely gets in the way of the language it's supposed to be supporting. compounding that with a new converter to C++ makes even less sense to me since now, you'll have to implement (new, as .net improves) language specific features into the converter, or more worryingly, NOT implementing them. which means, we're kind of back at where we started, right?

    for those that don't know it, but even with a converter to C++ there will ALWAYS be some sort of memory management, whether it's language dependent (ATL/COM reference counting) or some version of homegrown, you will always have to rely on that as a 'GC'.. unless of course you guys are going to let us choose to create/allocate things in the heap/stack ourselves? and then relying on us to release/delete them properly ourselves? and if that was the case, why not have just gone to LUA or C++ from the beginning?

    my opinion is that UT *gained* a ton of folks by using .net/mono. C# is relatively easy to learn to use. especially vs C++ or even LUA.

    one of the main things i dig about this engine is that i have some relative power to code things backed up by .net...

    sorry to be negative, but i think this is only going to shed you of a lot of your user base..
    Last edited: Mar 19, 2014
  24. joncham

    joncham

    Unity Technologies

    Joined:
    Dec 1, 2011
    Messages:
    31
    What is going to shed a lot of the user base? Nothing has changed from the users perspective as far as I can see.
  25. Marionette

    Marionette

    New Member

    Joined:
    Feb 3, 2013
    Messages:
    153
    there are already things in the .net 4.0+ that we can't even think of using that we'd like to. things that we're waiting for you guys to either implement or update your lic with xamarin as they have already updated things.

    the issue i'm concerned about is that if you write a converter, for us to get new functionality, you guys are going to have to *specifically* implement that, right? the thing is, a lot of us out here hold out hope that a deal with xamarin can be worked out, or even that you guys with your branch, will implement the major missing bits that we'd like to use that are available in .net right now and have been.
  26. Gigiwoo

    Gigiwoo

    Member

    Joined:
    Mar 16, 2011
    Messages:
    1,517
    Happy camper == Me!
    Gigi
  27. joncham

    joncham

    Unity Technologies

    Joined:
    Dec 1, 2011
    Messages:
    31
    At this point, the only change from the status quo is that a tool now exists which converts IL into C++ to allow scripting to function in WebGL. Anything beyond that is just speculation.

    We know the current situation with the mono version we ship is problematic and are looking at how best to address that situation.
  28. Marionette

    Marionette

    New Member

    Joined:
    Feb 3, 2013
    Messages:
    153
    understood. and i'm not trying to be a jerk, just trying to express how important this is to not only myself, but others.
  29. TheOtherMonarch

    TheOtherMonarch

    New Member

    Joined:
    Jul 28, 2012
    Messages:
    40
    I cannot believe what I am hearing. Mono has millions of developer hours and decade of work completed. The idea that you can every try to replicate that is ludicrous.

    I have 100s of thousands of lines of code in c# that has already been debugged. Almost 5 years of work. I already paid my $600.00 for unity 5.0 I am locked simple because of legacy code. Update mono already.

    This will be a sucky ass solution. Going to .net would be fine even if you could only release on xBox and PC.
  30. cynic

    cynic

    New Member

    Joined:
    May 21, 2013
    Messages:
    142
    I believe it was Graham saying something along the lines of "we're working on it" in the Unity 5.0 announcement thread. Now I'm wondering whether this converter of yours is what he meant by saying that. Judging from your statements there is still no solution to the Mono situation on the horizon, other than that you're "thinking" about it. Is that more or less accurate?
  31. Dantus

    Dantus

    Member

    Joined:
    Oct 21, 2009
    Messages:
    3,307
    This technology is the best chance for Unity to keep Mono and upgrade for a reasonable price and all that with a contract that has clauses for future updates. They can now demonstrate Xamarin that they don't rely on Mono and that there is another solution. This gives Unity a strong position for a good contract. And in the case that Xamarin doesn't agree, Unity can broadly use the new technology and make Mono obsolete in Unity. Unity could even decide to become a direct competitor by providing a highly optimized .Net to native code solution. I doubt that Xamarin is interested in that kind of competition.

    Edit: With "technology" I mean the IL to C++ compilation and everything it takes to executed the .Net code natively.
    Last edited: Mar 23, 2014
  32. TylerPerry

    TylerPerry

    Member

    Joined:
    May 29, 2011
    Messages:
    5,024
    Using this technology is it likely that C++ would be added? If the code is compiled from bytecode to C++ surely you could easily add C++ then just have it added after the bytecode compilation?
  33. angrypenguin

    angrypenguin

    Member

    Joined:
    Dec 29, 2011
    Messages:
    4,632
    Unusually rampant speculation-like musings: I imagine that if you can reliably get our code to C++ that you'd have more options from there as to what to do with it. The fact that you're currently planning to use that in a VM doesn't mean that will be the only way it can ever be used... (Though I do understand that there are implications since it comes from bytecode.)
  34. Smooth P

    Smooth P

    Member

    Joined:
    Sep 15, 2012
    Messages:
    212
    I just puked in my mouth, and it wasn't a rainbow... UT's grand idea for the future and what you've been spending time and money on is triple compiling code and moving FURTHER into AOT restrictions? Should I just sign up for my lobotomy now?
  35. GCat

    GCat

    Member

    Joined:
    Jul 31, 2012
    Messages:
    76
    Well said.
  36. Dantus

    Dantus

    Member

    Joined:
    Oct 21, 2009
    Messages:
    3,307
    What kind of restrictions do you mean? There are a few regarding genericity and everything else I am aware of should not be used anyway.
  37. makeshiftwings

    makeshiftwings

    Member

    Joined:
    May 28, 2011
    Messages:
    1,505
    What is the GC you're using? Is this an in-house GC that you guys wrote yourself? Is it generational?

    Also, mark me down as one of the "this actually sucks and I don't want it at all" group. It's fine as a tool to temporarily wedge stripped down C# code into something WebGL can handle. It's not a solution for actual .NET development going forward.

    You guys have been "looking into it" for five or six years now. It's time to stop looking and actually do something about it.
  38. Dantus

    Dantus

    Member

    Joined:
    Oct 21, 2009
    Messages:
    3,307
    They have done their job. Besides upgrading Mono, they may also enhance their implementation for WebGL, such that it becomes the default in Unity.
  39. makeshiftwings

    makeshiftwings

    Member

    Joined:
    May 28, 2011
    Messages:
    1,505
    No offense to Unity, I know they've got some smart devs, but I have absolutely zero faith that they've somehow figured out a "highly optimized .NET to native code solution" when no one else in the industry including Microsoft or Mono have figured out how to do it. Especially since they haven't yet demonstrated they can do a "not completely terribly optimized modification of Mono" in the decade since it came out. To me this sounds like a buggy SWIG-based beta parser that will turn simple .NET 2.0 AOT compatible code into possibly-working-but-maybe-not C++ that then runs through a home made non-native interpereter that is probably slower than a normal .NET JIT and is built on a tacked on and untested garbage collector.
  40. makeshiftwings

    makeshiftwings

    Member

    Joined:
    May 28, 2011
    Messages:
    1,505
    What? They haven't upgraded Mono. That's the point of the thread. Also I sure as hell don't want WebGL to be any kind of default. If they stop supporting platform-based builds and expect us to run everything through Chrome I would drop Unity like a hot potato.
  41. cynic

    cynic

    New Member

    Joined:
    May 21, 2013
    Messages:
    142
    Except that they didn't upgrade Mono and didn't hint at actually upgrading Mono in the near future, unless I just missed something.
  42. cynic

    cynic

    New Member

    Joined:
    May 21, 2013
    Messages:
    142
    Ditto.
  43. Dantus

    Dantus

    Member

    Joined:
    Oct 21, 2009
    Messages:
    3,307
    We most likely have that situation due to licensing reasons.

  44. makeshiftwings

    makeshiftwings

    Member

    Joined:
    May 28, 2011
    Messages:
    1,505
    Yes, it's absolutely because of licensing reasons; they have pretty much flat out stated that the reason they won't update Mono is because Xamarin is demanding a ton of money to let them do it, and Unity is trying to play chicken by showing Xamarin that Unity users are just fine with using the Mono version from 10 years ago and that the upgrade isn't really worth that much money. To me, it's long past time to give up the charade. Xamarin clearly has called Unity's bluff, and as time goes on and Unity's Mono keeps getting more and more out of date, Xamarin is going to just keep raising the price. Sometimes you have to know when to fold.
  45. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Messages:
    10,333
    ~Well the only problem I have with older mono is that GC needs a good tweak. That's just about my only problem. If Xamarin want to get funny over one single static link, then that's their problem and their loss. I'm sure there's nice people working there and all, and this is all just legalese silliness though.
  46. Murgilod

    Murgilod

    Member

    Joined:
    Nov 12, 2013
    Messages:
    1,031
    You know what? Calling bullshit on "licensing reasons" being a valid excuse. Unity's version of Mono has never been terribly up to date, with the version we have now coming up on five years old. The new generational GC, which has shown substantial improvements over the old one, was introduced four years ago. Unity even kinda has trouble updating its own built-in things, such as the absolutely antiquated terrain engine. Unity also has a tendency to license new things all the time and then implement them halfway, so I kinda have to doubt this is a straight money thing at this point.
  47. makeshiftwings

    makeshiftwings

    Member

    Joined:
    May 28, 2011
    Messages:
    1,505
    Or my other solution, if the bad blood between Unity and Xamarin has progressed to the point where they refuse to pay. First, do NOT go the way of trying to drop .NET and switch to C++ this late in the game. Don't try to invent an in-house.NET to C++ converter for all platforms. If you've got one for WebGL then that's fine. In my opinion, Unity should clean up the Mono bindings, refactor their code to expose all the points that touch Mono, and use an IoC wrapper or something to allow dropping in an interpreter. Then they could write an interpreter wrapper for MS .NET and Mono, and we the users could download whatever version of Mono or MS .NET we want, thereby removing Unity's need to actually license anything from the equation. The only problem then would be needing to statically link the interpreter for iOS builds, and for that they can just keep the crappy current Mono build that they own. iOS deployments would have to deal with it, but the other platforms would be fine. Maybe it would get iOS users to complain enough that they could convince the Apple Store that they need to support dynamic linking in order to keep up with the other phones.
  48. Dantus

    Dantus

    Member

    Joined:
    Oct 21, 2009
    Messages:
    3,307
    Which bluff? Your so called bluff seems to work quite well already.
  49. Meltdown

    Meltdown

    Member

    Joined:
    Oct 13, 2010
    Messages:
    3,581
    If Microsoft buys Xamarin, one has to wonder how this will affect the licensing to Unity.
    Microsoft and Unity are pretty tight at the moment.
  50. tatoforever

    tatoforever

    Member

    Joined:
    Apr 16, 2009
    Messages:
    2,285
    My take on this is that if Unity keeps growing, Xamarin will grow alongside Unity (as Unity is really dependent of mono right now) and the more it grows the harder it'll be for Unity to get a new mono license.
    Solution: keep supporting your current version of mono but build your own independent C++ API. This will cut Xamarin wings (which have been a bit arrogant with their license terms lately). Believe me, if Unity haven't been unable to get a new deal with Xamarin it really means Xamarin either want a really huge pie chunk or simply doesn't give a sh*t about Unity. For me sticking with C++ and a GC provided by Unity would be a good starting point and probably better than the outdated version of mono which is leading nowhere seriously. At this point I don't think you'll ever get any new license of mono, you all can start forgetting about any new .net frameworks!
    PS: Please take notes on UE4 C++ API, it offers both flexibility and power while being very elegant and clean.