Using Frameworks to Simplify JavaScript

shutterstock_367822664

Have you ever gone to a restaurant and had trouble selecting a dish because there were too many to choose from? The word for this is “overchoice,” and it’s how I feel about the various JavaScript libraries.

When I started learning JavaScript (back at the turn of the century), things were a lot simpler, apart from JavaScript behaving differently in the various Netscape browser versions. There was just one problem: aside from fancy cursor effects and validating HTML forms, JavaScript wasn’t much use for most developers. But that all changed with Ajax, Google Maps, Gmail, asm.js and node.io, and other platforms that demonstrated how the JavaScript could, yes, actually prove effective.

When I revisited JavaScript recently, I was overwhelmed by the available choices. Take a look at jster, the JavaScript catalogue: there are 67 options available for Application Frameworks alone, for instance. The plethora of options seems a bit excessive—how many ways can someone possibly write software?

Sure, many of these frameworks are amazing. Nobody could argue that jQuery has been anything other than immensely successful. Or take AngularJS, which improves on jQuery by adding an integration test runner, Restful API, MVC Pattern support and more. Or Angular, which came from Google (a company that knows a thing or two about JavaScript).

But not all frameworks are the same. While many originated inside big companies, others, such as Ember, are the work of just a few developers. Others are small, single-purpose frameworks that aren’t really all that powerful.

If you’re developing in JavaScript and looking for a way to cut through the options clutter, it’s the big frameworks that should interest you: These would typically include Angular, Backbone, React and Ember, as well as some others. Angular, for instance, has a stable version 1 but is bringing out a newer version 2. Before we plunge into the world of full-stack frameworks, though, let’s talk about the server side of things.

Server-Side Frameworks

Node.js originally introduced the concept of server-side JavaScript, which at the time seemed distinctly odd but has proved an effective tool for many developers. Instead of PHP, C++, Java or Python—i.e., the usual server-side languages—you use JavaScript in conjunction with a framework.

There are now several other server-side frameworks such as hapi.js, sails.js, express.js and others. Note that it seems to be a convention to label a framework as .js such as node.js even though the website is nodejs.org.

Full Stack Web Frameworks

Full Stack means the framework provides both client and server frameworks. Perhaps you’ve heard of the Mean Stack? It’s short for MongoDB, Express, Angular, and Node.js. (Just to confuse things further, there are now two Mean stacks, with Meanjs.org, known as mean.js, forked from mean.io by the lead JavaScript developer.)

Another full-stack web framework is Meteor, which can use Angular or React but also has its own Blaze library. The client and the server communicate data updates seamlessly and automatically, without you having to write any boilerplate data sync code, something that isn’t done in Mean.

Over 32,000 Github stars suggests that Meteor definitely has something going for it. It’s well-documented and apparently easier to learn than just Angular itself. For a pretty good overview, read Dan Dascalescu (a Google Engineer) comparing Meteor vs. Mean.

Conclusion

I don’t want to have to learn all the nuances and subtleties of the various web frameworks. If I find myself wanting to create a new website with modern features—one that’s responsive and secure—I might turn to something like Meteor (although some people have reservations about it, especially its speed and size.)

Another thing to consider when choosing a framework is whether it takes advantage of the new ECMAScript 6 standard, the latest standard version of JavaScript. Although browser support isn’t quite there yet, this standard adds significant new syntax for complex applications; if you want to work in JavaScript, you must know its capabilities.

Whatever your choices, don’t let JavaScript leave you feeling overwhelmed—there are good options out there for building new products.

Image Credit: Thongchai Kitiyanantawong/Shutterstock.com

Post a Comment

Your email address will not be published.