3 ms·
Similar to Spring dependency-injection: https://www.journaldev.com/2410/spring-dependency-injection https://www.journaldev.com/2410/spring-dependency-injection
by _bxg1 7y ago
Similar to Spring dependency-injection: https://www.journaldev.com/2410/spring-dependency-injection https://www.journaldev.com/2410/spring-dependency-injection
It seems too powerful, though. I could see it quickly becoming intractable to find where the code lives that is causing a certain outcome.
The root problem it's trying to solve is the fact that things often don't fit neatly in a single bucket, but our traditional idea of modules as mutually-exclusive and hierarchical categories forces you to choose just one place to "put" something. An idea I've had is to get rid of hierarchical modules altogether. Really they're a relic of directories and files. Instead, one could "tag" a function/class/constant as belonging to multiple modules, and one's editor could aggregate all members of a cross-cutting module as needed. Organization within actual files on disk becomes an implementation detail.
- akkartik 7y ago> I could see it quickly becoming intractable to find where the code lives that is causing a certain outcome. (Author here.) The tangler I describe inserts #line directives into the output. You can open up the generated C++ and see where a line comes from. Conventional C++ tools understand line directives as well, so the debugger experience is sane. I'm sure there are gaps in this tooling, but they're not intractable. Tooling around conventional modules has matured over decades. My approach hopefully shows some benefits of a road not taken.
- _bxg1 7y agoIt's certainly interesting, and I didn't mean to pre-judge too strongly. I definitely think we're at the point where we need some new ideas around this stuff, and probably any new ideas at this point will require some kind of special editor assistance, so yeah, I get what you mean in that regard.
- akkartik 7y ago> Instead, one could "tag" a function/class/constant as belonging to multiple modules, and one's editor could aggregate all members of a cross-cutting module as needed. Organization within actual files on disk becomes an implementation detail. Yes, this is interesting. Are you thinking of something like Ruby's modules and `include` directives? (https://ruby-doc.com/docs/ProgrammingRuby/html/tut_modules.html https://ruby-doc.com/docs/ProgrammingRuby/html/tut_modules.h...) Is there a reason the editor has to do this rather than the language?
- _bxg1 7y ago> Are you thinking of something like Ruby's modules and `include` directives? Unfortunately I'm not very familiar with Ruby, so I'm not sure > Is there a reason the editor has to do this rather than the language? The language would definitely have to support it (though maybe you could accomplish something similar with annotations and/or special comments in an existing language), but without special editor support you wouldn't gain much from it. Your constructs would still be scattered across files in ways that make compromises. Whereas editor support could pretend the files don't exist at all.