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

The Unity game engine created a library that transpiles C#(technically the byte-code) into C++[1].

The generated code isn’t particularly readable and it comes with some security issues[2] but the upshot is you have the benefits of a C++ compiler.

[1]https://docs.unity3d.com/530/Documentation/Manual/IL2CPP.htm...

[2] https://github.com/djkaty/Il2CppInspector



> the benefits of a C++ compiler.

Is there any? I think most modern compiler share the same codegen backend.

You don't get the benefit of the frontend when you transpile.


> Is there any? I think most modern compiler share the same codegen backend.

JIT-focused .NET is one of the ecosystems disparate from AOT-focused LLVM. While there's a bit more cross pollination now, at the time the C# to C++ transpiler was authored, there was much less so. I've taken a stab at porting mono to a new platform at a similar time period - it was rather nontrivial (I ran out of time and thus failed.) Worse still, many of Unity's targets (e.g. iOS, XB1, ...) explicitly ban JIT technology in the name of security, which wasn't something I had to deal with.

A MSIL bytecode -> C++ translator might be pretty quick and dirty... yet effective, gives you AOT compilation, avoids the need to explicitly target every architecture by hand. For all it's faults, it's not too terribly hard to figure out how to compile C++ for a given platform, typically, generally requiring exactly zero reverse engineering.




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

Search: