Apple’s focus on power consumption

App size difference between android & ios

I have always been boggled by the difference in the app size on android vs ios. For example, the android apk for paytm is about 8MB whereas the ios app is 18MB. Almost all apps increase in size by about 1.7x to 2x for ios compared to android. Have you ever wondered why the difference in size?

[answer: apple ios apps are in machine executable form which means higher app size, lower cpu cycles & lower battery consumption]

Xamarin — UI/Event based programming

A couple of days back, I started writing some ios app code & suddenly realised that it felt like writing C/C++ programs back in college days. Cursing the complexity, I started searching for better frameworks & bumped into Xamarin which is based on a .net engine meaning complete support for C#! C# is amazing for UIs. It comes with a lot of overhead but it is still super quick to get going. Haven’t you wondered as to why apple has never graduated to a better abstraction than Objective C? SWIFT is a bit of progress but no way near C#.

[answer: objective C means extremely low memory footprint, access to L1/L2 caches & optimization of executable code. This means lower battery consumption]

ART runtime on android (art is Android Run Time)

Android Kitkat introduced the ART runtime & Android Lollipop is completely based on ART. Dalvik runtime (before ART) is a JIT compiler i.e. it coverts high level code into executable code everytime you open the app. This takes away a lot of CPU cycles. The main improvement in ART was converting the high level code to executable code the first time the app is open & run the executable code everytime afterwards. The biggest problem with this is extra CPU cycles. CPU cycles have a direct correlation with amount of power/battery consumption on their platforms. Haven’t you wondered as to how apple phones have been able to consume a lot less power & still give a great experience.

[Android sucks in optimizing for battery power consumption. They are improving but no where close to ios. Java VM already has a lot of overhead compared to C based runtimes]

apple’s focus on power consumption

Apple has been extremely focussed on using as little power as possible. It goes to the level of the programming language allowed for developers to use to write apps for mac or ios. That is the amount of alignment within apple for design based thinking. Power consumption is an extremely important variable.

A quote from alex blewitt’s interview on swift fundamentals (link)

It’s also clear that although the power of Objective-C’s dynamic nature allowed evolution of both frameworks and the applications that are built upon them, the flexibility wasn’t required in almost all cases and simply added to the execution cost of each method call. Although CPUs have been fast enough for some time (I had an original NeXT station with a 68040 processor, running at 25MHz doing the same thing!) the focus is now on power consumption and minimising latency to main memory. With moving from a dynamic dispatch to a more static oriented dispatch, the compiler has better visibility to method calls and can perform in-lining in a way that modern runtimes (like Java) do to increase performance and in a way that Objective-C cannot. This is a win for Apple’s customers, not only because code can execute faster, but importantly take less CPU instructions and with less random access memory lookups that can be cached on the processor’s L1 and L2 caches. This in turn means less battery usage, which means that battery operated devices will last longer.

P.S: Android will probably never become this good in power consumption. The advantage of android is its ubiquity. It works on a wide range of hardware & the engine is based on JVM. Ubiquity & optimization never go hand in hand.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.