CoffeeScript

CoffeeScript
CoffeeScript
CoffeeScript-logo.png
Paradigm(s) Multi-paradigm: prototype-based, functional, imperative, scripting
Appeared in 2009
Designed by Jeremy Ashkenas
Developer Jeremy Ashkenas, et al.
Stable release 1.1.3 (November 8, 2011; 12 days ago (2011-11-08))
Influenced by JavaScript, Python, Ruby, Haskell, YAML
Influenced MoonScript
OS Cross-platform
License MIT License
Usual filename extensions .coffee
Website coffeescript.org

CoffeeScript is a programming language that transcompiles to JavaScript. The language adds syntactic sugar inspired by Ruby, Python and Haskell[1] to enhance JavaScript's brevity and readability, as well as adding more sophisticated features like array comprehension and pattern matching. CoffeeScript compiles predictably to JavaScript and programs can be written with less code (typically 1/3 fewer lines) with no effect on runtime performance.[2] Since March 16, 2011, CoffeeScript has been on GitHub's list of most-watched projects.[3]

The language has a relatively large following in the Ruby community, and has been used in production by 37signals.[4] CoffeeScript support is included in Ruby on Rails version 3.1.[5] Additionally, Brendan Eich has referenced CoffeeScript as an influence on his thoughts about the future of JavaScript.[6][7]

Contents

History

On December 13, 2009, Jeremy Ashkenas made the first Git commit of CoffeeScript with the comment: "initial commit of the mystery language."[8] CoffeeScript was created after reading the "Create Your Own Programming Language" ebook.[9] The compiler was written in Ruby. On December 24, he made the first tagged and documented release, 0.1.0. On February 21, 2010, he committed version 0.5, which replaced the Ruby compiler with one written in pure CoffeeScript. By that time the project had attracted several other contributors on GitHub, and was receiving over 300 page hits per day.

On December 24, 2010, Ashkenas announced the release of stable 1.0.0 to Hacker News, the site where the project was announced for the first time.[10][11]

Examples

A common JavaScript snippet using the jQuery library is

$(document).ready(function() {
  // Initialization code goes here
});

Or even just

$(function() {
  // Initialization code goes here
});

In CoffeeScript, the function keyword is replaced by the -> symbol, and indentation is used instead of curly braces, as in Python and Haskell. Also, parentheses can usually be omitted. Thus, the CoffeeScript equivalent of the snippet above is

$(document).ready ->
  # Initialization code goes here

Or just

$ ->
  # Initialization code goes here

Compiling

The CoffeeScript compiler has been written in CoffeeScript since version 0.5 and is available as a Node.js utility; however, the core compiler does not rely on Node.js and can be run in any JavaScript environment[12]. One alternative to the Node.js utility is the Coffee Maven Plugin, a plugin for the popular Apache Maven build system. The plugin works by utilizing Mozilla Rhino, a JavaScript engine written in Java. The official site at CoffeeScript.org has a "Try CoffeeScript" button in the menu bar; clicking it opens a modal window in which you can enter CoffeeScript, see the JavaScript output, and run it directly in the browser.

References

  1. ^ The Changelog. Episode 0.2.9 - CoffeeScript with Jeremy Ashkenas, Jul 23, 2010
  2. ^ Read Write Hack. Interview with Jeremy Ashkenas, Jan 7, 2011
  3. ^ Github. Popular Watched Repositories
  4. ^ Carson, Ryan. "New Rails-like Framework from 37signals for HTML5 Mobile Apps", Think Vitamin blog, Nov 8, 2010
  5. ^ Peek, Joshua. Tweet by Rails Core Team Member on Apr 13, 2011
  6. ^ Eich, Brendan. "Harmony of My Dreams"
  7. ^ Eich, Brendan. "My JSConf.US Presentation"
  8. ^ Github. 'initial commit of the mystery language'
  9. ^ "Create Your Own Programming Language". createyourproglang.com. http://createyourproglang.com/. 
  10. ^ Hacker News. CoffeeScript 1.0.0 announcement posted by Jeremy Ashkenas on Dec 24, 2010
  11. ^ Hacker News. Original CoffeeScript announcement posted by Jeremy Ashkenas on Dec 24, 2009
  12. ^ http://jashkenas.github.com/coffee-script/#installation

Geoffrey Grosenbach; Jeremy Ashkenas, Michael Ficarra (May 12). "Meet CoffeeScript". PeepCode. https://peepcode.com/products/coffeescript. 

Further reading

External links

Tutorials

Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • CoffeeScript — Класс языка: объектно ориентированный, императивный, функциональный, аспектно ориентированный, прототипный Появился в: 2009 Автор(ы): Jeremy Ashkenas Расширение файлов: .coffee …   Википедия

  • CoffeeScript — ist eine Programmiersprache, deren Programme in JavaScript transcompiliert werden. Sie wird seit 2009 von Jeremy Ashkenas entwickelt. Inhaltsverzeichnis 1 Herkunft und Verwendung 2 Compilierung 3 Literatur …   Deutsch Wikipedia

  • Фасад (шаблон проектирования) — У этого термина существуют и другие значения, см. Фасад (значения). Шаблон проектирования Фасад Facade Тип: структурный Описан в Design Patterns Да Шаблон Facade (Фасад)  Шаблон проектирования, позволяющий ск …   Википедия

  • Состояние (шаблон проектирования) — Шаблон проектирования Состояние State Тип: поведенческий Описан в Design Patterns Да Состояние (англ. State)  шаблон проектирования. Используется в тех случаях, когда во время выполнения программы объект …   Википедия

  • Мост (шаблон проектирования) — У этого термина существуют и другие значения, см. Мост (значения). Шаблон проектирования Мост Bridge Тип: структурный Описан в Design Patterns Да Bridge, Мост шаблон проектирования, используемый в …   Википедия

  • Компоновщик (шаблон проектирования) — Шаблон проектирования Компоновщик Composite Тип: структурный Описан в Design Patterns Да Компоновщик (англ. Composite pattern) шаблон проектирования, относится к структурным паттернам, объединяет объек …   Википедия

  • Одиночка (шаблон проектирования) — У этого термина существуют и другие значения, см. Одиночка. Шаблон проектирования Одиночка Singleton Тип: порождающий Описан в Design Patterns Да Одиночка (англ. Singleton) в программировании  …   Википедия

  • JavaScript — Не следует путать с Java. JavaScript Класс языка: мультипарадигменный …   Википедия

  • Декоратор (шаблон проектирования) — У этого термина существуют и другие значения, см. Декоратор. Шаблон проектирования Декоратор Decorator …   Википедия

  • Хронология языков программирования — Списки языков программирования По категориям Хронологический Генеалогический Хронология языков программирования  упорядоченный в хронологическом порядке список языков программирования. Содержание …   Википедия

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”