Why You Shouldn't Use A Web Framework

David Wickes - Jul 26 '18 - - Dev Community

What framework are you using? Are you using Bootstrap, or Materialize, or Foundation? Or Vue, or Angular 1, or Angular 2, or Ember? Or Ruby on Rails, or Sinatra, or Express, or Meteor, or Flask, or Korbin, or Hapi, or Spring, or...

Frameworks are all terrible. All of them. I'm serious - they are making you all into bad developers. Stop using them now.

Let's talk about this, as I may have lost most of you with that opening. Why do people like you like frameworks? Are you weak or are you stupid? Or both?

A framework means I don't need to reinvent the wheel

Sure, I'm building a bike. I don't need to reinvent the wheel, I'll just grab a framework with a wheel.

And a steering wheel

And a bonnet. In blue.

And an engine.

And a CD player

What, you don't have any CDs? Fine, just don't use it. Or just use the CD player to MP3 player adapter.

For your bike.

Which you're still building. But now on top of a car.

But it's fine, because AutocarJS has a modular plugin system to allow you to add bicycle pedals to your car-bike abomination. It's easy. Just type 'autocar scaffold add pedals'. Or edit the autocar.js.manifest.nightmare file.

This is much easier, eh?

"You don't need to reinvent the wheel" is fine under two conditions:

  • you know how a wheel works
  • you know how this wheel works
  • this wheel doesn't come with a whole bunch of crap you'll never use
  • you only want a wheel

It's easier for beginners to use a framework

Sure, if you're a Sith.

What? Yeah, a Sith Lord in a weird black bunker. You went for the fast path to ULTIMATE POWER, but you still don't really know how HTTP works. Or what a POST request looks like. Or how to write a form element. Or how to use a database without some freaky ActiveRecord nightmare layered on top...

And it's addictive, Because you don't know how anything works you'll spend your career chasing the NewShinyFrameworkJS because ShinyFrameWorkJS didn't quite do what you needed. You will suffer from eternal imposter syndrome because you don't know how anything works. You will get your job done, you will be a 'React Developer' or an 'Rails Developer' and you will wonder what went wrong.

True story. When someone interviewed for a position at a well known coding bootcamp they were asked to do the FizzBuzz kata in Ruby. First thing they typed at the command line?

gem install rails
Enter fullscreen mode Exit fullscreen mode

You're Anakin Skywalker and all you've got to look forward to is a life where you have no idea how anything works and your career and livelihood is built on the sand of your ignorance. No, you're not Darth Vader. You're not that cool. You're Anakin and you suck.

Angry Vader is Angry

But it's really hard without a framework

Is it? Is it really? Have you tried to write something without using a framework? I mean, can you write a beautiful, complicated, client-facing website without a framework? Say something like GitHub...

Github has no framework nao

YES YOU CAN!

The web is a much better place than it was ten years ago - hell, ten months ago. You don't need a framework - you just need to spend a few minutes reading the docs on MDN. You don't need Sass, CSS has variables now. You don't need Bootstrap, flexbox or grid are your friends.

What about that server stuff? How does that even work unless I'm using
a framework?

Are you kidding? Have you seen how simple HTTP is?

Easy HTTPeasy

Look, an HTTP request:

GET /hello-world?framework=none HTTP/1.1
Accept: text/html
Host: my-hello-world-server.com
Enter fullscreen mode Exit fullscreen mode

Does this seem too hard to parse? Really? You can read it like it's words almost. It's just a big old string. You should be able to extract out the which content type you want to accept, the method, and the query string parameters for this with any language you choose. If it's this easy, why are you relying on a bloated, opinionated framework to do all the work for you?

I'm not saying you should write your own abstraction over HTTP - almost every modern programming language has an abstraction built in that will do the heavy lifting for you. And if it's not built in then it's a readily available library. Go use one of them - an easier way of interpreting requests and responses over a socket. Which is really all you need.

'Abstraction over HTTP' is the key idea here. That's the bit that needs abstracting away from a stream of bytes over a socket into something sane. A framework is an abstraction over... a whole mess of things. It's usually an abstraction over somebody else's idea of what a website or a program ought to be. It's not your idea, it's not your product - it's theirs and it's limiting your creativity.

Learn the basics, not someone's abstraction

Stack Overflow is full of questions like "how do I do X in framework Y" with answers that range from "why do you want to do X?", "No, you can't", or "you can't do X, but why not do Z?".

It's because the poor dev asking was used to using a framework where the database was attached to the request object or whatever, and now they're using NewShinyFramework with a completely different abstraction. They leaned the wrong thing.

If you want a solid start to a career, don't learn a framework and a framework's abstraction; learn the fundamentals.

Don't learn Express's routing system; learn how HTTP works.

Don't get familiar with ActiveRecord hacks to make your queries faster, learn to write SQL.

Don't learn how to build React with Redux with Bootstrap with JQuery, learn HTML, CSS and JavaScript.

For 99% of what you need to do, they will be more than enough.

This knowledge will never get stale.

Unlike frameworks.


Update

I wrote a continuation and response to this post:

. . . . . . . . . . . . . . . . . . .
Terabox Video Player