From the mobile browser to the cloud: The expanding role of JavaScript

While originally a language confined just to the web browser, JavaScript has become a requirement for server-side developers as well, as its use in cloud based and mobile applications has become more prevalent and important than ever.

It's not news to find out that JavaScript has become the new crowd favorite for front-end development, but what is surprising is how quickly it is also catching on in the back end, powering many of the most intense cloud based and data center hosted applications. While it has plenty of quirks that make it a challenge for use at the enterprise level, JavaScript is obviously here to stay. This means back-end developers need to know how to work with the scripting language itself—and how to work with JavaScript front-end programmers to build business applications that really deliver. Here are a few areas of interest for server side developers.

Understanding the kind of back-end that supports a JavaScript front-end

Server side developers who want to remain relevant in the world of front-end JavaScript need to understand the needs of the new client side-centric development approach. In some ways, things will get easier. But enterprises will need to clean up their act with APIs. Freelance JavaScript consultant Mark Bates described his frustration with enterprise developers who don't build with the front-end in mind.

"I've dealt with many APIs that are not a pleasure to work with because they aren't RESTful. They've got strange URLs associated with them, there's no rhyme or reason to them, and the objects aren't formatted in a particular pattern. Pick a design pattern and a URL pattern that works for your company and stick with it. Don't give me a hodge-podge of different things." Such irregularity is a problem that crops up often in larger, older organizations that are maintaining a substantial amount of legacy code. Consistency is difficult to create after the fact, but it should be one focus of modernization efforts for older APIs.

Pick a design pattern and a URL pattern that works for your company and stick with it. Don't give me a hodge-podge of different things.

Mark Bates, Freelance Developer

Brian Holt, director of front-end development for Reddit, agreed that a sane API is mostly RESTful. However, that's just one way of going about achieving the real goal. "You don't even have to use the HTTP verbs, necessarily. You just need to have end points, and then you direct your client-side apps to consume these APIs that you create." JavaScript Object Notation (JSON) is the communication method of choice. This means server side developers who focus on APIs that pass information back and forth using JSON will make things easier on their peers in the JavaScript development field.

Getting comfortable with more JavaScript on the back-end

Speaking of JSON, JavaScript certainly isn't just for the front-end these days. Server side developers who are familiar with JavaScript, jQuery and Ajax are delving deeply into the use of event-based server execution procedures using node.js. In some cases, this approach can capture functional gains comparable to multi-threaded execution in traditional PHP. Node.js is becoming especially popular for use with non-relational databases such as MongoDB. There's a simple reason: Mongo is a JSON object store and its functions are JavaScript functions.

JavaScript solutions also mesh well with the rise of mobile and the cloud. There's less overhead with JavaScript, and the code is simpler to write. Plus, server side scripting is readily scalable to many concurrent connections since it doesn't wait for I/O operations. This makes it particularly useful for data-intensive real-time applications that need low-latency without gobbling up too many computing resources.

Designing and programming with simplicity in mind

Server side developers making the transition to writing front-end JavaScript or working closely with front-end teams should be on the lookout for bad habits that die hard. Brian mentioned the problems developers can inadvertently create when they shy away from getting to know the new JavaScript frameworks. "It's a different paradigm. Back-end developers and more service oriented developers are going to have more of a jQuery mentality where they are doing just enough to hook into the DOM and do some minor updates. These apps need to have better structure with separation of concerns or your code is going to get really messy very quickly."

When developers begin using frameworks, the code base will balloon rapidly. It's easy for legacy errors to creep in, and these are hard to fix. Developers from a server side background must learn to appreciate how JavaScript frameworks help them stay organized and write cleaner code. New frameworks like Angular make things much easier by abstracting the programming process away from the DOM. In short, JavaScript is finally becoming a language that server side developers can feel good about using.

How has JavaScript changed the way you develop back-end applications? Let us know.

Dig Deeper on Front-end, back-end and middle-tier frameworks