O'Reilly logo

Smashing CoffeeScript by Alex Hudson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 14

Server-Side CoffeeScript

The CoffeeScript you’ve seen so far in this book is best described as client-side, CoffeeScript is designed as a solution to the various problems that web developers face, which usually means code working within the environment of the web browser. Although many of the facilities and features of CoffeeScript are designed to solve client-side problems, it’s not the whole story.

JavaScript has exploded as a server-side scripting language over the past few years, and the reason for this is a project called Node.js, or simply node. Taking a different approach to the technical architecture of a web server, node asks the JavaScript developer to write highly event-driven and function-oriented code.

It turns out that the event-driven style of coding required by node suits CoffeeScript down to the ground: all of the features that make CoffeeScript compelling in the client-side environment transfer directly to the server-side environment, and development of node-based servers is even more straightforward.

Putting Coffee in the server

Before delving too far into the details, I want to take a few moments to recap some of the long and glorious history of JavaScript, starting with the early days of Netscape . From the beginning, JavaScript was intended to be a server-side language and a client-side one, and one of the earliest versions of Netscape Enterprise Server included support for it. By 1996, Microsoft also had included support for the language in its ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required