What is coffeescript?
CoffeeScript is a programming language that transcompiles to JavaScript. It provides a more concise syntax, additional features not present in JavaScript, and aims to enhance readability and brevity of code. It can be used for server-side scripting with Node.js or client-side scripting in web browsers.
What are coffeescript's main functionalities?
Simplified Syntax
CoffeeScript offers a more readable and expressive syntax compared to JavaScript. This code sample defines a function to square a number using an arrow function and without the need for curly braces or the 'function' keyword.
square = (x) -> x * x
Classes and Inheritance
CoffeeScript supports classes and inheritance, allowing for more structured and object-oriented code. This code sample defines an Animal class and a Dog class that inherits from it, with a constructor and a method.
class Animal
constructor: (@name) ->
class Dog extends Animal
bark: -> 'Woof! I am ' + @name
List Comprehensions
CoffeeScript provides list comprehensions, which are a concise way to apply operations to the elements of a collection. This code sample demonstrates creating a new array of cubes from an existing array of numbers.
cubes = (math.cube num for num in list)
Destructuring Assignment
Destructuring assignment syntax in CoffeeScript allows for unpacking values from arrays or properties from objects into distinct variables. This code sample shows how to extract the 'name' and 'value' properties from an object.
{name, value} = object
Other packages similar to coffeescript
typescript
TypeScript is a superset of JavaScript that adds static typing. It offers similar benefits to CoffeeScript in terms of providing additional language features, but it focuses on type safety and is more widely adopted in the industry.
babel
Babel is a JavaScript compiler that allows developers to use next-generation JavaScript features by transpiling code to a version compatible with current browsers. It's similar to CoffeeScript in that it processes code to enhance compatibility and offers modern syntax, but it sticks closer to standard JavaScript.
livescript
LiveScript is a language that compiles to JavaScript. It is similar to CoffeeScript in providing a more concise syntax and additional features, but it also includes functional programming constructs and is influenced by Haskell and Coco.
@@@@@@@ @@@@ @@@@@
@@@@@@@@@@ @@@ @@@ {
@@@@ @@ @@@ @@@ } } {
@@@@ @@@@@@@ @@@ @@@ @@@@@@ @@@@@@ { { } }
@@@@ @@@ @@ @@@@@ @@@@@@ @@@ @@ @@@@ @@ } }{ {
@@@@ @@@@ @@ @@@ @@@ @@@ @@@ @@@ @@@ { }{ } }
@@@@ @@@@ @@ @@@ @@@ @@@@@@@@ @@@@@@@@ { }{ }{ { }
@@@@@ @@@@ @@ @@@ @@@ @@@ @@@ { { } { } { } }
@@@@@@@@@@ @@@@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@@ { } { } { }
@@@@@ @@@ @@@ @@@@@ @@@@@ @@@@@@ { } { } @@@@@@@
@@@ @@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@ @@@ @@@ @@ @@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@ @@ @@@ @@@@ @@ @@@@@@@@@@@@@@@@@@@@@@@@
@@@@ @@@ @@ @@@@ @@@ @@@@@@@@@@@@@@@@@@@@@
@@@@@ @@@@@ @@ @@ @@@ @@@@@@@ @@@@@ @@@ @@@@@@@@@@@@@@@@@@
@@@@@ @@@ @@@ @@@@@@@@ @@@@ @@@@ @@@@@@@ @@@ @@@@@@@@@@@@@@@@
@@@@@ @@@ @@@@ @@@@ @@@ @@@ @@@ @@@@@@@@@@@@@@
@@@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@
@@@ @@@@ @@@ @@@@ @@@@ @@@ @@@@ @@@@
@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@
@@@@@@@@@ @@@@@@ @@@@ @@@@ @@@@@@@@@ @@@@
@@@ @@@@
@@@
@@@
CoffeeScript is a little language that compiles into JavaScript.
Installation
Once you have Node.js installed:
# Install locally for a project:
npm install --save-dev coffeescript
# Install globally to execute .coffee files anywhere:
npm install --global coffeescript
Getting Started
Execute a script:
coffee /path/to/script.coffee
Compile a script:
coffee -c /path/to/script.coffee
For documentation, usage, and examples, see: https://coffeescript.org/
To suggest a feature or report a bug: https://github.com/jashkenas/coffeescript/issues
If you’d like to chat, drop by #coffeescript on Freenode IRC.
The source repository: https://github.com/jashkenas/coffeescript.git
Changelog: https://coffeescript.org/#changelog
Our lovely and talented contributors are listed here: https://github.com/jashkenas/coffeescript/contributors