3 ms·
Complaining about the JVM on Android ("a low powered platform") feels like a take that's about 10-15 years out of date. A modern Android phone is several orders
by wk_end 3y ago
Complaining about the JVM on Android ("a low powered platform") feels like a take that's about 10-15 years out of date. A modern Android phone is several orders of magnitude more powerful, however you might want to measure that, than the machines that Java was first designed for. And anyway, Android doesn't really use a VM anymore - it's been AOT compiling apps on installation for around a decade.
There's about a billion things about developing on Android that are absolutely miserable. HLL-induced perf bottlenecks aren't usually one of them.
- phendrenad2 3y agoI don't think GP's complaint is about Java and Swift being unperformant, I think the complaint is that you can't use the language of your choice easily. If we just had a C API we could interpret Ruby or Python with a standard interpreter. But instead, if you want to write a Ruby or Python mobile app, you need to translate objects between the language of your choice and Java/ObjC.
- iainmerrick 3y agoRight -- Android does have a C API but it’s a pain to use and really incomplete: https://developer.android.com/ndk/guides/stable_apis https://developer.android.com/ndk/guides/stable_apis If you want to do anything else you need JNI which is an even bigger pain. I don’t really understand why the Android team haven’t made it easy to call any Java API from C, with auto-generated bindings or some such. I think they just don’t believe in apps using native code, beyond the special case of games (note that pretty much all the native APIs are to do with low-level graphics and sound).
- pjmlp 3y agoYou don't need to wonder, it is quite explicity mentioned on the NDK documentation. "The Android NDK is a toolset that lets you implement parts of your app in native code, using languages such as C and C++. For certain types of apps, this can help you reuse code libraries written in those languages." -- https://developer.android.com/ndk https://developer.android.com/ndk "The NDK may not be appropriate for most novice Android programmers who need to use only Java code and framework APIs to develop their apps. However, the NDK can be useful for cases in which you need to do one or more of the following: - Squeeze extra performance out of a device to achieve low latency or run computationally intensive applications, such as games or physics simulations. - Reuse your own or other developers' C or C++ libraries. " -- https://developer.android.com/ndk/guides https://developer.android.com/ndk/guides There is also the security aspect, why they discourage the use of those languages for full blown applications.
- iainmerrick 3y agoHmm, that explains the situation (native code is discouraged for most purposes) but doesn’t explain why they take that approach. There is also the security aspect, why they discourage the use of those languages for full blown applications. Native code in apps doesn’t seem like a security problem on iOS, though?
- pjmlp 3y agoWhy do you think Swift was invented, and there is a Safe C dialect used on iBoot? Spend some time reading iOS security updates from Apple, lots of nice CVEs fixes reported there.
- iainmerrick 3y agoSwift compiles to native code. C and C++ are well-supported userspace languages on iOS.
- pjmlp 3y agoJava also compiles to native code on Android. Try to write an iOS application using only C and C++, instead of either Objective-C or Swift. "Swift was designed from the outset to be safer than C-based languages, and eliminates entire classes of unsafe code" -- https://www.swift.org/about/#features https://www.swift.org/about/#features "Swift is a successor to the C, C++, and Objective-C languages. It includes low-level primitives such as types, flow control, and operators. It also provides object-oriented features such as classes, protocols, and generics, giving Cocoa and Cocoa Touch developers the performance and power they demand." -- https://developer.apple.com/swift/#fast https://developer.apple.com/swift/#fast Some of the information related their Safe C dialect, https://discourse.llvm.org/t/rfc-enforcing-bounds-safety-in-c-fbounds-safety/70854 https://discourse.llvm.org/t/rfc-enforcing-bounds-safety-in-... "2023 EuroLLVM - Keynote: “-fbounds-safety”: Enforcing bounds safety for production C code" https://www.youtube.com/watch?v=RK9bfrsMdAM https://www.youtube.com/watch?v=RK9bfrsMdAM Finaly a recent gem from CppNow 2023, "Introducing a Memory-Safe Successor Language in Large C++ Code Bases" https://www.youtube.com/watch?v=lgivCGdmFrw https://www.youtube.com/watch?v=lgivCGdmFrw
- quelsolaar 3y agoHow many Android devices are in service in the world? Whats the total power consumption of all Android devices? Shaving just 1% is probably a couple of coalfired power plants worth of CO2.