2013-07-22

Co.Labs

Real-Time Web Basics: What You Need To Know

Web developers are gravitating toward real-time frameworks that run JavaScript on both the front and back-end. If you don’t know what the hell that means, this article is for you.



Earlier this year, I began work on a project requiring real-time communication with Node.js and Socket.IO. The existing solutions I was aware of try to tie as much as possible of the frond-end to the back-end using JavaScript. I prefer to keep these functions more clearly differentiated, and that by integrating only where necessary, it's easier for one person, or single small team, to maintain both.

The idea is to build a solution that lets you implement your specific use case, and then add features and expand for scale from this platform. All too often, teams feel the need to throw everything out and start over when the use case changes, as it inevitably will.

Why JavaScript Is Taking Over Web Development

JavaScript works on all devices and in all browsers, pretty much guaranteeing that your HTML page will always render. It can be used for everything, and new JavaScript tools and frameworks seem to be everywhere.

There are front-end development frameworks, such as Ember.js, AngularJS, and Backbone.js. Template engines, such as Jadejs. Back-end frameworks, such as the Web Application Framework, Express for Node, and real-time app framework, engine.io for transporting real-time information using different methods. Testing frameworks using JS libraries, such as Mocha or Should.js. Task automation using GRUNT The JavaScript Task Runner, and the list goes on and on and on. It seems that every other day there is a new project .js or .io out there.

Much of that is contributed by the open source community (through GitHub) and increases the popularity and health of JavaScript. And the NPM Registry for Node Packaged Modules is the official package manager for Node.js, making it easier for developers to share their projects and code together, not to mention bower, which helps distribute re-usable components.

Many MVC libraries and template engines have been created giving JavaScript an awareness of the design patterns we all know from Object-Oriented Programming (OOP). And as more web developers embrace HTML5, they're finding JavaScript frameworks to support many of the new, interactive media and real-time features.

Cutting-Edge Developers Are Building On Node.js

Node.js is a server-side engine (just like PHP, ASP, and .NET) designed for writing scalable Internet applications, specifically web servers. It could have been written using any programming language, but it ended up in JavaScript.

In 2009, Node.js creator, Ryan Lienhart Dahl, set out to build websites with push capabilities similar to what he saw in Google's Gmail application. Interestingly, he chose to work in JavaScript not for what it had, but for what it lacked--an I/O API. This left him room to define a "convention of non-blocking, event-driven I/O" that became Node.js.

Most JavaScript programs execute in a web browser, but Node.js executes on the server-side. This has the distinct advantage of allowing one developer, or a single small team, to work on both front-end and back-end at the same time!

Framework Agnosticism in a Fragmented Mobile World

Obviously, the web has been a fragmented place ever since the old browser wars, and each time we appear to be approaching greater unity, a new technology comes along and sends us all scurrying to pick up the new paradigm. Even so, there are standards maintained and much of the turmoil is the inevitable fallout of the rapidly changing mobile world.

It's easy to feel hesitant about committing to yet another new development paradigm, which has become one of the major reasons so many of us are returning to JavaScript or even discovering its capabilities for the first time. It may not seem fashionable, but it certainly is reliable, more so than ever.

This JavaScript resurgence has had the effect of encouraging more work on JavaScript, itself. We're seeing remarkable new tools that make it possible to do all of our work, front-end and back-end, in a single language, which is a new paradigm we've discovered almost by accident.

We'll discuss these tools and ways to use them to make web development easier, faster, and definitely more fun. Most importantly, we'll also show you how to design and build better, brighter, easier-to-maintain websites. Too good to be true? Stay tuned.

[Image: Flickr user Brad Perkins]