Why unity doesn’t let us use c++ as a primary scripting language along with c#?? I am not asking about plugins. And no, not asking about source code access either(I read somewhere it’s a six figure sum). Just c++ for general users.
Makes sense since the engine itself is in c/c++ and c# is just a wrapper.
Is c++ support is in unity roadmap?
No, it’s not on their roadmap.
I think this was asked before and several reasons were given on why.
Considering that everything relies on Mono, I’d bet no.
You are in no way limited to using C# though. You can import a library in C# just as easily as you can do it in C++. If you want to write the majority of your code in C++, then do it, and provide an extern “C” interface that you can use from Unity. I was unhappy with the default JSON engine’s performance, so I imported libjson, which is pure C++ code.
Considering they open sourced their C# code, there’s nothing really stopping you from using that as a reference to roll your own API to act as a bridge between your C++ code and native Unity.
It doesn’t really make much business sense for Unity to bring C++ to the forefront, though. It’s a huge job with a questionable return on investment. I’d rather they focus on hardening their existing features, adding new features, etc. than tying up resources to work on something that offers zero benefits to C# users.
Maybe they’re concerned we’ll all write our code in bolded fonts.
And we can’t have that can we…
What would Unity really gain by supporting C++?
On most platforms you can already compile using IL2CPP which indirectly compiles your C# to C++ before going into your build, so the performance benefit of writing your scripts in C++ is dubious. The learning curve going from C++ to C# is probably the shortest of any programmer learning a new language due to how similar the two languages are syntactically. C# is actually a far more popular general purpose programming language than C++ is today, so Unity going with C# is serving a much larger number of people than if they went C++.
Supporting two different scripting languages would be an enormous investment. There would need to be a pretty large number of developers who would prefer C++ to justify its continued maintenance, since it will require resources that would have to be taken away from other maintenance and new feature work. It would fracture the community again, where people looking for code examples or asking for help will need to specify what language they need help using (we finally got done with that issue with JS/UnityScript now that it got deprecated, and everyone and all examples in a single language is far better).
So I don’t really see it happening, I don’t see the benefit, and I think if they did add C++ support it would actually hinder the future of the engine and the community more than it would help. So I hope they throw this idea in the garbage.
We did two (even three) supported languages for a while. Its not desirable. Specifically:
- It fragments the community. You only get half as many people able to answer each scripting question.
- It fragments the asset store. Languages don’t play nicely together, so asset developers have to support both.
- It delays features. Unity has to implement and test interfaces in both languages before release.
- Beginners inevitably choose the wrong language, slowing down new users.