Get Professional

Do I have to learn a JavaScript framework?

15 Jun , 2017  

“Do I have to learn a JavaScript framework?”

That’s a super-common question, especially for anyone who’s just finished learning HTML, CSS and JavaScript.

Learning a JavaScript framework (or even just a library) can seem really daunting.

Especially because the first thing a lot of frameworks ask you to do is break the rules you’ve just learnt about making web pages.

Things that commonly cause confusion are:

  • Weird syntax – JavaScript turning up in unexpected places in HTML, or HTML appearing in the middle of JavaScript!
  • Difficult configuration – a lot of the hard work implementing even a tiny web application with a framework for the first time is understanding the configuration.
  • Project organization – using a framework will usually require you to organize your source code files in a very specific way. This can seem weird and arbitrary at first.

That sounds like no fun at all, right?

Well, JavaScript framework benefits do outweigh the initial hard work you’ll have to put in to learn one.

Let’s find out why.

Why Learn a JavaScript Framework?

What’s a JavaScript framework?

First, we’d better define what a JavaScript framework is, and remove a point of confusion.

The point of confusion here is the difference between a library and a framework.

The problem is that people often use these words interchangeably, or talk about common libraries and frameworks (e.g. React and Angular) as if they’re the same thing.

I’ve been guilty of this in the past, and I’m going to do it some more in this article so I can avoid typing framework and/or library over and over. Mea culpa.

So what’s the difference between a Framework and a Library?

JavaScript Framework

 

Here’s the rule: Frameworks call your code; your code calls a library.

That’s kind of glib, but it’s true. Here’s what it really means:

The word ‘framework’ has been so overused that it’s easy to forget what it means. But framework is short for application framework.

What this means is that an application framework provides the fundamental functionality required to implement an application. This includes handing navigation between pages, managing communication with a database or API, and handling events.

It’s your job then to build page content, describe data sources and so on. This information is used to fill out the framework into a complete application.

When you see a framework described as opinionated, it’s because the framework won’t work properly unless you organize your code to suit the framework’s way of doing things.

What about a library?

Like I said earlier, a library is something that your code calls. This means that your code needs to define the application, and then use the library to help with the heavy lifting.

The heavy lifting in this case may mean that an application uses one library for rendering a page, another library for managing the user’s movement between pages, and a third library for coordinating requests and responses for application data.

So remember – a framework defines the outline of an application and your code colors the inside. With a library, your code defines the fundamental structure of an application, and then uses the library (or libraries) to help fill in the insides.

And could you use a framework to build your application and use a library as well? Of course! 🙂

But all that sounds kind of complicated, right? Let’s see why we’d bother with frameworks and libraries.

What are the benefits of a JavaScript Framework?

How to Learn JavaScript - serious tools

Warning! This is where I’ll start using framework to mean either framework or library.

Adding a framework (or library!) obviously adds a lot of complexity. But what do we get out of it?

In short, it’s like getting some of the best programmers in the world to write parts of your application.

Why? Because these frameworks have been developed by very good programmers, and then refined further by even more great programmers.

And the frameworks provide a huge chunk of the functionality for your application. And they’re implementing the hardest, most error-prone parts for you.

This means you get to concentrate on implementing code that’s unique to your application, and leave the rest to your framework of choice.

The end result? You save a lot of time and have fewer bugs.

Do I have to use a JavaScript framework? Are there Downsides?

No, you don’t have to use a framework, and I think there are huge benefits to learning how to implement every part of an application in vanilla JavaScript.

But! Frameworks are ubiquitous. Everybody uses them because, overall, programmers can complete a project more quickly and with less complexity if they use a framework.

There are downsides, however.

The most obvious downside is that a framework takes some getting used to.

Your first framework will introduce a lot of new concepts and it’ll take a while before you’re able to use it confidently. And as a general rule, the more features a framework provides, the longer it’ll take to learn.

The second big downside is that a framework is a commitment. Once you’ve chosen a framework and implemented an application with it, you’re kind of married to it.

It’s a big job to move an application from framework to another.

Why does that matter?

First, if you ever need to any help with your application or website, you’ll need a programmer who knows the framework. If you’ve chosen an obscure framework that

The second big downside is that a framework is a commitment. Once you’ve chosen a framework and implemented an application with it, you’re kind of married to it.

It’s a big job to move an application from framework to another. Why does that matter?

First, if you ever need to any help with your application or website, you’ll need a programmer who knows the framework. If you’ve chosen an obscure framework that you really like but not many programmers know it’ll be tough to find programmers to work on it.

Another issue is that we’re all at the mercy of whoever is sponsoring and implementing the framework.

As a specific example, what if Facebook decided to stop development of React?

Would there be any further development of React? What about bug fixes? The foundation of every single React application in the work suddenly becomes very shaky.

(I don’t think that’s going to happen, by the way!)

Alternatively, the framework developers could take the framework in a completely new and unexpected direction.

This actually happened with the Angular framework, when version 2 introduced many changes incompatible with version 1. While the changes were 100% beneficial for the framework, it was a big headache for the owners of Angular 1 applications, who had to significantly re-structure their applications.

While these situations are rare, they do happen. You should keep them in mind when you’re considering adopting a new JavaScript framework.

Which JavaScript framework should I learn?

JavaScript Frameworks

Sadly, since I don’t know your particular situation, this isn’t a question I can answer for you. But what I will do is go over some of the popular frameworks and libraries, and discuss what they offer.

Bootstrap

Bootstrap is a framework originally developed by Twitter, and combines HTML, CSS and JavaScript to help you build web user interfaces.

Note – it won’t take care of anything other than your user interface – you’ll be left in charge of coordinating data requests and the like.

React

React is a library, but React application code has such a specific look and structure that it’s often mistaken for a framework!

Once again, React provides functionality for implementing a user interface, and that’s all. The great thing is that since React is turning up everywhere (mobile and desktop) you can get a lot of mileage out of your code.

React applications are often fleshed out with the Redux and React Router libraries to take care of data requests and navigation.

Vue

Vue is quite similar to React, in that it’s primarily used for implementing user interfaces.

I haven’t used it personally, but the Vue project claims it can be used as either a framework or as a drop-in library.

It has a reputation for being very easy to learn and I know a lot of people enjoy using it. It’s not as popular as the other frameworks discussed here, but it’s quickly gaining a lot of interest.

Angular

Angular is the batteries-included, ‘everything in the box’ MVC (Model-View-Controller) framework that tries to provide everything a programmer needs to implement an application. This means, of course, that there’s a lot to learn.

It’s well-supported and popular enough that it survived the giant changes between version 1 and version 2.

Backbone

Another MVC framework, Backbone provides a lot of functionality, and removes responsibility for managing data and user-interface updates from the application programmer.

While it’s widely used, it’s not as popular as Angular (the other main option for a fully-featured MVC framework), or React (or even Vue).

What you need to do about learning a JavaScript framework

Think hard about your goals. That’s the best place to start.

It’s undeniable that anyone with solid skills with either Angular or the React ecosystem is super-employable right now.

If employment is your main focus right now, then pick a project to learn with, pick a framework, and get learning.

But if you’d prefer to just build small projects for your own entertainment, you really don’t need to learn a framework to do it.

In fact, it’ll be great for your web programming skills if you learn to build apps without a framework.

So to return to the question that started this article – no, you don’t have to learn a framework; but you’ll be a more employable programmer if you do.

By


Leave a Reply

Your email address will not be published. Required fields are marked *