2 ms·
> I do not believe in the idea that it automatically provides benefits in all circumstances Where 'it' is dependency injection, or, hey, anything else. How ab
by shadowmint 12y ago
> I do not believe in the idea that it automatically provides benefits in all circumstances
Where 'it' is dependency injection, or, hey, anything else.
How about we have an interesting conversation instead of rethrashing a stupid one (here is my straw man: 'you use DI for everything without thinking.' Watch as a bash it...)?
Why do dynamic languages like python, ruby and javascript typically not use dependency injection?
You could argue that some of them (python) don't have a great unit testing background, but modern projects like node do, and you still don't see the DI pattern thrown around a lot.
In fact, you tend to only see it in languages that implement a native interface-based polymorphism, like java, c++ and c#. Even folks using go (http://openmymind.net/Dependency-Injection-In-Go/ http://openmymind.net/Dependency-Injection-In-Go/). Maybe rust too, but since the single ownership makes singletons an anti-pattern in rust, maybe not (at least I haven't seen it).
Could it be you can get by just fine for all your testing needs without DI?
- rjbwork 12y agoDynamic languages provide their own DI facilities simply by making objects. Since the definition of a class, or object, or prototype (whatever your language happens to call it) can be completely changed at runtime before ever getting to your code,there's no need for injection. You can simply configure all your services and helpers and config objects and managers etc. at startup, so there's no need for an explicit DI/IoC type pattern.
- arielby 12y agoRust is new here, but it often does its dependency injection on the type-level (see the *_traits crates in servo, or anything involving piston - `https://github.com/piston-developers` https://github.com/piston-developers`). However, Rust doesn't have an OOP or Unit Test culture, so dependency injection is limited to true dependencies.