CoffeeScript Application Development

Book description

What JavaScript user wouldn’t want to be able to dramatically reduce application development time? This book will teach you the clean, elegant CoffeeScript language and show you how to build stunning applications.

  • Learn the ins and outs of the CoffeeScript language, and understand how the transformation happens behind the scenes
  • Use practical examples to put your new skills to work towards building a functional web application, written entirely in CoffeeScript
  • Understand the language concepts from short, easy-to-understand examples which can be practised by applying them to your ongoing project

In Detail

JavaScript is becoming one of the key languages in web development. It is now more important than ever across a growing list of platforms. CoffeeScript puts the fun back into JavaScript programming with elegant syntax and powerful features.

CoffeeScript Application Development will give you an in-depth look at the CoffeeScript language, all while building a working web application. Along the way, you'll see all the great features CoffeeScript has to offer, and learn how to use them to deal with real problems like sprawling codebases, incomplete data, and asynchronous web requests.

Through the course of this book you will learn the CoffeeScript syntax and see it demonstrated with simple examples. As you go, you'll put your new skills into practice by building a web application, piece by piece. You'll start with standard language features such as loops, functions, and string manipulation. Then, we’ll delve into advanced features like classes and inheritance. Learn advanced idioms to deal with common occurrences like external web requests, and hone your technique for development tasks like debugging and refactoring.

CoffeeScript Application Development will teach you not only how to write CoffeeScript, but also how to build solid applications that run smoothly and are a pleasure to maintain.

Table of contents

  1. CoffeeScript Application Development
    1. Table of Contents
    2. CoffeeScript Application Development
    3. Credits
    4. About the Author
    5. Acknowledgements
    6. About the Reviewers
    7. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
      2. Free Access for Packt account holders
    8. Preface
      1. What is CoffeeScript?
      2. Why CoffeeScript?
      3. What this book covers
      4. What you need for this book
      5. Who this book is for
      6. Conventions
      7. Reader feedback
      8. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    9. 1. Running a CoffeeScript Program
      1. Installing Node.js
        1. Installing Node.js on OS X
          1. Using the installer
          2. Using Homebrew
          3. Using Macports
        2. Installing Node.js on Windows
      2. Using the installer
        1. Using the standalone executable
        2. Using Chocolatey
        3. Installing Node.js on Linux
          1. Using a graphical package manager
          2. Using the command line
            1. Linux Mint/Ubuntu 12.04 (Precise Pangolin)
            2. Debian Sid/Ubuntu 12.10 (Quantal Quetzal)
            3. Arch Linux
            4. Fedora
        4. Compiling Node.js manually
        5. Skipping the Node installation step
      3. Testing our Node installation
        1. Testing npm
      4. Installing CoffeeScript
      5. Our very first CoffeeScript code
      6. Compiling from a CoffeeScript file
      7. CoffeeScript support in the editor
        1. Support in TextMate
        2. Support in Sublime Text 2
        3. Support in Vim
        4. Support in Emacs
      8. Starting our web application
        1. One more thing
      9. Summary
    10. 2. Writing Your First Lines of CoffeeScript
      1. Following along with the examples
        1. Seeing the compiled JavaScript
      2. CoffeeScript basics
        1. Statements
        2. Variables
        3. Comments
      3. Calling functions
        1. Precedence
      4. Control structures
        1. Using if statements
        2. The else and else if statements
        3. The unless statement
        4. Single-line form
      5. Comparison operators
      6. Arrays
        1. Ranges
        2. Loops
          1. Loop comprehensions
          2. A few more array tricks
        3. Checking array membership
      7. Simple objects
        1. Iterating over objects
      8. Summary
    11. 3. Building a Simple Application
      1. Building our application
      2. String Interpolation
        1. Using string interpolation in our application
      3. Defining functions
        1. Function naming
        2. Function return behavior
      4. Adding dynamic behavior to our application
      5. Switch statements
        1. Using a switch statement in our application
      6. Summary
    12. 4. Improving Our Application
      1. Checking if a value exists
        1. Using the existential operator
        2. Null values in chained calls
        3. Assigning new values conditionally when null
        4. Dealing with nulls in our application
      2. Assigning multiple values at once
        1. Using destructuring assignment in our application
      3. Advanced function arguments
        1. Default argument values
          1. Using default arguments in our application
        2. Accepting a variable number of arguments with splats
          1. Invoking functions with splats
          2. Using splats in our application
      4. Summary
    13. 5. Classes in CoffeeScript
      1. Defining a class in CoffeeScript
        1. Attaching methods to a class
        2. How CoffeeScript builds classes in JavaScript
        3. Maintaining state with object properties
        4. Calling other methods on this object
        5. Attaching a method outside of the class definition
      2. Constructors
        1. CoffeeScript constructors in JavaScript
      3. Calling methods statically on classes
      4. Inheritance
        1. CoffeeScript's inheritance in JavaScript
      5. Using CoffeeScript with other class libraries
        1. Backbone classes in CoffeeScript
        2. Ember classes in CoffeeScript
      6. Summary
    14. 6. Refactoring with Classes
      1. The refactoring cycle
      2. Structuring our data with classes
        1. Adding business logic
        2. More data modeling
        3. More business logic
      3. Managing display logic with classes
        1. Displaying a collection
        2. The top-level display logic
      4. A final refactoring pass
      5. Using inheritance while refactoring
      6. Getting the green light
      7. Summary
    15. 7. Advanced CoffeeScript Usage
      1. Getting our context right
        1. Using fat arrows in our project
      2. Saving our work with memoization
        1. Using memoization in our application
      3. A new idiom: options objects
        1. Using options objects in our application
      4. Summary
    16. 8. Going Asynchronous
      1. Understanding asynchronous operations
      2. Getting to know our remote API
      3. Making an asynchronous request
      4. Using a third-party library
        1. Refactoring
      5. Wrangling multiple asynchronous calls
        1. Requests in a loop
        2. Determining when we're finished
      6. Alternatives for managing asynchronous calls
        1. Promises
          1. Using Promises in our application
        2. An async helper library
          1. Using Async.js in our application
        3. IcedCoffeeScript
          1. Using IcedCoffeeScript in our application
      7. Summary
    17. 9. Debugging
      1. Discovering a problem
      2. Working with source maps
        1. Source maps in the Firefox developer tools
          1. Inspecting our application state
          2. Using the debugger
        2. Source maps in the Chrome developer tools
          1. Inspecting our application state
          2. Using the debugger
      3. Fixing the problem
      4. Summary
    18. 10. Using CoffeeScript in More Places
      1. CoffeeScript directly in the browser
      2. CoffeeScript in the browser console
        1. A CoffeeScript console in Firefox
        2. A CoffeeScript console in Chrome
      3. Using CoffeeScript with Rails
        1. Setting up the asset pipeline
          1. Creating a new Rails application
          2. Rails 3.0
          3. Rails 3.1 and 3.2
          4. Rails 4
        2. Setting up our application
        3. Adding some CoffeeScript
        4. Precompiling assets
      4. Using CoffeeScript with Brunch
        1. Creating a Brunch project
        2. Filling out our application
        3. Precompiling assets
      5. Using CoffeeScript with Node.js
        1. Creating our project
        2. Keeping the server up-to-date
        3. Adding CoffeeScript compilation
        4. Finishing our application
        5. Cleaning up our script dependencies
      6. Summary
    19. 11. CoffeeScript on the Server
      1. Running a server with CoffeeScript
        1. Running our application
      2. Adding an endpoint for data
      3. Using a database
        1. Handling errors
      4. Using a Cakefile
        1. Writing a Cake task
        2. More Cake tasks
      5. Making our application interactive
        1. Seeing the results
      6. Summary
    20. Index

Product information

  • Title: CoffeeScript Application Development
  • Author(s): Ian Young
  • Release date: August 2013
  • Publisher(s): Packt Publishing
  • ISBN: 9781782162667