background preloader

Learn CoffeeScript

Facebook Twitter

A CoffeeScript Intervention. Sure, CoffeeScript is as easy as ABC.

A CoffeeScript Intervention

But Trevor’s prepared to take you all the way to Z. Like any sane programmer, I was initially wary of CoffeeScript. How could a little syntactic sugar sprinkled over JavaScript possibly justify the extra compilation step? But after playing with CoffeeScript for just a few days, I knew I’d never go back. The syntactic sugar was only the beginning. JavaScript newbies naïvely assume that var x means “I hereby declare a variable named x.” And there’s no var x declaration in a surrounding scope, then x is automatically a global.

Even seasoned pros sometimes make this mistake, especially when chaining variable declarations: var a = 1, b = 2 declares two variables in the current scope, while var a = 1; b = 2 assigns a value to the global b. With CoffeeScript, all variables are automatically scoped. You can rest assured that you aren’t messing with any globals. There may be no more common source of confusion in JavaScript than the this keyword. ETE 2012 - Trevor Burnham - The CoffeeScript Edge. 6.3Thinking Asynchronously for Coffee Script. Code School - CoffeeScript. CoffeeScript Cookbook » Home. OOP with CoffeeScript & JavaScript. Posted by thomasb in CoffeeScript , Javascript on Mar 5th, 2012 | 13 comments For developers trained classically in OOP [Java, C++, Delphi, and AS3], Javascript can be very challenging.

OOP with CoffeeScript & JavaScript

Expertise in Javascript requires developers to understand prototypal inheritance, closures, partial applications, currying, and more. Combine these learning requirements with an understanding of function constructors and… well, OOP developers can quickly become discouraged. Developers migrating to Javascript may even be tempted to discard all the best-practices learned during their OOP efforts.

This article is intended to demonstrate to developers that CoffeeScript and Javascript can both be used to implement object-oriented code with structures used in the `classic` languages. Class and Inheritance With Coffeescript it is really easy to create a Class with inheritance, constructors, and even use super() to invoke parent method overrides. Shown below are two (2) class definitions: Animal and Dog .

Packages. Category:CoffeeScript. CoffeeScript This programming language may be used to instruct a computer to perform a task.

Category:CoffeeScript

Listed below are all of the tasks on Rosetta Code which have been solved using CoffeeScript. CoffeeScript is a programming language that compiles to JavaScript. The language adds syntactic sugar inspired by Ruby and Python to enhance JavaScript's brevity and readability, as well as adding more sophisticated features like array comprehension and pattern matching. 10 CoffeeScript One Liners to Impress Your Friends. You may have read "10 Scala One Liners to Impress Your Friends" at Marcus Kazmierczak's blog recently featured on HN.

10 CoffeeScript One Liners to Impress Your Friends

Although I don't know Scala (or Java), it all looks quite nice, so I decided to impress my friends too - folks go from Java to Scala, we go from Javascript to CoffeeScript. Assume node.js as the environment for all examples. 1. Multiply each item in a list by 2 Marcus starts by showing off the map function. But we can also write the more expressive form 2. Javascript (and CoffeeScript by extension) also has native map and reduce functions: [1..1000].reduce (t, s) -> t + s (reduce == reduceLeft, reduceRight is also available) 3. Too easy since we have the some method. WordList = ["coffeescript", "eko", "play framework", "and stuff", "falsy"]tweet = "This is an example tweet talking about javascript and stuff. " wordList.some (word) -> ~tweet.indexOf word This will return the matched words instead:

CoffeeScript. The Little Book on CoffeeScript. CoffeeScript: JavaScript without the Fail.