On Mon, Apr 8, 2013 at 7:18 AM, Tim Boudreau <[email protected]> wrote:
> I just moved a framework for working with Netty, which relies on Guice > very heavily, to GitHub. It's called Acteur. It has a somewhat unusual > programming model, as it's more-or-less functional programming in Java, > using Guice and custom, reentrant scopes to drive the whole thing. > > I'm curious if the Guice folks here see it as neat, or a strange abuse of > Guice: > http://timboudreau.com/blog/Acteur/read I think it's both. :-) <nitpick> The "Why Constructors?" section makes me nervous, though. To say, as you do in the first bullet, that a constructor "is the one guaranteed thread-safe unsynchronized method an object can have" makes it sound as though you don't need to worry about safe publication of the object being constructed as long as you don't leak "this". But you only get the guarantee that other threads will see completely initialized values of *final* fields. (See http://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#d5e28755 for an example.) Your second bullet hints at this, but in a way that seems to imply that you don't have to worry about the thread-safety of objects referred to by final fields. Final doesn't magically confer thread-safety; if I have a final field that points to a mutable object, that object still needs to be made thread-safe if the final field is shared by multiple threads. All that final does is guarantee complete initialization (in the absence of leaked "this"). And you don't mention one of the big drawbacks of constructors, which is that you can't in general safely call overridden methods in constructor bodies. </nitpick> That said, I think the Guice abuse is very cool. --tim -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-guice?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
