4 ms·
> and helped me realise that what I want to do is write code that calls, not code that is called. I want to own main(). It took me a while to clarify this in m
by TeMPOraL 10y ago
> and helped me realise that what I want to do is write code that calls, not code that is called. I want to own main().
It took me a while to clarify this in my head, but I feel exactly what you wrote here - I want to own main(). A framework is something that calls your code. A library is something you call. I avoid frameworks whenever possible.
- greenshackle2 10y agoAh, yes that clarifies a problem I've had trouble with too. I work with a complicated framework, and I often end up having to explain why a seemingly simple change to x is actually complicated, even if I'm looking at the code for doing x right now and could trivially make the change. x is at the bottom of a framework, the top of which I didn't code or fully understand, so I'm not sure exactly who's calling this code under what conditions - I have to read and analyse an edifice of code to make sure the change is safe. Or just do the change and hope the integrated tests catch any breakage.
- quantumhobbit 10y agoI like this definition of libraries vs frameworks by who owns main() too. I've always said that libraries add functionality to the language, whereas frameworks are half-assed DSLs.
- oxymoron 10y agoI also very much agree with this. I think it might be a sign of something deeper, though. When I design a library, I keep in mind that it might be used in a variety of contexts applied in a multitude of styles. In contrast, when I author a framework I expect the users to adhere to the principles of the framework. Whoever owns main() gets to dictate the terms. For a beginner or intermediate developer, this might be a relief. Once you reach the level where you have a good intuition for how to do things well, your primary focus will be the minimizing of complexity, and I can never shake the feeling that frameworks stand in contradiction to this goal. After all, they were designed for maximum generality, but are the abstractions envisioned really the ones you require? That's not to say that everyone should embark on a journey to build their own 50kloc framework. You might want to consider skipping the framework if 500 lines of compact, well-designed and thoroughly documented code can do the same job, though. And you can still use libraries for the truly complex parts.
- m_mueller 10y agoWhat about frameworks that let you keep main, but require to take over your build system? I admit I'm guilty of one of those as well [1], but only because I don't see a more simple solution in terms of usage. [1] https://github.com/muellermichel/Hybrid-Fortran https://github.com/muellermichel/Hybrid-Fortran
- TeMPOraL 10y agoTo me this looks closer to library than framework, by the virtue of augmenting your code instead of hijacking the control flow completely.