
Porting the Unity Engine to .NET CoreCLR - benaadams
http://xoofx.com/blog/2018/04/06/porting-unity-to-coreclr/
======
drawkbox
CoreCLR will be nice for Unity with the 2x performance improvement.

I wish Microsoft had moved to it quicker and Unity wouldn't have had that lull
on Mono 2.x .NET and had to build IL2CPP.

When IL2CPP was being rolled out it was quite impacting to build size and
actually making iOS builds for a while in 2015 from like March to summer was
not workable for months. Now they have Android on it and it works well but
keeping all that up to date is cumbersome for a smaller tech/engine team.

I still would love a C++ engine/lib like they were going to do back when Apple
was forcing AOT instead of JIT languages around 2010 [1], but having a C#
engine that can be comparable in performance is killer.

As long as this update is smooth and is truly faster that would be welcome. It
was harder to trust Microsoft before during the Mono/.NET disconnected period
so Unity treaded carefully but after Microsoft bought Xamarin and went .NET
standard/core it seems like they are embracing and not extinguishing.
Microsoft's new focus is Azure and .NET core/standard help expand that as well
as its use by Unity (always a C# champion) and even Unreal Engine possibly
which some have attempted [2]. If Unity switches to .NET core/standard
possibly Unreal Engine will be compelled to add it natively.

[1] [https://blogs.unity3d.com/2010/07/02/unity-and-
ios-4-0-updat...](https://blogs.unity3d.com/2010/07/02/unity-and-
ios-4-0-update-iii/)

[2] [https://mono-ue.github.io/](https://mono-ue.github.io/) or
[https://github.com/xiongfang/UnrealCS](https://github.com/xiongfang/UnrealCS)

~~~
doomlaser
They put up their editor source code on Github recently
([https://github.com/Unity-
Technologies/UnityCsReference](https://github.com/Unity-
Technologies/UnityCsReference)), and originally it also included the full
source to their runtime garbage collector, which ended up being the standard
open source C++ boehm collector
([https://github.com/ivmai/bdwgc](https://github.com/ivmai/bdwgc)) from the
90s.

Unity should replace it with a reference counting object management system, or
update to a newer garbage collection technique to minimize the inadvertent
sweeps that cause huge choppy frame rate drops.

~~~
pcwalton
I hope they don't use naive reference counting. It would reduce throughput and
would not eliminate pauses. A standard incremental or concurrent generational
tracing GC would be a better choice. In games you have a lot of knowledge
about timing that you can use to help schedule GC: you always know (or should
know anyway) how much time there is until the next VBLANK, so you can use that
to bound pause times for your major collections.

~~~
doomlaser
Large parts of iOS and its ecosystem use automatic reference counting, and it
has a reputation for the interface being noticeably smoother than Android,
which uses Java's garbage collector.

~~~
pcwalton
Android doesn't use the HotSpot garbage collector.

------
sanxiyn
> But also, you will notice lots of work related to ARM32 and ARM64, including
> corporate work from Samsung for the Tizen platform

It's nice to see this recognized. Source: I worked on open source at Samsung.

~~~
voltagex_
Hopefully I can use some of the postmarketOS work to run Tizen on some more
devices. The ghost of the Nokia N900 lives on!

~~~
pjmlp
Actual Tizen has nothing to do with Nokia N900 spirit, other than using a
Linux kernel.

------
disordinary
I wonder if Unity regrets using Mono / C# as their scripting language, it
seems like they have so many workarounds and hoops that they jump through that
it must be a nightmare to maintain.

~~~
kevingadd
I don't think they had any better options available to them at the time.
Embedding and integration for an engine like Unity is just a tremendous
challenge no matter what stack you use. I've done this sort of integration w/
various languages (python, lua, vbscript, c#, actionscript, javascript, etc)
and C# is one of the most reasonable choices, if only because it was designed
with native interop scenarios in mind. There are pointers, there are structs,
etc.

Also keep in mind Unity did offer multiple scripting solutions - they had Boo
for a while (eventually dropped), and there's UnityScript, though I'm not
super familiar with how it works... C# is the one that won.

~~~
coldacid
Wasn't UnityScript just Unity-flavoured JS, like ActionScript was for Flash?

