• Complain

Alex MacCaw - The Little Book on CoffeeScript

Here you can read online Alex MacCaw - The Little Book on CoffeeScript full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2012, publisher: OReilly Media, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Alex MacCaw The Little Book on CoffeeScript
  • Book:
    The Little Book on CoffeeScript
  • Author:
  • Publisher:
    OReilly Media
  • Genre:
  • Year:
    2012
  • Rating:
    3 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 60
    • 1
    • 2
    • 3
    • 4
    • 5

The Little Book on CoffeeScript: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "The Little Book on CoffeeScript" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

This little book shows JavaScript developers how to build superb web applications with CoffeeScript, the remarkable little language thats gaining considerable interest. Through example code, this guide demonstrates how CoffeeScript abstracts JavaScript, providing syntactical sugar and preventing many common errors. Youll learn CoffeeScripts syntax and idioms step by step, from basic variables and functions to complex comprehensions and classes. Written by Alex MacCaw, author of JavaScript Web Applications (OReilly), with contributions from CoffeeScript creator Jeremy Ashkenas, this book quickly teaches you best practices for using this languagenot just on the client side, but for server-side applications as well. Its time to take a ride with the little language that could.Discover how CoffeeScripts syntax differs from JavaScript Learn about features such as array comprehensions, destructuring assignments, and classes Explore CoffeeScript idioms and compare them to their JavaScript counterparts Compile CoffeeScript files in static sites with the Cake build system Use CommonJS modules to structure and deploy CoffeeScript client-side applications Examine JavaScripts bad partsincluding features CoffeeScript was able to fix

Alex MacCaw: author's other books


Who wrote The Little Book on CoffeeScript? Find out the surname, the name of the author of the book and a list of all author's works by series.

The Little Book on CoffeeScript — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "The Little Book on CoffeeScript" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
The Little Book on CoffeeScript
Alex MacCaw
Editor
Mary Treseler

Copyright 2012 Alex MacCaw

OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (.

Nutshell Handbook, the Nutshell Handbook logo, and the OReilly logo are registered trademarks of OReilly Media, Inc. The Little Book on CoffeeScript and related trade dress are trademarks of OReilly Media, Inc.

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and OReilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps.

While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.

OReilly Media Preface What Is CoffeeScript CoffeeScript is a little - photo 1

O'Reilly Media

Preface
What Is CoffeeScript?

CoffeeScript is a little language that compiles down to JavaScript. The syntax is inspired by Ruby and Python, and implements many features from those two languages. This book is designed to help you learn CoffeeScript, understand best practices, and start building awesome client-side applications. The book is little, only six chapters, but thats rather apt as CoffeeScript is a little language too.

This book is completely open source, and was written by Alex MacCaw (@maccman) with great contributions from David Griffiths, Satoshi Murakami, Chris Smith, Katsuya Noguchi, and Jeremy Ashkenas.

If you have any errata or suggestions, please dont hesitate to open a ticket on the books GitHub page. Readers may also be interested in JavaScript Web Applications (OReilly), a book I authored that explores rich JavaScript applications and moving state to the client side.

So lets dive right into it: why is CoffeeScript better than writing pure JavaScript? Well, for a start, theres less code to write; CoffeeScript is very succinct, and takes white space into account. In my experience, this reduces code by a third to a half of the original pure JavaScript. In addition, CoffeeScript has some neat features, such as array comprehensions, prototype aliases, and classes that further reduce the amount of typing you need to do.

More importantly though, JavaScript has a lot of skeletons in its closet which can often trip up inexperienced developers. CoffeeScript neatly sidesteps these by only exposing a curated selection of JavaScript features, fixing many of the languages oddities.

CoffeeScript is not a superset of JavaScript, so although you can use external JavaScript libraries from inside CoffeeScript, youll get syntax errors if you compile JavaScript as is, without converting it. The compiler converts CoffeeScript code into its counterpart JavaScript, theres no interpretation at runtime.

So lets get some common fallacies out of the way. You will need to know JavaScript in order to write CoffeeScript, as runtime errors require JavaScript knowledge. However, having said that, runtime errors are usually pretty obvious, and so far I havent found mapping JavaScript back to CoffeeScript to be an issue. The second problem Ive often heard associated with CoffeeScript is speed (i.e., the code produced by the CoffeeScript compiler would run slower than its equivalent written in pure JavaScript). In practice though, it turns out this isnt a problem either. CoffeeScript tends to run as fast or faster than handwritten JavaScript.

What are the disadvantages of using CoffeeScript? Well, it introduces another compile step between you and your JavaScript. CoffeeScript tries to mitigate the issue as best it can by producing clean and readable JavaScript, and with its server integrations which automate compilation. The other disadvantage, as with any new language, is the fact that the community is still small at this point, and youll have a hard time finding fellow collaborators who already know the language. CoffeeScript is quickly gaining momentum though, and its IRC list is well staffed; any questions you have are usually answered promptly.

CoffeeScript is not limited to the browser, and can be used to great effect in server-side JavaScript implementations, such as Node.js. Additionally, CoffeeScript is getting much wider use and integration, such as being a default in Rails 3.1. Now is definitely the time to jump on the CoffeeScript train. The time you invest in learning about the language now will be repaid by major time savings later.

Initial Setup

One of the easiest ways to initially play around with the library is to use it right inside the browser. Navigate to http://coffeescript.org and click on the Try CoffeeScript tab. The site uses a browser version of the CoffeeScript compiler, converting any CoffeeScript typed inside the left panel to JavaScript in the right panel.

You can also convert JavaScript back to CoffeeScript using the js2coffee project, especially useful when migrating JavaScript projects to CoffeeScript.

In fact, you can use the browser-based CoffeeScript compiler yourself, by including this script in a page, marking up any CoffeeScript script tags with the correct type:

# Some CoffeeScript

Obviously, in production, you dont want to be interpreting CoffeeScript at runtime, as itll slow things up for your clients. Instead, CoffeeScript offers a Node.js compiler to pre-process CoffeeScript files.

To install it, first make sure you have a working copy of the latest stable version of Node.js and npm (the Node Package Manager). You can then install CoffeeScript with npm:

npm install -g coffee-script

The -g flag is important, as it tells npm to install the coffee-script package globally, rather than locally. Without it, you wont get the coffee executable.

If you execute the coffee executable without any command line options, itll give you the CoffeeScript console, which you can use to quickly execute CoffeeScript statements. To pre-process files, pass the --compile option:

coffee --compile my-script.coffee

If --output is not specified, CoffeeScript will write to a JavaScript file with the same name, in this case my-script.js. This will overwrite any existing files, so be careful youre not overwriting any JavaScript files unintentionally. For a full list of the command line options available, pass --help.

You can also pass the --compile option a directory, and CoffeeScript will recursively compile every file with a .coffee extension:

coffee --output lib --compile src

If all this compilation seems like a bit of an inconvenience and bother, thats because it is. Well be getting onto ways to solve this by automatically compiling CoffeeScript files, but first lets take a look at the languages syntax.

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic

Indicates new terms, URLs, email addresses, filenames, and file extensions.

Constant width

Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.

Constant width bold

Shows commands or other text that should be typed literally by the user.

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «The Little Book on CoffeeScript»

Look at similar books to The Little Book on CoffeeScript. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «The Little Book on CoffeeScript»

Discussion, reviews of the book The Little Book on CoffeeScript and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.