Book Image

CoffeeScript Application Development Cookbook

By : Mike Hatfield
Book Image

CoffeeScript Application Development Cookbook

By: Mike Hatfield

Overview of this book

Table of Contents (18 chapters)
CoffeeScript Application Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

In my nearly 20 years of developing custom software solutions, nothing has had as great an impact on our industry or society as the Internet. Today, it would be difficult to imagine a world without HTML, CSS, and JavaScript. When I developed my first web-based application using JavaScript with Netscape Navigator in the mid 1990s, little did I know that we were in the early days of a software revolution.

Skip ahead nearly two decades and JavaScript has become one of the most widely supported programming languages in the world. Unfortunately, little has changed with JavaScript in this time and it is plagued with gotchas that can make developing a pure JavaScript system challenging. Enter CoffeeScript.

CoffeeScript provides us with a better approach to develop our applications that not only helps us to avoid these pitfalls, but also allows us to be more productive while still being able to take advantage of the large JavaScript ecosystem.

This book is a practical guide, filled with many step-by-step examples of using CoffeeScript for all aspects of building our software.

We will begin by looking at the fundamentals and getting our tools ready to be productive CoffeeScript developers. Next, we will use CoffeeScript to create our application layers, including the user interface, database, and backend services layer. After that, we will investigate various options to test and host our applications. Finally, we will look at ways CoffeeScript can be used by the DevOps to help automate their day-to-day tasks.

What this book covers

Chapter 1, Getting Ready, introduces CoffeeScript and lays the foundation to use CoffeeScript to develop all aspects of modern cloud-based applications.

Chapter 2, Starting with the Basics, covers using CoffeeScript with strings, numbers, dates, arrays, and classes.

Chapter 3, Creating Client Applications, demonstrates using CoffeeScript with various UI libraries and frameworks, including jQuery, Backbone, Angular, and Socket.IO.

Chapter 4, Using Kendo UI for Desktop and Mobile Applications, demonstrates how to use CoffeeScript with Telerik's open source Kendo UI Core framework to create both desktop and mobile applications.

Chapter 5, Going Native with Cordova, demonstrates how to use Apache Cordova with CoffeeScript to create native applications that can access native device features such as camera, geolocation, and contacts and be deployed to physical hardware.

Chapter 6, Working with Databases, covers various database technologies, including SQLite, Redis, MongoDB, and CouchDB, and how CoffeeScript can be used with each technology to perform create, read, update, and delete operations.

Chapter 7, Building Application Services, dives into the aspects of building the backend services needed by our application with a look at building RESTful services, working with Base64 encoding, and using domain name services to do DNS and reverse DNS lookups.

Chapter 8, Using External Services, examines ways to use existing services to send text messages and e-mails, use the Amazon cloud storage, and transfer files via FTP.

Chapter 9, Testing Our Applications, is dedicated to using CoffeeScript to test our applications using test frameworks such as Jasmine, Mocha, and Zombie as well as creating mocks using Persona.

Chapter 10, Hosting Our Web Applications, explains how to prepare your application for deployment using Grunt, and how to deploy to popular cloud hosting solutions such as Heroku and Windows Azure.

Chapter 11, Scripting for DevOps, examines ways that CoffeeScript can be used to help with day-to-day operation tasks such as working with files and directories, CSV and fixed-width data files, generating PDF files, and formatting data for output.

What you need for this book

To use the code in this book, you will need a code editor of your choice, a web browser, and an Internet connection to download Node packages and other libraries or frameworks.

Who this book is for

If you enjoy developing applications that can be run on desktop, tablet, and mobile devices without needing to learn platform-specific languages, this is the book for you.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "In this example we will demonstrate the use of spawn() to execute a CoffeeScript statement."

A block of code is set as follows:

var multiply = function(a, b) {
  return a * b;
};

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

if value % 2 is 0 then console.log 'Value is even'

Any command-line input or output is written as follows:

coffee -c -m counting.coffee

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on the Tools menu and select the Extensions and Updates menu option."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.