Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container Compilation? #166

Open
ev45ive opened this issue Aug 13, 2014 · 1 comment
Open

Container Compilation? #166

ev45ive opened this issue Aug 13, 2014 · 1 comment

Comments

@ev45ive
Copy link

ev45ive commented Aug 13, 2014

I love what you have done. I would very much like to use something like wire.js in my projects. There is DI for backbone, there is one for Angular but there are not even close to wire.js. There is a concern that library is still in beta, and there are speed and debugging issues I am afraid of in production intended projects.

AFAIK for bigger applications wire.js (with lots of promises and big call stacks) gets slower and not easiest thing to debug. I like to think about scopes as Dependency Injectors. All major DIs i know do container compilation to give back the spped and inline some of the wiring as plain function factories.(especially when values are given, and synchronous - no need for promises and long call stacks then).

There exist now a lot of work on javascript compilation / transpilation (using Node.js and alike) out there. Situation is even simpler here as all we need to do is compile JSONlike wire files to flat js code, no JS parsing needed.

Have you thought about it? Any plans to implement it?

@briancavalier
Copy link
Member

Hey @ev45ive, thanks! @unscriptable and I had talked about the idea a while back, and about possibly doing this via wire's cram build plugin. It would be a really cool feature.

It's possible to structure applications into multiple wire specs that are wired as the user navigates through the system, rather than wiring the entire application at startup time. In fact, that was one of the original design goals when we first started working on wire. We've worked on large projects, and wiring speed hasn't yet proven to be a significant issue. Wire also got significantly faster recently with the update to use when.js 3.x.

All that said, it's always nice to make wiring faster :)

I think it would be difficult in the current architecture to get to a fully-compiled version, where a wire spec is completely transformed into imperative code (especially synchronous, imperative code since wire is highly async and handles non-determinism in component ordering!).

However, I think it would be extremely interesting to try to see what is possible. For example, maybe there are a few simple things we could start with, such as statically determining the optimal component wiring order based on a dependency graph built from $refs (wire already builds such a graph internally to detect circular dependencies). With that graph, it may be possible to output some imperative code that minimizes promise usage and still wires everything in the right order. It'd probably take some refactoring to expose the graph, but it's probably doable.

Would you be interested in doing some experiments or helping with such a thing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants