3 ms·
First and foremost, compiling to C++ means you then optimize it using a full C++ compiler like gcc or clang+LLVM. Not only are those compilers generally better
by azakai 12y ago
First and foremost, compiling to C++ means you then optimize it using a full C++ compiler like gcc or clang+LLVM. Not only are those compilers generally better than JITs, they can also do whole-program optimizations. JITs are getting that too (Dalvik=>ART, newer .NET runtimes), but the C and C++ compilers have a big head start.
(In theory a JIT can do all the things C++ compilers do, of course.)
Aside from performance, Mono must be ported to each target platform (I've heard this can take significant effort). On the other hand, well-written C++ code should just run (the rest of the engine is in C++ anyhow).
edit: yes, Unity compiles C# to C++, then to JS to run in the browser.
- Skinney 12y agoAll true, but you're forgetting that Mono can AOT compile C# to native code using LLVM. That's how Xamarin.iOS works. So il2cpp doesn't really bring anything new to the table.
- pdaddyo 12y agoBut it does solve their biggest issue - ultimately enabling Unity projects to publish to the web without plugins (WebGL / javascript). Once all code in a Unity project eventually ends up as C++ (even if it started as C#), they can leverage Emscripten, asm.js and related technologies to enable Unity devs to use C# in the editor, which is converted to C++, and ultimately Javascript. It seems crazy, but it might just work!
- cwyers 12y ago"But it does solve their biggest issue - ultimately enabling Unity projects to publish to the web without plugins (WebGL / javascript)." I'm not really sure that is their biggest issue; HTML5 publishing of Unity games seems mostly a novelty at this point.
- azakai 12y agoIt is still pretty new, yes, but it seems to work well (see for example https://hacks.mozilla.org/2014/10/unity-games-in-webgl-owlchemy-labs-conversion-of-aaaaa-to-asm-js/ https://hacks.mozilla.org/2014/10/unity-games-in-webgl-owlch... ), and it's been one of the most-asked for features by Unity users on their forums.
- Skinney 12y agoRegarding the C# -> C++ -> JS thing, it really must alot easier to do a C# -> JS conversion...