Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Huh, I never knew Unity used its own CLR implementation. Any idea why?


I think its implementation is a fork of a 2006-era Mono (a clean room reverse engineered .NET implementation). After a few releases, they had a falling out with the Mono team over licensing, meaning they got stuck on an old release.

Besides that, they made a bunch of proprietary changes to Mono to make it run on their engine, and to be able to export to literally any platform under the sun.

A lot of platforms, like iOS and consoles have (or had) a strict no-JIT policy, so they needed to come up with statically compiling code to said platforms. One of the methods they used was IL2CCP, which turned .NET bytecode, into horrible looking C++, full of goto-s, weird labels and structs getting passed around.

Considering some platforms had limitations like you had to compile the game solely with the C++ compiler the platform supplied, not sure if they had a better solution, but it's still horribly hacky.

They've been manually syncing up changes from the more recent versions, but I can't really tell, at what pace.

But the thing is, even the official Mono has never really kept pace with MS's implementation, and recently, after the acquisition, Mono was dropped by MS in favor of the CoreCLR.


At the moment, Unity is in the middle of the move to "vanilla" flavour of .NET aka CLR. Once they do, it should dramatically improve GC performance in Unity and enable an easier route for targeting AOT-requiring platforms like iOS (it is officially supported as a fully-fledged target for NAOT starting with .NET 8, and there's even rich interop directly with Swift in the plans).


Which platforms require you use a single C++ compiler?


Unity is older than the Core runtime. They had to use Mono as their base.


Assuming they had C# or .NET as a constraint. I'd wager not, they just wanted something that would work for "scripting".


C# and their own custom clr language was the only supported languages, so yes.


There were lots of other languages with support available.

I don't think Unity had anyone mandating they had to use .NET or C#.


It used to be C# along with JS and Boo (a Python for .NET). All docs had examples in order of preference for JS, C#, Boo.


They called it javascript, but it was not. Not even very similar.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: