Introduction to CoffeeScript

CoffeeScript is a programming language that compiles to JavaScript. It adds syntactic sugar inspired by Ruby, Python and Haskell in an effort to enhance JavaScript’s brevity and readability. Specific additional features include list comprehension and destructuring assignment.

JavaScript often abbreviated as JS, is a programming language that conforms to the ECMAScript specification. JavaScript is high-level, often just-in-time compiled, and multi-paradigm. It has curly-bracket syntax, dynamic typing, prototype-based object-orientation, and first-class functions.

Alongside HTML and CSS, JavaScript is one of the core technologies of the World Wide Web. Over 97% of websites use it client-side for web page behavior, often incorporating third-party libraries. Most web browsers have a dedicated JavaScript engine to execute the code on the user’s device.

As a multi-paradigm language, JavaScript supports event-driven, functional, and imperative programming styles. It has application programming interfaces (APIs) for working with text, dates, regular expressions, standard data structures, and the Document Object Model (DOM).

The ECMAScript standard does not include any input/output (I/O), such as networking, storage, or graphics facilities. In practice, the web browser or other runtime system provides JavaScript APIs for I/O.

JavaScript engines were originally used only in web browsers, but they are now core components of other software systems, most notably servers and a variety of applications.

CoffeeScript support is included in Ruby on Rails version 3. and Play Framework. In 2011, Brendan Eich referenced CoffeeScript as an influence on his thoughts about the future of JavaScript.

On December 13, 2009, Jeremy Ashkenas made the first Git commit of CoffeeScript with the comment: “initial commit of the mystery language.” 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 a self-hosting version 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.

On September 18, 2017, version 2.0.0 was introduced, which “aims to bring CoffeeScript into the modern JavaScript era, closing gaps in compatibility with JavaScript while preserving the clean syntax that is CoffeeScript’s hallmark.”

Almost everything is an expression in CoffeeScript, for example ifswitch and for expressions (which have no return value in JavaScript) return a value. As in Perl, these control statements also have postfix versions; for example, if can also be written in consequent if condition form.

Many unnecessary parentheses and braces can be omitted; for example, blocks of code can be denoted by indentation instead of braces, function calls are implicit, and object literals are often detected automatically.

The CoffeeScript compiler has been self-hosting 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. One alternative to the Node.js utility is the Coffee Maven Plugin, a plugin for the Apache Maven build system. The plugin uses the Rhino 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 users can enter CoffeeScript, see the JavaScript output, and run it directly in the browser. The js2coffee site provides bi-directional translation.

  • Source maps allow users to debug their CoffeeScript code directly, supporting CoffeeScript tracebacks on run time errors.
  • CoffeeScript supports a form of Literate Programming, using the .coffee.md or .litcoffee file extension. This allows CoffeeScript source code to be written in Markdown. The compiler will treat any indented blocks (Markdown’s way of indicating source code) as code, and ignore the rest as comments.

Iced CoffeeScript is a superset of CoffeeScript which adds two new keywords: await and defer. These additions simplify asynchronous control flow, making the code to look more like a procedural programming language, eliminating the call-back chain. It can be used on the server side and in the browser.

On September 13, 2012, Dropbox announced that their browser-side code base has been rewritten from JavaScript to CoffeeScript, however it has been migrated to TypeScript in 2017.

GitHub’s internal style guide once said “write new JS in CoffeeScript”, and while it no longer does, all the advice in the style guide references how to write good CoffeeScript,[22] and their Atom text editor was also written in the language.

Pixel Game Maker MV makes uses of CoffeeScript as part of its game development environment.

Above is a brief about CoffeeScript. Watch this space for more updates on the latest Trends in Technology.

Leave a Reply

Your email address will not be published. Required fields are marked *