|Facebook's Redex Makes Android More Efficient|
|Written by Mike James|
|Friday, 02 October 2015|
Or does it? Facebook developers have just described a project that aims to optimize Java byte code. The post is impressive. but it gives the impression that it is breaking new ground - it isn't.
Facebook has a implemented an optimizer that works directly with the DEX code destined for the Android Dalvik interpreter.
It performs a number of stages of optimization including:
Minification and compression
It replaces human readable strings in the byte code by small unique generated identifiers.
If a function calls another function then it is more efficient to convert the call into inline code by putting the code of the called function in the calling function.
Removing unused wrapper functions
Remove set/get functions that aren't used.
Dead code elmimination
Walk the function graph and remove any code that is unreachable.
Of course, making all of this work properly so that it makes the DEX code smaller without introducing subtle bugs is difficult. The blog post ends with a promise for more information on additional optimizations.
However, there are other byte code optimizers and in fact Android Studio ships with, and makes use of, Proguard, an open source byte code obfuscator and optimizer. Using it is just a matter of targeting a final release version. Proguard seems to do everything that Redex does - dead code removal etc. The list provided by the Proguard website seems to cover just about everything that Redex does and more:
This raises the question of how good Redex is compared to Proguard, something not covered in the Facebook post.
It also makes you wonder why the Facebook team didn't start by forking Proguard if they wanted to do better? The only big difference is that Proguard works on the byte code, and hence works with all versions of Java, and Redex works with the DEX byte code and hence only works with Android. However there is a commercial version of Proguard that does work with DEX files.
Facebook has been nice to the programmer community by releasing open source code for various tools. In this case there is no word on when or if Redex will be made available. If it ever is then it certainly won't be entering a vacuum.
To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin, or sign up for our weekly newsletter.
or email your comment to: email@example.com
|Last Updated ( Friday, 02 October 2015 )|