I first heard about the dinosaur 🦕 VS shark 🦈 analogy when I read this excellent article about relational databases:
You see, relational databases aren’t dinosaurs. They aren’t lumbering prehistoric relics doomed to extinction by a changing world. They are sharks. Apex predators honed by millions of years of evolution into a perfectly adapted creature that is just as effective today as it was eons ago.
In engineering field, when new technologies pop out, they tend to make the older one look worse. The hype could make us think that new tools are intrinsically better. This can prevent us to have an honest reflexion about the choice to make.
We, as developers are unusually curious creatures, and can be very excited by novelty, I get it. But we should get even more excited by avoiding unnecessary complexity, or making safe bets, because in the end, it matters more. We have to remember that the only goal of tech is to support business the best we can. Hence, the less tech you need, the best it is.
I think there is a serious shark in web sea: the monolithic MVC framework. Rails (Ruby), Django (Python), Laravel (PHP) and many others. They've been here for a long time, and even they're kind of boring, they still do the job very well. Of course, they're not the right solution for every use case. Like any piece of tech, there are always trade-offs to consider.
But I'd like to explain, in an opinionated way, why I think this piece of tech should not be discarded so easily just because of its age. If you acknowledge with many of the points bellow, odds are an MVC framework could be the right tool for your project, even in 2022.
Let's say your startup needs two different kind of apps:
In a monolithic approach, having the same backend for your both apps will considerably ease the future operations.
Micro services are trendy and useful in specific cases. But they still don't make monoliths dinosaurs. Many startups came back from them. They were lured by the promises and underestimate all the trade-offs, especially because of their inherent complexity. Besides, micro services require more skills and people to be operated.
As Martin Fowler said:
don’t even consider microservices unless you have a system that’s too complex to manage as a monolith
Last years, using MVC framework was not an option as soon as you wanted a dynamic front-end. Having to reload a full page for every user action leads to a bad user experience and is indeed, not acceptable in 2022. To add some dynamism to your page, you had to mess with jQuery and AJAX, which often lead to very complex and hacky code in y opinion. That's why many of us started using SPAs when AngularJS came out. It was a true revolution!
So, what is HTML over the wire and why is it game changing?
As explained on this page:
Hotwire is an alternative approach to building modern web applications without using much JavaScript by sending HTML instead of JSON over the wire. This makes for fast first-load pages, keeps template rendering on the server, and allows for a simpler, more productive development experience in any programming language, without sacrificing any of the speed or responsiveness associated with a traditional single-page application.
So, you can now have a good user experience AND developer experience, while keeping the very simple MVC approach. You won't need to maintain 2 different projects which communicate with a JSON API.
Hotwire is the dedicated solution for Rails, made by its creator. HTMX is a more generic solution usable with any HTML. I suspect lots of SPAs built today could be replaced by this approach, with more benefits that losses.
Stop reinventing the wheel, stop making your own customised stack for every little unimportant thing. When you have a common need, you can be sure some team already did the job, and better than you'd do it.
And reinventing the wheel is not just building stuff by yourself, but also gluing stuff together. Gluing pieces of software is not easy. You have to handle compatibility, dependencies, etc. In an MVC framework, each battery is thought to integrate with each other.
You can spend so much time just evaluating simple libraries that do a single thing that in a sense, having all batteries included avoid the paradox of choices. But you're still not forced to use all the batteries. It's a "progressive" philosophy. You can even replace one of the provided batteries, if you have a real reason.
Security? ORM? Authentication? Permissions? Template Engine? Middlewares? SMTP tools? Internationalization tools? CRUD GUI? You got covered. All of them made by the same team, ensuring a consistency over time: when you go from v3 to v4, you know everything still should work together. You spend less time maintaining your whole customised stack, in which every package would evolve at its own pace, in total independence.
In tech press, I keep hearing about "tech X" is more performant/scalable than "tech Y". These metrics are important to know. But the fact your MVC / monolith is slow or does not scale may actually has nothing to do with the technology itself. In a request/response HTTP cycle, there can be so many ways to slow things down. To name some of them:
So before blaming "framework X" or "language X", ensure your own work is clean. And ask yourself: "before tech X exists, were we really unable to build fast and scalable websites?"
Yes, you can write a "Hello world" very quickly with few lines of code with a lightweight framework like Flask (Python) or Express (Javascript). And then what? Except the feeling you can start faster, there is no real point in having less files or less lines of code. Because the situation will be different as soon as the project will grow.
Even if it can be true in some cases, here are some points to keep in mind:
You're using node.js? Cool, me too!
The more the tech tools you use are "low level", the more there will be a bunch of ways to achieve the same task with it, because you'll need many other tools, which will differ between two developers.
When someone says "I use Rails" or "I use Django", you feel pretty confident to understand its code quickly, because there are less ways to do exotic things.
There are even projects in the JS world, like Nest JS, to recreate these conventions.
This is actually a good point: it make things easier. To achieve this, there is no other choice that using Javascript (or any translate-to-JS language) on the back-end, because you're forced to use it on the front-end.
However, from what I've seen, there is still no Rails / Django equivalent in JS world. Sails JS has a low satisfaction rate. Nest JS looks more like a wrapper around existing tools than a real framework. Blitz JS looks promising but has not enough traction. That may just not be the philosophy.
In addition, you may prefer using another language you feel more comfortable with, even if it's just for backend. For some people, Python or Ruby could be easier, more readable, or have a better standard library, etc.
One day, I asked on Reddit:
If there is a wonderful MVC framework available in Javascript tomorrow, would you drop Django or Rails to go full stack JS?
Some JS lovers answered "yes definitely", some JS haters answered "If I can use a Ferrari 70% of the time, and a Twingo 30%, why would I want to use a Twingo 100% of the time ?".
In that sense, I agree that being comfortable with the backend language can be more important than using the same language everywhere.
Another point is that you're not even sure to use Javascript extensively on the front-end because:
Here are some generic advantages you get with maturity:
We focused on strengths of MVC frameworks and multiple reasons to consider them carefully. It does not mean they're perfect and I guess we could find lots of projects in which they're not the right solution.
But as a general rule, I think we must not discard a technology just because it's old. Doing so because it's too new would make more sense, if you want to build stuff for businesses.
MVC monoliths are like relational databases, they are not dinosaurs, they are sharks. We, as developers, are forced to spend lots of time to learn new tools and concepts. So, we should be relieved that some pieces of technology we learnt years ago are still relevant today. So the next time you catch yourself thinking "this is boring tech", that may be a positive thing for you and your project.