Frameworks as Stepping Stones
Joe Gregorio: But something else has happened over the past ten years; browsers got better. Their support for standards improved, and now there are evergreen browsers: automatically updating browsers, each version more capable and standards compliant than the last. With newer standards like HTML Imports, Object.observe, Promises, and HTML Templates I think it’s time to rethink the model of JS frameworks. There’s no need to invent yet another way to do something, just use HTML+CSS+JS.
I’m curious as to where Joe believes that these features came from. For example, promises were first proposed in the 1970s, made their way into a number of frameworks, were extracted into a common implementation and then standardized.
The true story is that Joe’s “gradient” picture is incomplete:
There’s actually a gradient of code that starts with a simple snippet of code, such as a Gist, and that moves to larger and larger collections of code, moving up to libraries, and finally frameworks:
gist -> library -> framework
A more complete picture:
gist -> library -> framework -> standard
And even that isn’t complete. Standards are backported using polyfills, and frameworks are updated to use feature detection to make use of standard implementations as they become available.
I’ll also mention a few libraries/frameworks I’m fond of, and how they fit:
- Underscore.js. This library implements a number of methods that really should be a part of the language. And in a few cases, are (scan that page for the word native). I’ve been a member of ECMA TC39 off and on for a decade and a half, and based on what I have seen, JavaScript will catch up with Underscore in 30 to 50 years.
- jQuery. Their official slogan is “write less, do more”. While that’s true, “make DOM suck less” is equally as true. Like with Underscore.js, it predated features like querySelector. One last comment before I move on: abstract away the platform is not true for jQuery (nor for any of the libraries/frameworks I’m mentioning here). The key abstraction jQuery provides is a collection of DOM nodes. You can determine the number of element in the collection by using the
length
property. You can access individual DOM nodes using indexes:[0]
,[1]
,[42]
, etc. - Bootstrap. While this project contains JavaScript, its true focus is on providing a higher level of CSS constructs than the browsers currently provide. Things like modal dialogs, dropdown menus, tabs, etc. It is worth noting that they do this with “just” HTML+CSS+JS. Sure, you can reinvent these concepts for yourself, but why?
- Angular.js. Joe mentioned that he hasn’t needed data binding yet. I’ve written a fair amount of small web applications. Some have grown to become bigger and unwieldy. I’ve taken a few of these and started to separate out the client side model, view, and controller, and in the process found data binding to be quite handy. Now I can write larger web applications, and go back and add features months later without being afraid that I am going to break anything.
In each of these cases, I’m confident that the best ideas of these libraries and frameworks will make their way into the web platform. Meanwhile:
The future is already here — it’s just not very evenly distributed.