4 ms·
Unity has gone far beyond cross compilation of C# to C++ now. Their Burst compiler is capable of compiling C# straight to assembly with vectorization optimizati
by hesdeadjim 8y ago
Unity has gone far beyond cross compilation of C# to C++ now. Their Burst compiler is capable of compiling C# straight to assembly with vectorization optimizations. They’ve even ported core C++ components of the engine into bursted C# because the resulting code is faster and a quarter of the size. It’s impressive stuff.
- fendy3002 8y agoI wonder why they choose c# over other language common for scripting / gaming engine, like lua c++ or even java. I think C# is good and designed well (over java), and I wonder if it's the same for them.
- mycall 8y agoUnity features three scripting languages; JavaScript/UnityScript, C#, and Boo
- MattRix 8y agoThis is technically true, but these days using anything other than C# is strongly discouraged.
- lasagnaphil 8y agoUnityScript and Boo are deprecated and most people strongly discourage from using it.
- ecuzzillo 8y agohttps://blogs.unity3d.com/2019/02/26/on-dots-c-c/ https://blogs.unity3d.com/2019/02/26/on-dots-c-c/ has a high-level overview for why not C++. Moreover, Unity has invested heavily in the c#/.net/mono ecosystem; the editor runs on mono, and the runtimes are all either IL2CPP (an in-house translation from .NET bytecode to C++) or mono as well. It would be a truly crazy amount of work to switch, for little or no clear benefit. If one were picking a language today to write an engine in, Rust might be a reasonable competitor, but it's also fairly new and is arguably less noob-friendly. C# offers a nice ramp from new programmer to performance-critical AAA with burst.
- jayd16 8y agoThey most likely chose C# because mono they originally targeted macs and mono compiled to that. Ultimately it was the best of the three languages they chose to support (Javascript and Boo being the others).
- hesdeadjim 8y agoC# was the only choice they had of a typesafe language that had a runtime portable to many platforms (Mono). C++ is terrible for fast iteration times and is capable of hard-crashing with simple mistakes, Lua is not typesafe and the library support is weak, and Java is still not a portable language in 2019 (PS4, Xbox, Switch and even iOS). C# has ended up being a wonderful choice to build games in, and now that the 2019 version of Unity has an incremental GC we are entering a golden age with the tool.