4 ms·
Java is interpreted on Android on every version prior to Android 2.2. Lua (clearly a scripting language) also converts to bytecode on load, and runs faster than
by SomeCallMeTim 16y ago
Java is interpreted on Android on every version prior to Android 2.2. Lua (clearly a scripting language) also converts to bytecode on load, and runs faster than Java in most cases. I'm pretty sure Python also converts to bytecode.
Objective C has a lot of run time overhead due to its "message passing" paradigm. So any time you need to use a Cocoa API, it's pretty slow. Somewhere I read that, as a result of Objective C overhead, the iPhone ends up about the same speed as Android in typical apps--so that with Android 2.2 getting a JIT compiler, it ends up much faster on similar generation phones.
EDIT: I just realized what you were confused about. Originally Apple said: "NO native SDK. You must use JavaScript on web pages to create iPhone apps." That's what I meant by "Apple started with a scripting language and had to back down." END EDIT
If you're writing code for mobile platforms, then I'm sorry, but it sucks to have to write it all 3-4 times. C# may be better than Java, but it's not relevant to me if I want to write Android/iOS games. If everyone used C++, then even the small-market phones (I'm looking at Microsoft here) would get ports of everything. At least iOS has somewhat native support for C++, which makes it easier to port games to/from Windows/Linux. The Android native support is unfortunately a neglected step-child of Google, though I'm fighting with it to get that compatibility.
And I'd certainly debate that modern phones are overpowered, but then again I write games. My G1 positively crawls--which I submit it wouldn't do if large portions of the OS weren't written in interpreted Java. I would totally agree with you that, on paper, there's plenty of power--but it's all wasted by inefficient code.
You know what really surprises me, though? How much CPU it takes to render a web page. Even when I'm on WiFi, the G1 is unusably slow at rendering web pages. And it's built on C++--and the Google browser, which is supposed to be fast. Opera and Dolphin are also pathetic on the G1.
Not that anyone will see this now that my original comment has been downvoted to oblivion. I guess you can't insult Java on HN and get away with it. No worries, though--the same thing happens on Reddit.
EDIT: See "EDIT" section above.
- i80and 16y agoMostly I just took issue with your usage of "scripting language" (which has more to do with a REPL and no discrete compilation step than anything else). The edit clarifies things a bit too; I confess to not following the original iOS app development details. Thanks for taking the time to write an awesome response; you are definitely more savvy on the performance topic than me, and I'm disappointed to learn that the crunching power of modern mobile CPUs tends to be squandered.
- vetinari 16y agoG1 crawls, because it is very memory constrained device. It has 192 MB RAM, 64 MB is taken by radio stack, leaving only 128 MB for android system. Try taking c2d system and limit it to 128 MB RAM, without swap. It will crawl too.
- glhaynes 16y agoObjective C has a lot of run time overhead due to its "message passing" paradigm. So any time you need to use a Cocoa API, it's pretty slow. I hear over and over from experienced Obj-C guys that it's almost never message passing that's your bottleneck. (Just like how it's almost never your compiler that's wrong, it's almost always that you really did forget a semicolon.) Keep in mind that most of Mac OS X is Objective-C and it seems competitive performance-wise. I believe the Objective-C runtime even has some caching to make the performance of frequently-sent messages almost on the order of a function call. Asm guys used to say the same thing about new-fangled languages like C: all that code that pushes/pops the function call stack was a huge slowdown. In practice, you just don't ever spend your time in function call stack manipulation code.