Search Unity

Unity Roadmap/Research: .NET Profile Upgrade

Discussion in 'Scripting' started by Arowx, Apr 29, 2016.

  1. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Roadmap Info:
    My take on this is that Unity will move from the .NET 3.x framework to the latest .NET 4.6.x framework (or newer), is that right?

    But what will be the major benefits to Unity Developers (a question for the C# gurus)?

    Does 4.6.x have a real time or improved GC?

    What about .NET Core?

    Note: I was tempted to post this in Scripting but I think this could go way beyond just scripting, we could get major new language features?
     
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,190
  3. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    612
    A) Assuming it stays mono instead of the newer opensourcery microsoft things, adds the ability to use the mono SGEN gc, which is much quicker / consistent than the current one.
    B) Various language features, imo all relatively minor and/or purely syntactic sugar. Except possible the aggressive inlining attributes.
    C) Ability to use more recent libraries from the internet without refactoring, searching for 3.5 libs can be a pain.

    C) may even be the biggest benefit for the average user.

    Also, there may be a big difference here. The roadmap is talking about 'newer .NET profiles'; this is NOT equal to the newer .NET frameworks. So the garbage collection improvements mentioned by @Ryiah probably aren't applicable, though the SGEN gc improvement is there.
     
    Ryiah likes this.
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Having easy access to things like the tasks framework would be nice. Sure it's mostly sugar, but a little sugar is nice.

    But GC is the most important piece.
     
    AdmiralThrawn and Ryiah like this.
  5. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    What about the async/wait system introduced in 4.5?
     
  6. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    What kind of benefit it gives over, say, coroutines (which if my understanding is correct serves similar purpose)?
     
  7. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    612
    The async/await system is multithreading, coroutines is timeslicing within the main thread. Async/await will execute even if the main thread is busy doing things; coroutines will be done during the frame time (and therefore can't really improve fps, but can reduce stuttering).

    The async/wait system is syntactic sugar over the current System.Task/Func/Predicate etc. All of it can be done now but the async/wait syntax is nicer, so it takes (significantly?) less overhead to write multithreaded code.
     
  8. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    Ah, I see. So it's multithreading, eh? I wonder how much of Unity is thread-safe, otherwise no sense of doing multithreading with it if the thing you need to use isn't thread safe and you can't change it without source access.
     
  9. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Multi threading is great. In Unity its mostly about decoupling long running calculations from the frame rate. You can do some of the same things with coroutines, but not all. Coroutines still run on the main thread, so there is a maximum number of calcs you can do on a single core. But my favorite part about corooutines is that the operating system manages the time slicing and sharing. Managing time slicing manually with coroutines is a pain.
     
    landon912 likes this.
  10. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    OK moved but to Editor and General Support, we are talking about a future feature, maybe we need a roadmap topic or future of Unity topic. It would seriously save me from "spamming" the General topic!

    I like the sound of easy multi-threading.

    Isn't there a version of foreach that works in parallel?

    Now if only MS could upgrade C# .Net so it can work on the GPU and CPU, all that processing power!
     
  11. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    612
    Parallel ForEach
    ...Please, no. GPU programming is something different from CPU programming, and only works for a specific set of mathy things. And you wouldn't be using c# code anyway if you were that desperate for performance.
     
    AdmiralThrawn and Kiwasi like this.
  12. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    CUDAfy .NET allows easy development of high performance GPGPU applications completely from the Microsoft .NET framework. It's developed in C#.
     
  13. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    612
    Ah, right - I forgot that quite some GPGPU processes don't require a lot of cpu pre-processing (or the pre-processing is trivial compared to the gpu time). Still, for games there's already the compute shaders, though the setup is different.