Vue.js 2.8: the framework Vue 3 could have been
"We all want progress. But progress means getting nearer to the place where you want to be. And if you have taken a wrong turning, then to go forward does not get you any nearer. If you are on the wrong road, progress me
"We all want progress. But progress means getting nearer to the place where you want to be. And if you have taken a wrong turning, then to go forward does not get you any nearer. If you are on the wrong road, progress means doing an about-turn and walking back to the right road; and in that case the man who turns back soonest is the most progressive."
C. S. Lewis
I recently rewatched the Vue documentary from CultRepo, which is very nostalgic and inspiring. It brings back the memories of the Vue.js 2 times when this framework was a symbol of openness and creativity in JavaScript web development, with its emphasis on developer experience, simplicity, and comprehensive documentation. Interestingly, the documentary refers to the notorious AngularJS to Angular 2 migration nightmare in a derogatory way but at the same time Evan You had created a nightmare of his own with the Vue.js-2-to-Vue-3 transition (notice, even the gradual name transformation from Vue.js to Vue is kinda symbolic here) β practically following the template of the Angular team's disaster. During the latter, as some grannies can recall, developers who loved the intuitive ease-of-use and simplicity of Angular 1 felt completely abandoned by Angular 2. Vue came around at the perfect time to capture those migratory developers by offering the strength of React combined with the low barrier to entry of early Angular. And yet again β the framework had stepped on the same rake, leaving developers who probably just started to reΡover from the trauma to suffer the same betrayal again.
Vue.js 2 officially reached its End of Life on December 31, 2023 which is quite a while ago. There are practically no traces of that in modern world of grown and fantastic Vue 3. For what it's worth, it was an opinionated and contradictory evolution. Composition API solved real problems, for sure, but it also solved problems Vue.js 2 developers didn't have, at the cost of a model they really liked. What if the next Vue had been an honest continuation instead of the Hulk-like instant mutation? What if Vue.js 2 had simply gone on β 2.8, 2.9 β with the tools we have now, the same simple DSL, and a little more room to breathe?
This post is a modest nostalgic (and, I accept, slightly melancholic) attempt to look at this probabilistic scenario in a butterfly-effect-like way, without any didactic plea for revival. There's no specific reference to the Gridmix project here (that still sits on Vue.js 2 as a small monument to the warm past, but may well move to Vue 3 someday soon) but it's needless to say Gridmix loves Vue and not indifferent to that topic, especially in the context of lazily-ongoing update of dependencies and infrastructure.
Hey, Number Three, what have you done?
The main goals of Vue 3 changes were to open the door to better framework performance and to balance readability against scalability. Vue.js 2's components were basically slightly creased paper pages you could easily read. Vue 3 asked you to redesign the page and wrap it in solid transparent plastic in order to meet (and withstand) the scale demands.
The grand rewrite (which it was) was sore: Object.defineProperty is out, Proxies are in, a new renderer, a new way to start an app, a big list of breaking changes for a framework people chose because it was small. Even the compatibility build shrugged at the libraries that had grown into Vue.js 2's habitual cozy hand-made furniture. For Vuetify, Nuxt, and Vuex, the migration became a challenge for years (sometimes), not a chilly summer sprint. Vue 3 shipped in September 2020, became the default only in February 2022, and Nuxt 3 and Vuetify 3 called themselves stable in November 2022.
Developers often felt some form of doubt, calling the new major version a mistake not to repeat, the wrong solution to a real problem, and rolling their eyes at AngularJS EOL-LTS vultures rubbing their hands over another quick win. The framework creator himself walked through the break in a positive way while being more candid at (rarely cited) Vue Fes Japan 2023: too many breaking changes in one release, underestimated ecosystem impact, too much shipped at once, and so on. The migration he had watched Angular inflict, he later described in his own project β isn't it a kind of a daydream irony?!
What Vue.js 2 got right
Vue.js 2's charm was never that it was the fastest thing in the room (though it was kinda OK anyway, that's for sure). It was that a component felt like a small, easily-readable, honest contract with the author β and no small-font paragraphs at the end. this was a comprehensive skeleton, options were a concise schema, a component was easily "greppable" even with a tired mind β like a hand-drawn pirate map from your childhood, with data, computed, methods, watch, mounted as familiar islands you always knew how to navigate through. You did not invent a private topology of nested functions and hope the next reader would reverse-engineer your taste β you just put state where state lived, derived values where derived values lived, and side effects where side effects were allowed to stand.
As for the template, it was warm DX, if the phrase still means anything, where a new person opening a .vue file knows exactly where to look without a guided tour of setup() folklore (Gridmix still feels like that for me and I cry when I think of the somewhat inevitable future migration). Take a static site, or a modest admin screen, or a marketing page with a few interactive "islands" β none of that should require a composition seminar before the first button works. Mixins were imperfect and still, in their way, brilliant: list a behavior, and its pieces appeared on this as if they had always lived around. Vuex was stern and somewhat ceremonial, but it was one story about shared state, not a bazaar of patterns that each team re-derived from blog posts or whatnot. In conjunction with documentation with a low barrier to entry, that all was quite controllable and very humane.
Of course, all of that was not without some significant tradeoffs, with implicit mixins intermixing, getter/setter reactivity holes bigger than the ones in our feet after using them, huge options objects when a screen grew with adult responsibilities, alluring but poorly reachable TypeScript, performance "inefficiencies"... We all have sins, haven't we? But those sins didn't necessarily ask for a new religion. Better tools at most, at least for most of us β especially as the tools were already on their way, like new bundlers, the proliferation of language servers, compilers all around, and so many more. So let's attempt to imagine: what if history gave us this gift of better tools?
Under the hood of the fantasy
What I imagine Vue.js of versions 2.8+ would become is something that preserves the same developer habits but is faster underneath and a little more flexible in day-to-day life β nothing too fancy, significantly different, or breaking the habitual development paradigms. Instead, the Vue.js of my dream would have:
-
Signals under the hood,
thison the surface. You'd still writethis.count++as usual but, similar to Solid (or Preact) and Vue 3's own experiments, re-rendering would be managed in a more efficient reactive way β as an implementation detail though, not a new API to learn. - A Vapor-style compiler to help. The script-tag runtime would stay for simplicity but you'd get a Svelte-like compiler to choose to compile your way out of the excessive Virtual DOM diffing, implicitly changing how a Vue.js 2.8 template renders under the hood.
-
Filters back.
{{ price | currency }}was (arguably) a small and neat AngularJS-inspired joy, thrown away in favor of calling a method. Vue.js 2.8 would keep the pipe/filter approach, giving filters imports and types, and letting the compiler fold them in. Presentation stays in the template, where it is much more readable. -
Mixins (with optional composables). A mixin is implicit on purpose: you list it, and its
data,computed,methods, and hooks show up onthisas if they had always lived there. That was a hell of a habit. You wrotethis.formatDateand you are done. The trouble was never the implicitness per se, but rather a potential collision you could not see. Something like an improved "behavior" primitive with better collision detection (through better dev tools too) could resolve that. Composables would also remain, as a useful addition. -
asyncData(instead of Suspense). Nuxt 2 already had the popular humane version: a place on the page that says what data it needs, then merges it into the component you already understand. Vue 3 reached for<Suspense>and left it experimental, though it probably would have been better off going with the thing people already liked. -
Strict templates (proven possible by neighbors). Angular type-checks its own DSL without turning it into TypeScript.
strictTemplateslooks at{{ }}, inputs,$event,@forlocals, and pipes, and the compiler does the translation behind the curtain so TypeScript can complain in the template. Vue 2.8 could have the same kindness: a misspelledthis.count, a prop of the wrong shape, av-foritem treated as a string when it is a post. The editor/IDE underlines the template in a habitual way with a friendly inline error message β no need for TSX, orsetup(), or fancy new grammar. - More nice extras from the ecosystem experience. Fragments, and teleports β like, for instance, backported style blocks that can see component state β and lots of other delights that can easily fit the old good ways too.
-
Faster tools without paradigm shifts. The 2020s handed everyone a faster dev server. Vite, yes, but also Rspack, Parcel, Turbopack, esbuild, SWC β a whole generation of bundlers, many of them Rust, some Go, all of them mighty enough that "the build is slow" stopped being a reason (or one of them) to rewrite a framework. A language server in your editor could learn to love a plain
.vuefile too, without requiringsetup().
All in all, a Vue.js 2 that stayed could have taken the new tools and thoughtful, reasonable (and suitable) approaches and remained itself at the same time. What a cake would that be!
Performance implications
Let's be honest, nobody here is chasing a perfect score, really (otherwise everyone would use something esoteric like doo.HTML or whatnot). "Bearable" would have been enough for most of the practitioners (including the enterprise) if the DX remained on par. The described Vue.js 2 of one's dream would (maybe) even catch up with Vue 3, who knows β a smarter compiler, signals, and that new generation of tools could have gone a long way without asking us developers to change how a component looks and feels. In fact, as many would agree, I believe, the migration loss that stings isn't a benchmark, it's rather that "faster" became a reason to stop being the framework people loved, and to grow a fancy (and, again, ironically Angular-like) performance machine instead (without any actually impressive performance records too).
In the end
As a veteran of several migrations in the JavaScript world, I still truly believe the question "what if we'd fixed it instead of replacing it" is worth asking, even for a framework you love β was worth it always, and is even more worthy today, in the age of multiple easy-win temptations fed by impressive and somewhat magical technologies of our days.
What this frivolous exercise has helped me verify for myself again is that the Composition API (along with other awesome Vue 3 stuff) made Vue.js more powerful and less itself, which could most probably have been avoided. We might have had the good old framework now but quicker, kinder, and still itself β the framework developers actually love. But history does not tolerate the subjunctive mood. So let's proceed with building the new history with precious instructive knowledge gained with our gray hair.
The cover photo by Cai Fang from Unsplash
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.