Frameworks are for hacks, libraries for seeds
sencjw.com
sencjw.com
Because a framework is basically a set of libraries that work together to help you get to a certain goal.
If there's already a framework that helps you get to a certain goal, it can save you a lot of work to use that existing framework instead of making your own. It can also save you a lot of security issues.
But if your requirements don't really connect to the things existing frameworks provide, you'll have to build your own custom framework by collecting all the libraries you need and making them work together the way you want. Maybe you can make a framework out of it so the next person that has the same requirements as you doesn't have to go through this process again.
A framework IS the entry point to your application. If you use libraries you write your own entry point.
I can see the distinction that people are trying to make here but it's far from a binary one.
Deciding to use a library might, of course, also force some other decisions, because the library has dependencies, but the decisions should be more constrained than they are for a framework.
It's entirely possible to build applications without infecting it with anything that looks like a framework if you resist the urge to create unnecessary abstractions and keep coupling to an absolute bare minimum. Keep it simple and focus on the task at hand.
Arguably a framework is a lot more than just a set of libraries - it's a formal specification for how you layout your code, from what directory you put a class in to how you do your database migrations. Dropping a few libraries in to an app won't make you work in a specific way. Using a framework will.
Truth is,with dependency injection, one doesn't need a framework.But most people writing Ruby or Python apps don't understand the value of a registry that lazy-loads objects and it's dependencies.They mix module systems with IoC .
In theory, sure, and as another poster said that's exactly what the PHP-FIG (PHP Framework Interoperation Group) have achieved over the past year or two. However, in practice, the big frameworks that most developers and employers use give you much more than just a set of easily plugged together libraries, typically enough more that you end up building software on-top of that framework, and extracting your product out onto another or swapping a library out becomes nigh-on impossible.
Yeah. Back in the day we called that "writing a program".
If a company isn't going to use a framework, they had better architect and spec out their app with heavy documentation. I would argue this is more for the stability and future of the app and company than it is for ease of hiring purposes.
Without a spec or framework, you run the risk of ending up with various styles of code (often times some really terrible stuff) sprinkled throughout the codebase, constant arguments between devs (as there is no established standard within the code) and a mountain of "tech debt".
That's only relevent when you are hiring someone to deal with the monstrosity of a rails app that you ended up with because the abstractions didn't quite work for the problem you were trying to solve.
I've found it very easy to use some Rails best practices in a Sinatra app and not have to deal with all the routing/controller cruft in Rails, while still getting sensible filesystem conventions.
But in any case, I prefer that over working with a framework. Frameworks pretend to have everything figured out, but in reality they have not, and they are a pain to work with if you deviate the slightest from the "master plan".
Also, libraries are more easily replaced than frameworks, which is a huge advantage. And they invite you to think modularly, rather than monolithically, which helps to keep complexity down.
This is a real problem, certainly. In very bad cases (anyone remember programming COM from C++?) the burden of making a simple function call from one part of your code to another can be soul-destroying.
This is why I think the modern kitchen-sink standard libraries might be missing a trick. Instead of trying to provide everything out of the box, often to an acceptable but not best-in-class standard, what if our programming languages concentrated on just establishing conventions and providing universal tools with relatively small standard libraries, and then emphasized tools to connect different libraries from other sources together? That is, could they make it easier not just to import modules from different libraries but also to convert data types and match calling conventions and initialize/close down run-time systems?
Plenty of ideas have already started down this path, from implicit type conversions or coercion to full-blown lens libraries, simple calling convention annotations to full-blown FFIs and wrappers, and so on. However, to my knowledge, no mainstream language today has an explicit design goal to make integration of multiple modules that have related functionality but different conventions as easy as possible. I wonder how far we could run with that strategy.
Right now it's just in the "I'd like this and this" stage, but I hope to work on it more this year.
Frameworks by their nature affect the whole codebase.
This is the low-coupling/high-cohesion benefit of libraries as seen in many places in software engineering.
A codebase with low coupling is inherently more flexible and maintainable. Libraries and well defined, sensible interfaces are critical to good engineering.
It's not that frameworks are bad; they quite clearly have their place. It's that they are short term hacks, and as such there is a time and a place for using them, but they aren't a long term solution to a problem.
It is true that you have to lay out more infrastructure yourself working this way but I feel that this is a really good thing because it makes you really think about the problem you are trying to solve, and don't just think in terms of the patterns your framework offers (e.g. MVC: "I have some logic, so I'll put it into a controller!"). This usually leads to code that is a lot easier to understand and is easier to test. Also, every application is different and with the framework way of doing will always end up having to shoe-horn things.
From the nanosecond the user hits the power button on their little box, and the BIOS loads 0x7c00 and executes it (loosely defined, frameworks call your code), we're in framework world.
You want your browser loaded? Better hope that the user clicks it, and the OS calls your code, because otherwise you're malware (and you were still loaded by the OS). Want users to visit your site? Unless you're a virus, you're gonna have to wait for their browser to navigate there. Another framework.
The idea that frameworks are not for writing software to me is just ridiculous. It's the only way useful modern software can be written. Unless of course you yourself have created the hardware, OS, and layer upon layer of userland software that you're going to rely upon, you really need to acknowledge that your code is 99% dependent upon frameworks.
On the contrary, if the only connection between my code and the kind of "framework" you're describing is the entry point, my code is 99% not dependent upon frameworks. I am free to structure the remainder however I wish and to incorporate libraries on my terms wherever reusing their code is helpful.
Even if those libraries might encapsulate some functionality that calls back to some OS API, they do so when I want to use that functionality, not when the OS requires me to make that API call. So for practical purposes I don't think your analogy between system/platform software and frameworks holds at all.
You're interpreting the poster by pulling the definition past the breaking point of any utility to this conversation.
Either air your grievances with the word "framework", or try and read what the author meant.
> In computer programming, a software framework is an abstraction in which software providing generic functionality can be selectively changed by additional user-written code, thus providing application-specific software. [1]
I fail to see how I'm stretching this definition at all, especially if you read further into the wikipedia article. I believe it's critical that I acknowledge when I'm wrong, lest I stay stagnant in my understanding, but I don't think I'm wrong here, unless somebody wants to point out a specific area.
Userland software customizes and reuses default behavior of the OS for application-specific purposes. Web pages customize and reuse default behavior defined by the HTML, CSS, and JavaScript specifications. Same goes for Operating Systems on top of the BIOS and on top of the hardware itself.
Frameworks are useful, basically unavoidable, and critical to take the time to understand if we're going to be effective at any level, be it consuming them or providing them.
EFI, on the other hand, is quite framework-ish.
It seems to be a really good idea. It solves the exact problem that the author has.
However, I think there's more here that the author skirts around. He laments the fact that "in-fashion" changes to a framework force you to refactor your code. I'm not so sure that this is purely a negative thing. Let's take the upcoming Laravel 5 as an example; on the face of it, Laravel 5 is a drastic departure from Laravel 4.2. The directory structure is completely different, and the way you interact with The System is changing in a subtle but significant way (middleware). Is this cause for consternation? Perhaps. It requires developer time to upgrade, which is not free. But the gain is twofold: you benefit from using newer and, ostensibly better, structure around your app; and you grow as a developer, because you learn a new way to do something familiar.
I'm not saying here that the author's assertion that this is unnecessary is incorrect; just that there are benefits to being forced into change.
Also, regarding libraries: just because two libraries deal with the same topic or technology does NOT guarantee that they'll make the same assumptions about abstraction. Even on the device driver level, you can't take that for granted.
They were useful because learning them and walking through code while debugging showed me all sorts of best practices (and worst practices). When I wanted to use the GDI I grabbed a handle, basically a hash in a lookup table somewhere. This made sense. When I was programming custom VBX controls, I used the USER part of the WM_ space and sent messages back and forth. Loved the message loop paradigm.
But then something funny happened. Frameworks no longer helped me complete a complex project, they actually got in the way of doing it, by adding a lot of intellectual overhead for very little return. I started seeing new programmers pick up some training, start using a framework, and then get completely lost when their work took them anywhere off the "happy path". People would spend a hell of a lot of time learning framework X, only to eventually realize that the next job required framework Y.
As I got older, my recall isn't what it used to be, which actually turns out to be a good thing -- it forces me to focus on important things instead of minutiae. I got much more radical about web apps. I'm happy with static web pages that are interactive for most everything. I don't code things that do deep-dives into the guts of the stack. I'm looking to provide the most value in the least amount of time (and cognitive overhead). I moved to pure FP.
So now my order is: 1) Code it myself, 2) Use a precanned library, 3) Use a framework
The frameworks I use are very small: JQuery, .NET, maybe one of two others. I like it that way.
I'm not talking simple tooltips, I'm talking about real components. Sencha's tree.Panel comes first to my mind: http://docs.sencha.com/extjs/5.0/5.0.1-apidocs/#!/api/Ext.tr...
It has extremely powerful feature set (based on the other features of the framework) out of the box and you can very fast switch your focus on other things besides re-implementing the wheel.
I simply haven't found some of these things as simple libraries. They nearly always come within complete frameworks, because they have had to implement a lot of stuff that really just requires other features from frameworks. And, no, I'd rather not spend a year implementing that feature set.
There are a lot of platitudes here whirling around a central point: Frameworks are more restrictive than libraries.
But, omgwtf, that's exactly the point of frameworks - they enforce convention in exchange for faster development. Also, newsflash, any large software project is going to have its own conventions. Okay, so, if you're still following me, get ready to take a leap. What if we have conventions that can apply to more than one project to reduce the ramp-up time for programmers to contribute?
The neophytes on HN eat this kind of stuff up, without ever considering that the thing the author is whining about is exactly the intent.
Building your own "framework" from a good collection of libraries tends to not have this problem. Also, if it does have that problem (this library is getting in my way) you can usually more easily exchange the library for a different one.
Note that developers tend to disagree on the definition of framework. When I say framework i'm saying something like Rails or Django that is a big monolithic thing that your application is built upon.
Frameworks quickly allow you to go from 0-80% without having to start from scratch. You just take something that already exists and then fill in the gaps with your values, colors, content etc.
I agree with gitaarik that in the grand scheme of things libraries are also like a framework.
Win32, Swing, iOS, et al aren't really frameworks in the same sense that something like Rails is. Win32 doesn't care if you name your code something that clashes with The Revelation Given To Great Prophet DHH; all it cares about is that your WNDPROC behaves like it should. The OO variants of this only care that you derive your UI classes from the framework's classes so you can be notified of relevant events. Nor did these old 'frameworks' (as often incorrectly stated) prescribe the underlying architecture. They didn't force you into MVC for every single project, they didn't force you to use a database for persistence.
Monolithic frameworks are a modern fetish; borne out of a Stockholm Syndrome for the Business: "how will we hire easily replaceable workers?" / "how will we spin someone up in the minimum amount of time?". The answer: programming by MadLibs.
Developers advocate for them because they provide immediate gratification for doing very little work. They confer a mediocre architecture on all projects, which is perceived as preferable to the hard work of designing and architecting a system from scratch. They are a form of blame-shifting by developers: they can offload some of the risk and the Hard Parts of development to a Smart Person/The Community and run to them for help when it breaks. This is not a bad thing, but it does stunt the design impulse, and limits their growth as developers.
In the case of Rails, choosing Rails is no guarantee of project quality, or even conventions. Are you using Postgres, Mongo, or a combination of data stores? If it's the latter, then AR's transactional niceties are out the window! Are you using regular Rails views, presenters, or decorators? When you structure your controllers, are you using The Rails Way (fat models), or services, or more Bernhardt-esque design (app lives in lib/)? All of these things require spin-up time to learn the where and the why.
I do think frameworks are a symptom of propping up conceptually weak abstractions (e.g. the web) and languages. It should be concerning to you that all the metaprogramming in the world + a fully dynamic runtime cannot produce a framework that makes it easy to produce minimally coupled run-of-the-mill business software that doesn't require horrendous hacks like Rails' Spring.
Buy a copy of Growing Object Oriented Software, Guided By Tests. The author builds something sans framework, letting the construction of the software guide him to the best design. The resulting software is lean, supple, and easy to extend.
If you work in a company with 10 different teams that all do different things and all need to develop different applications that work together, you need a framework.
If you want to leverage an existing fully-functioning suite of interoperable function abstractions to extend a small amount of custom behavior in a minimal amount of time, you need a framework.
This whole article is ridiculous because it's essentially comparing using an existing product to developing a new product, and calling the former a hack, and the latter some sort of higher art form.
Also, of course Win32, iOS and Android aren't a framework - they're platforms. You still have to build a framework for the platform. And Swing isn't a framework either, it's a toolkit; you use it to write software for a framework.