Ask HN: Why isn't native mobile libraries written in C?
Is there any particular reason why Google and Apple didn't take this approach? Does it introduce problems with the permission systems for apps? Security issues?
Is there any particular reason why Google and Apple didn't take this approach? Does it introduce problems with the permission systems for apps? Security issues?
I have been part of teams where entire stack (even UI layer) was in C. malloc() was a prohibited function by design! It was way too much of code for what could be accomplished by having c++-STL these days. But then the system specifications were very low (~130 Mhz) too.
In one of embedded projects couple of years earlier - the trade off discussion we had was whether to include boost or to have a JVM ported to it! So we 've come far away.
With good chances of myself corrected here - I 've a feeling that C will be restricted to drivers/kernel, in most systems going ahead, as everything that can be written in C in rest of layers can be written in OO languages.
eg: OS based on nodejs on top of linux-kernel: https://node-os.com/
Secondly, for stateful graphics programming, the most common kind of application on mobile, OO works really well. So Apple and Google both picked languages that support OO.
Finally, despite all this, both Apple and Google have native C apis. You can write C freely in Objective-C, which is a superset, and Android has its NDK.
Also while C has great interop. it still comes at a cost, you loose a lot of modern programming constructs like exception, static initialization, reflection and garbage collections.
Compare that to Java where you can look at the class file and get enough metadata to do anything.