Many things can be identified as BS simply by asking the question “What is X?”. Today, X = “framework”. First of all, what are some examples of things that have been dubbed “frameworks”? I’m sure they’ve been around for a long time, but in my mind, the mother of all frameworks is Rails. Other things that are similar enough to Rails to be called frameworks include Django, Pylons, and CakePHP. All of the examples that I’ve mentioned so far are web frameworks. But what about frameworks for things besides the web? Surely the concept can be applied more generally.
Because Rails is the hot shit, everyone else has decide you need to slap on the same label in order for your project to be cool. Exhibit A: Prototype. Let me be the first to say it: this is not a framework, just a library. Don’t get me wrong; I actually like using it, but it just isn’t a framework. At this point, you’re probably thinking I’m splitting hairs and getting frustrated with me. But if the word “framework” is to have any meaning and be at all useful, we can’t run around calling everything a framework. I think if you’re a serious engineer you should care about get things technically right, which means getting your language technically right.
On the surface, Prototype and Rails have much in common:
- They both provide basic functionality that would be useful in a wide variety of applications.
But guess what? The same thing can be said of many things that are clearly not frameworks. For example, Java provides basic functionality common to many apps, and (mostly) abstracts differences between different operating systems. In fact, anything that provides a useful abstraction would qualify under these terms.
In contrast, Rails forces your application to follow a particular structure. I’m not just talking about the MVC design pattern (perhaps a topic for another day), although that’s certainly part of it. I’m talking about the way Rails forces you to put your files in the right directories, and the way the framework knits those files tightly together to serve requests for dynamic web pages. For example, if your FooController has a bar method (“action” in Rails terminology), you need to have a file named bar.html.erb in your foo views directory. As for mixing Rails with something else, I’m not even sure how that could possibly work. Maybe if two parts of your site share the same model classes? Then again, your model files do not contain any of the necessary require statements that would allow them to stand-alone. Rails does that for you.
Whenever I’m trying to wrap my head around something in software, I like to try to think of analogs in physical systems. Imagine you have a complete car minus the engine and body panels. You still have the cupholder, power-windows, stearing, etc. That’s sort of what a framework is. You get to drop in your own engine, and stick on your own body panels, but you don’t get to choose your shock absorbers, stereo speakers, or which side to fill up on. Sure, you can hack these things to get them the way you want, but good luck if anything breaks and you need to bring it in for servicing.
Building a car would be very different from starting out with big pile of seats, windows, doors, air conditioners, gas tanks, etc. There are very few limits on how you combine these to make a complete car, but you might want to settle on whether you’re going to use metric on imperial units. It’s somewhat of an arbitrary decision, because there’s no reason a metric car seat cannot be married to an imperial gas tank; nevertheless, you’ll probably want to standardize on one or the other so you don’t accidentally chew up the imperial threads in your expensive engine block with a metric bolt.
The thing about libraries such as Prototype that gets people confused is that they provide basic functionality that would be useful in a wide variety of apps. In our car situation, they’re sort of like nuts, bolts, hoses, gears, and shafts. Unlike a framework, these things do not dictate the structure of your app. Although we tend to think of libraries as being more specialized, this need not be the case. A library is just a standard set of parts that you can put together in ways that need not follow a particular structure.
Now that you understand the difference between things that are frameworks and things that aren’t, I hope we can stop abusing the terminology.