Introducing Blender, an annotation processor for Guice

388 views
Skip to first unread message

Stéphane NICOLAS

unread,
Oct 21, 2014, 5:04:41 PM10/21/14
to google...@googlegroups.com, Michael Burton, Stéphane NICOLAS
Hello all,

Mike Burton (the author of RoboGuice, a version of Guice adapted to Android) and I have been working on a new annotation processor for Guice(named Blender).
We have been working hard on this and, in RoboGuice, we gain from 30 to 70% gain in speed and around 30% gain in memory footprint for our apps.

We would like to submit the idea of Blender to the community of Guice devs in order to have your feedback on this, and as we hope thatBlender can become part of the official Guice.


We have currently forked Guice and tried to make something close to a PR for it : 
(Please ask us where to get the latest version, we try to stick on guice 4 changes)

We are very excited to submit Blender, and we are very open to modify our implementation to make it fit in Guice and we are eager to get feedback on it.

Thanks in advance,
 Stéphane

Sam Berlin

unread,
Oct 21, 2014, 5:08:27 PM10/21/14
to google...@googlegroups.com, Michael Burton, Stéphane NICOLAS
This is interesting.  Have you compared the results to Dagger (Dagger1 or Dagger2)?  Dagger is explicitly built with Android in mind, and shifts the processing to compile time.

sam

--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice...@googlegroups.com.
To post to this group, send email to google...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/9cd1683f-0545-4687-b824-0a0cfd7a9f31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stéphane NICOLAS

unread,
Oct 21, 2014, 5:14:22 PM10/21/14
to google...@googlegroups.com, mi...@niskala.org, steff....@gmail.com
No, we didn't compare them yet. 

For sure, RG + RoboBlender decrease the amount of processing needed to compute injection points, but still a good part of it is done at runtime.

Nevertheless, we think it makes a good compromise in terms of simplicity and performance to use Guice + Blender on Android.

S.

Michael Burton

unread,
Oct 21, 2014, 5:18:13 PM10/21/14
to google...@googlegroups.com, mi...@niskala.org, steff....@gmail.com
We are aware of Dagger, but feel that Guice is more powerful and flexible.  Which is why we are investing time in making Guice more performant for our use-case.  We hope to make additional contributions in the future to further close that gap.

Christian Gruber

unread,
Oct 22, 2014, 12:38:12 PM10/22/14
to google...@googlegroups.com, mi...@niskala.org, steff....@gmail.com, Colin Decker, Sam Berlin
Can you recommend what features of Guice you find you want that Dagger does not offer, and how these relate?  The Dagger and Guice folks are in pretty regular discussion and are related projects, and it would be nice to know what we're missing.  Absolutely Guice is more powerful and flexible across many dimensions - a deliberate decision to constrain APIs in order to encourage certain patterns, especially in Dagger 2.

Google has some experience (with some good results) simulating the guice API in a compile-time annotation processor, though it still ended up being a sub-set of the GUICE total capability.  I'm interested to hear of your experiences. I will say, I'm really glad people are experimenting with different approaches. 

Also, I should point out that we do have a validation annotation processor for Guice that we need to roll-out to help with earlier error validation, though that doesn't address performance constraints.  It's been sitting for a bit, owing to prioritization, but I think that we should get it in shape and into Guice soon. (cc:ing colin about that)

Christian. 

Stéphane NICOLAS

unread,
Oct 22, 2014, 3:20:37 PM10/22/14
to Christian Gruber, google...@googlegroups.com, Michael Burton, Colin Decker, Sam Berlin
I will let Mike answer your question Christian, as it is more oriented to his previous post.

My personal point of view is that a lot of people already use RG, and for this reason itself, its worth trying to update it and make it the best it can. 

From a technological point of view, I really like RG as it way simpler to use than Dagger. I am not super familiar with Dagger, though I really love DI as it made me a better dev, but I really like how Guice is simple, and well known also for Android devs from the Java world. I like the fact that you add injections super easily, without having to define a module in the most simple cases, no need to say when the module is being used, by who, etc. I saw the video about Dagger 2 and chances are that this release will make Dagger close to RG in terms of simplicity. But I must say that up to now I have not been convinced by the Dagger tutorial and find it harder to use.

Also, when we started to work on Blender, I have been keeping wondering if Guice was being discarded for the good reasons : namely speed and memory consumption. With Blender we could already re-gain some ground on that field, and I am pretty sure Guice could be even more optimized and deliver super decent performance results. I have been a bit sad to see that Google itself discourages using Guice on Android.

Though, I agree that a lot of advanced features of Guice are too costly for Android, like the TypeLitteral stuff. But still, in that case, it could be enough for me to discourage people to use them on Android.

So, to sum yes, I found it really both interesting and worth it to make Guice better so that we can use it on Android.

Do you guys consider merging Blender into Guice ? 
It could be coded better, but we tried to minimize the changes so that you can more easily see the changes from master branch.

Stéphane
BTW, I am going to present Blender and RG 3 at AndevCon San Francisco, it would be glad to meet you or Sam there.



Christian Gruber

unread,
Oct 22, 2014, 4:30:14 PM10/22/14
to Stéphane NICOLAS, google...@googlegroups.com, Michael Burton, Colin Decker, Sam Berlin
Always happy to meet folks and share experiences.  As to whether we would consider merging Blender into Guice, that's an easy and a hard question to answer.  The simple answer is - we'll consider any great improvements.  But how it turns out is obviously a combination of API review, implementation review, licensing (no issues if it's Apache 2.0), performance implications in cases other than what the code was intended to solve (side effects), whether the chances change the scope of the Guice project in ways we wouldn't prefer, etc.

That said, I don't know that it's necessary.  If it's a fork, you can, ultimately, release it to maven with a different artifact.  As long as you properly manage dependencies so no one is pulling in conflicting symbols, it's not an issue.  We have a few guice forks out there doing interesting things.  

But starting the conversation here is definitely a great place to start helping us see what you're trying to achieve.  Thanks!  We want to encourage folks to try new things, or re-try things in new ways, but I don't want to unrealistically imply any particular likelihood of incorporating it.  We'll just have to look at the details to figure that sort of question out.

c. 

Stéphane NICOLAS

unread,
Oct 22, 2014, 5:08:19 PM10/22/14
to Christian Gruber, google...@googlegroups.com, Michael Burton, Colin Decker, Sam Berlin
Thanks for this answer Christian. Let us know if we can help this review.

Sam Berlin

unread,
Oct 22, 2014, 5:11:18 PM10/22/14
to google...@googlegroups.com, Christian Gruber, Michael Burton, Colin Decker
One immediately useful thing that would be helpful is a doc that lists any new APIs, changed APIs, and removed APIs, along with rationale of each.  Also if any implementation details are different, that would be useful to explain too.  The slideshow linked earlier is nice for an end-user, but to know if it can be merged into Guice we'd need something a bit meatier.  A pull request would also be useful, to see the actual code changes.

sam

Stéphane NICOLAS

unread,
Nov 11, 2014, 12:42:54 PM11/11/14
to google...@googlegroups.com, cgr...@google.com, mi...@niskala.org, cgde...@google.com
Hi all,

here is our first PR to demonstrate what blender is and what it changes in Guice : 

(sorry for the delay, we had some pending work and a few things to solve in blender).

Stéphane

Stéphane NICOLAS

unread,
Nov 12, 2014, 2:27:57 PM11/12/14
to google...@googlegroups.com, cgr...@google.com, mi...@niskala.org, cgde...@google.com
The annotation processor document requested by the Guice team is ready for a first review. 

This is our first attempt to write such a document, I hope it will meet your expectations : 

Stéphane NICOLAS

unread,
Jan 17, 2015, 7:31:22 AM1/17/15
to google...@googlegroups.com, cgr...@google.com, mi...@niskala.org, cgde...@google.com
Hi Guice team,

I am just knocking to see if you have had some time to consider our enhancement request.
As we mentioned it, we are very open to enhance this work. 

The current implementation is in production inside RoboGuice 3 and already propels tens of apps used by millions of users and the system is stable and performs well.

Regards,
 Stéphane

Stéphane NICOLAS

unread,
Feb 27, 2015, 11:15:09 PM2/27/15
to google...@googlegroups.com
Ping ?

Sam Berlin

unread,
Feb 27, 2015, 11:35:55 PM2/27/15
to google...@googlegroups.com

On Fri, Feb 27, 2015 at 11:15 PM Stéphane NICOLAS <steff....@gmail.com> wrote:
Ping ?


--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice+unsubscribe@googlegroups.com.

To post to this group, send email to google...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
Reply all
Reply to author
Forward
0 new messages