Comment by dminik

Comment by dminik a day ago

4 replies

> but most modern apps rely on some form of dependency injection

Does Zig actually do anything here? If anything, this seems to be anti-Zig, where everything must be explicit.

philwelch a day ago

Passing in your dependencies as function arguments is a form of dependency injection. It is the simplest and thus arguably best form of dependency injection.

  • almostgotcaught a day ago

    This is like saying arithmetic is a form of calculus, the simplest form. Ie it reduces the concept (DI) to a meaningless tautology.

    • philwelch 3 hours ago

      Not at all. Dependency injection is the injection of dependencies as logical parameters. The simplest and arguably best way to inject logical parameters to a segment of code is to use function parameters. You can have a complicated DI framework that involves Java class annotations and megabytes of XML, but that’s not the central idea.

      • dminik an hour ago

        I'm sorry but if I read

        > most modern apps rely on some form of dependency injection

        then plain parameter passing is not what I'm thinking of. Especially not manually doing that to hundreds or thousands of calls.