4 ms·
Firstly, C kinda sucks. Undefined behaviour is unavoidable, and compilers see it as license to do whatever they please, so you can actually get a segfault becau
by qwertyuiop924 10y ago
Firstly, C kinda sucks. Undefined behaviour is unavoidable, and compilers see it as license to do whatever they please, so you can actually get a segfault because the compiler decided to "optimize" away your null pointer checks. C is also dangerous, and Apple and Google don't want users getting segfaults. And even if the plan was to bind the C apis to high level languages, people would just write their apps in C.
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.
- soulbadguy 10y agoCompiler dev here : "and compilers see it as license to do whatever they please", isn't that the definition of undefined behavior?
- qwertyuiop924 10y agoWell, yes. That's why compilers can comply to the spec and do that. But nobody EVER writes any C with no UB, so there are no guarantees about how the compiler will compile it. Most C programmers, I would guess, do not know the entire list of UB. The end result is that you can write code that looks completely safe to most, but compiles without any checks.
- deleted 10y ago[deleted]