Live data from Hacker News

Avoid Mini-Frameworks

laike9m.com

31–40 of 119 posts

Re: Avoid Mini-Frameworks

#31
post #5

> real and only difference between a library and a framework, is whether it introduces new concepts This isn't what is normally understood in software engineering by those terms. A library is something you call. A framework is some kind of application scaffolding that normally calls you. You can use more than one library. You normally only have one framework in-process. I found the blog post a little hard to parse. I…

Frameworks abide by the Hollywood Principle and the Greyhound Principle:

Don't call us, we'll call you.

Leave the driving to us.

Re: Avoid Mini-Frameworks

#32
post #12

Earlier quoted context omitted.

these things are hard, maybe impossible to define. For example I mostly agree with your calls/called definition but you also get self-described libraries like React giving you defined structure and hooks that call your code.

That’s because React started as a small, focused library and evolved as even more than a framework, a whole ecosystem, complete with its own best practices

A hill I will die on is that React is a framework.

Re: Avoid Mini-Frameworks

#33

Earlier quoted context omitted.

these things are hard, maybe impossible to define. For example I mostly agree with your calls/called definition but you also get self-described libraries like React giving you defined structure and hooks that call your code.

React is 100% framework. They even bring their own DSL. It's absurd to call React library. Library is something that can be pulled off project and replaced with something else. There's no non-trivial project where replacing React with anything would be possible. Every React web app is built around React.

Most people don't but you absolutely can use React a library. When React was very new, it was popular to use it as a view layer with backbone.js. In that usage, it's essentially a sophisticated templating library.

Re: Avoid Mini-Frameworks

#34
This was great. I enjoyed the alternative definition of "framework" as something that introduces new concepts (differing from the more common idea that it's code that calls YOUR code.)

This article reminded me of two classic pieces of writing.

The first is 20+ years old now: Joel Spolsky's law of leaky abstractions:

https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-a...

One of the reasons these mini-frameworks lead to problems is that they leak. They don't cover every case which means you inevitably have to fully understand what they are doing for you in order to debug them or work around their limitations. Your cognitive load goes up!

The second is Will Larson's "Migrations: the sole scalable fix to tech debt."

https://lethain.com/migrations/

The OP complains that they've never seen a technology migration at Google that finished. Will advocates for migrations to be driven by a team that both coaches other teams on the migration and then, crucially, finish the job themselves to make absolutely sure it gets done to 100% completion.

Re: Avoid Mini-Frameworks

#35
post #4

> Introduce new concepts that doesn't exist in the original stack That is also true for "macro" frameworks. > Wraps around the company/org-shared tech stack or framework That is often also true for "macro" frameworks. > Creators claim that the framework "magically" solves many problems, and push more people to use it That is often also true for "macro" frameworks. --- It is not clear from the reader's perspective wha…

If you have a very specific product with limited scope, a micro-framework would work just fine. My experience in the real world™ is as such: people start with micro-frameworks and keep bolting on stuff to the point where it would have been better if they started with a macro-framework in the first place. At least there is better compatibility between framework components and a clear upgrade process. I agree with the "makeshift framework" terminology by the way. One way or another, my experience is that products that start with micro-frameworks, over time turn into a "makeshift framework" over time regardless. If the scope is clear and limited from the start, micro-frameworks are great. If unsure, micro-framework is a no go (for me).

Re: Avoid Mini-Frameworks

#37
Making good abstractions is hard.

And it is very easy to start feel like you know you have a great abstraction when you don't. And unfortunately it's easy and fun to make abstractions, kinda like making babies. And has kind of similar weight to it too.

I just have to say.. stay safe out there.

Re: Avoid Mini-Frameworks

#38
post #5

> real and only difference between a library and a framework, is whether it introduces new concepts This isn't what is normally understood in software engineering by those terms. A library is something you call. A framework is some kind of application scaffolding that normally calls you. You can use more than one library. You normally only have one framework in-process. I found the blog post a little hard to parse. I…

> A library is something you call. > A framework is some kind of application scaffolding that normally calls you.

I think I broadly agree with this. In essence, libraries don't impose an application-level life cycle. Frameworks, generally, do.

The rest of the article, I don't know….

The most successful, long-running app I maintain has a mini-framework that allowed me to assemble what I need piecemeal rather than relying on any off-the-shelf framework that would have been obsoleted several times over in the seventeen-year lifespan of this code.

I guess about one in three things I do in it require me to dip into my framework code to look at it, but this is mostly to remember how it works! About one in five things have required me to make a small progressive change.

Twice in its lifetime a core component has been swapped out (mailer and database library).

And twice in its lifetime, because it is beginning to converge on a general web framework, I have considered porting the code out of it and into a general framework, which might make it easier to hand over. One day, I suspect, something will break compatibility in a way that makes that the sensible route, but the code works, fast, has a pretty obvious set of abstractions, and there are implicit examples of everything it can do in everything it already does.

Almost all articles like this start out with "here is a thing I claim is a generalised problem that I am sure you should not do", that is a well-meaning but false generalisation, and is then caveated to the point where no new point is being made.

Underneath they are always: don't write bad code. If you do, learn from it.

If I'd followed the advice of this article when I started this project, I would by now have rewritten the entire thing more than once, for little gain.

Much more concise and much more sensible: consider whether your additional levels of abstraction have value.

But do mini frameworks have value? Sure they do, especially if there is setup and teardown that every function needs to do.

Re: Avoid Mini-Frameworks

#40
Mini-frameworks would be dangerous at a place like Google where smart people think they are smart. I think they're heaven sent for smart people who think they're stupid.

Distributed (multithreaded, concurrent, ...) systems are a counterexample that are highly vulnerable to snake oil. In normal software it makes sense to build up from a small set of intellectually coherent primitives. In those cases you inevitably end up with poor performance and usually reliability if you try that. Java started out with a snake oil approach to threading (synchronized!) and Doug Lea talked some sense into them and now we have java.util.concurrent which has a rich set of primitives which are pragmatic and meet the real requirements, not a vision of purity.

On the other hand, If it was a mini-framework to pound out numerous not-so-simple HTML form applications it could greatly enrich your life and your team's.

Post reply on HN