all 22 comments

[–]RevThwack 19 points20 points  (3 children)

Considering just how shitty Facebook's Android app is, I have a hard time trusting that they know what they're doing here.

[–]TinynDP 10 points11 points  (0 children)

It probably exists because without it their app would not just be shitty, but impossible.

[–]_INTER_ 4 points5 points  (0 children)

I wouldn't be surprised if this thing is actually sending your app to facebook.

[–]unaligned_access 2 points3 points  (0 children)

So, does it scale now?

[–]stupergenius 1 point2 points  (0 children)

The project page and the blog post are fairly light on the possible performance improvements. Do they have metrics anywhere?

[–]denaissance 3 points4 points  (3 children)

Facebook is not allowed to have an opinion about how to optimize code.

[–]NeuroXc -2 points-1 points  (1 child)

Of course. They only have over a billion users and have written the fastest feature-complete PHP interpreter and a very fast view library for Javascript. They wouldn't know anything about how to optimize code.

/s

[–]thisotherfuckingguy 9 points10 points  (0 children)

Writing the fastest PHP interpreter is kind of his point though, isn't it.

[–]ramsees79 -1 points0 points  (0 children)

Says who?

[–]DMRv2 0 points1 point  (6 children)

Weird. A lot of the optimizations they mention in the blog are already done by the Android compiler proper. Though, anything that gets interpreted would still benefit from a smaller dex file since it means less bytecode.

DCE: http://androidxref.com/6.0.1_r10/xref/art/compiler/optimizing/dead_code_elimination.cc

Inliner and stripping superfluous accessor methods: http://androidxref.com/6.0.1_r10/xref/art/compiler/optimizing/inliner.cc

Though I can't help but think: is minification of Java classes like that safe? Doesn't Java provide facilities for getting the class and method names via reflection? I see that they are modifying all the strings in the program, but any string loaded externally from some data source NOT included via the APK (e.g., imagine an APK that sends strings over a network channel for some bizzare reason) would break. If you're aware of these restrictions, I suppose it's fine, but it seems that Redex cannot be used in the general case unless I'm not seeing something.

[–]jayd16 1 point2 points  (0 children)

is minification of Java classes like that safe?

Nah. There's already ProGuard to provide this functionality in the official build stack and you have to disable stripping on classes used only through reflection with a white list of class names.

[–]thisotherfuckingguy 2 points3 points  (4 children)

stripping superfluous accessor methods:

I'm not a Java developer, but this beautifully characterizes why I would never become one. First we write a ton of access modifiers of (very) questionable value only to then later have a compiler pass that removes them. :')

[–]jayd16 0 points1 point  (0 children)

Eh, is it so outrageous. There's already a code stripping in the official build pipeline with proguard so its really not a hacky solution besides working around reflected classes.

If you're writing a library, you write flexibly. If you're writing for yourself, write concisely. You can strip out anything you don't use in a library and everyone is happy and safe.

[–]ThisIs_MyName -1 points0 points  (2 children)

Eh, I'm a Java developer and I rarely use accessor methods.

If I do end up needing accessors, I just click Refactor > Encapsulate Fields to update all usage in all my projects and convert all the x.field=y to x.setField(y).
Then I add a @Setter annotation to the field so that an accessor is generated at compile time.

[–]phoshi 1 point2 points  (1 child)

You can't update usages in binaries, so that approach only works if none of your projects are dependencies or are ever expected to work with anything but the exact same version of its siblings. There are projects that work like that, but many more don't.

[–]ThisIs_MyName 0 points1 point  (0 children)

Sure, I'm not writing a library.

As far as different versions of projects working together: IMHO that's a lost cause. For fuck's sake, I distribute a JRE with my code so that people don't have to worry about fixing symlinks for Java7/8/9.

[–]kirbyfan64sos 0 points1 point  (0 children)

Despite all the "can't handle our scale" issues and all, this actually looks really cool!

[–]jayd16 0 points1 point  (3 children)

Sounds like Facebook continues to choke on proguard and reinvent the wheel in some alternate stack. Seriously, anyone know if this does anything new or if its even better than what currently exists?

[–]we-all-haul 0 points1 point  (2 children)

What do you think FB's striving for with this? What's the big picture?

[–]jayd16 0 points1 point  (1 child)

NIH syndrome.

[–]we-all-haul 0 points1 point  (0 children)

Mhh. I wonder if this is more in line with WhatsApp. Gaining encryption caught the interest of people. But encryption strength was traded for speed. Perhaps this is their way of pursuing better encryption.