Jason Voegele wrote:
> Jamis Buck said:
> 
>>Needle is a dependency injection (a.k.a. "inversion of control")
>>container for Ruby, employing many of Ruby's best idioms to make
>>dependency injection and service location fast, friendly, and fun! It
>>has never been easier to take advantage of these powerful design
>>patterns. Treat yourself and download it today!
> 
> 
> What is the relationship (if any) between Copland and Needle?  Is Needle
> the successor to Copland?

Copland and Needle are two independent projects. They are unrelated 
(although Needle does borrow some code from Copland, such as the logging 
subsystem).

Copland, though functional, is pretty overengineered from a Ruby 
standpoint. I used a lot of Java-isms to implement it, and although Java 
requires that kind of complexity to accomplish dependency injection, 
Ruby does not.

Compare LOC:

   Copland 1.0: 5,962
   Needle  1.1: 2,455

(Needle 1.1 will be out later this week--that's not a typo.)

Needle is less than half the mass of Copland, and yet it has the same 
core functionality: interceptors, logging subsystem, dependency 
injection, etc. However, whereas Copland uses external configuration 
files, Needle uses Ruby as a domain language to register services.

Needle is significantly faster to start up than Copland. For example, 
the calculator demo (on my laptop) takes 0.096s to start up for Copland, 
but only 0.026 seconds for Needle. For a standalone app, that might not 
matter, but in a CGI environment where the registry will be created for 
every request, the registry load times for Copland could become prohibitive.

Copland is designed with "fail-fast" in mind. That is to say, if you 
misconfigure your services, Copland tries to detect and error out as 
soon as possible. Needle makes very little effort to do the same.

Needle has a much more flexible model for service lifecycle management 
than Copland, but only because I didn't think of it until I was writing 
Needle. Needle's pipeline model could (theoretically) be ported back to 
Copland, but I do not have any plans to do so.

Also, although theoritically Copland can do anything that Needle can, 
you may need to write a lot of code for Copland in some cases to 
accomplish something Needle can do "out-of-the-box", since Needle uses 
Ruby as its configuration language.

Lastly, Needle does sport one feature that Copland does not: 
hierarchical namespaces. Copland pretends to have these, but in reality 
all packages in Copland are laid out flat, as siblings of each other. 
Needle actually allows you to nest namespaces, with services in a 
namespace overriding the services in its parent namespaces. This gives 
you a lot of power that Copland cannot provide.

So, you should use Copland if:

   * you prefer external configuration over configuration in Ruby
   * you want "fail-fast" functionality
   * you are primarily a Java developer and prefer to think that way
   * lengthy registry load times are not a factor

You should use Needle if:

   * you prefer to use Ruby's idioms (blocks, etc.) to configure services
   * you don't need "fail-fast" functionality
   * short load times are important
   * you need maximum flexibility in defining services
   * you need hierarchical namespaces with overridable services

Anyway, that was a longer explanation than I had intended to write. 
There are other differences (I'm thinking of more even as I write this 
conclusion, like Needle's lack of eager loading and shutdown 
notification), but the above should give you an idea of how the two 
differ. Hope it helps.

- Jamis

-- 
Jamis Buck
jgb3 / email.byu.edu
http://www.jamisbuck.org/jamis