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

Small clarification.

It is faster than the old Mono they ship.

Their Mono is at best Mono 2.10, about three years old, without any of our optimization work for three years, very notably, a lot of the LLVM support, or the new garbage collector.

That said, the il2cpp looks like a very promising an interesting project, so kudos for that!



Yes, I think those benchmarks are based on the Mono they use, which is indeed old. I would be very curious to see benchmarks compared to trunk Mono - should be interesting.

My information may be out of date, but typically people tell me that Mono tends to not match Microsoft's .NET implementation in speed, and in turn, .NET tends to not match native C++ either. So I would still guess il2cpp can win here. Or are there benchmarks showing Mono matches .NET and/or native C++?


It's important to consider that C++ code, is not the same as C# to C++ code. The Facebook guys originally converted PHP to C++ code for speed, just like il2cpp, but eventually they wrote a JIT because it was faster AND they could keep the dynamic features like code generation and dynamic loading.

C# is ment to be a safe language, unlike C++ which has, among other things, the notion of undefined behaviour and manual memory management. This is what makes C# initially slower than C++. You might be able to compensate with a JIT, but safety still costs. Not to mention, the Unity guys will still probably have to implement their own GC and spend years on optimisations.

Also, several games are using dynamic loading for things like plugins and mods, as far as I know, il2cpp will force them to change how this is implemented.

From my standpoint. The cheapest option, and best option for everyone really, is to continue using (an up-to-date) Mono and instead allow for writing games in C++ as well.


> From my standpoint. The cheapest option, and best option for everyone really, is to continue using (an up-to-date) Mono and instead allow for writing games in C++ as well.

Yes. It seems logical that there have been some licensing negotiations that we're not aware of, and maybe all this is part of ongoing negotiations too.

What's puzzling is that they're keeping il2cpp closed. Opening it would make sense and would show they mean serious business but keeping it closed makes me wonder if their risk will pay off or if it's just a bluff.


Good point about code compiled to C++ not being the same as idiomatic C++ code.

However, unlike PHP which is dynamic, C# is statically typed. It is a much more direct match for C++, and performance should be pretty good.

But with that said, I think your point still stands, as there are still things like bounds checks in C# which would need to remain when compiled to C++, while idiomatic C# might not have those checks.

I wonder though if those bounds checks couldn't be disabled in some cases. Sandboxing isn't a concern on the Unity WebGL port, for example, since the browser provides that, so il2cpp code doesn't need to be safe in that sense.


C# has very defined behaviour that when "ported" to C++ is going to result in similar speed hits. Allocations are zero'd out. boxing/unboxing objects, array bounds checking.

GC is going to be the big hit as you're still going to need to pay for that even in C++ land. I'm not really seeing what you'd get over just C# with a more modern JIT unless you start converting to non-safe C code and doing sneaky c stuff behind the scenes (and I'm sure absolutely nothing will go wrong*).

The webgl stuff is fine to not be bound (I'm assuming it's being converted to js anyway?) but anything running in the plugin better be.


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.


All 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.


But 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!


"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.


It is still pretty new, yes, but it seems to work well (see for example 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.


Regarding the C# -> C++ -> JS thing, it really must alot easier to do a C# -> JS conversion...


>NET tends to not match native C++ either

Let's see if with the new RyuJIT and the AOT compiler sharing the Visual C++ compiler backend in the upcoming .NET, that still holds.


Can't be understated - I've benchmarked my current MonoGame stuff with 2.10 and 3.10 and the modern stuff is leaps and bounds better in terms of GC performance (that alone being my biggest hurdle). Perf improvements have been coming very steadily and while there are areas I wouldn't recommend it for I wouldn't hesitate in recommending it for the logic level of many games.




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

Search: