CoffeeScript 2 Released With Support For Async
Written by Kay Ewbank   
Thursday, 28 September 2017

There's a new version of CoffeeScript that is more compatible with modern JavaScript. The new release adds features including support for async functions and JSX.

 CoffeeScript code compiles one-to-one into JavaScript while being easier to read and adding language features not supported by classic JavaScript. The developers say the language aims to expose the good parts of JavaScript in a simple way. You can use any existing JavaScript library seamlessly from CoffeeScript, and the compiled output remains readable, passes through JavaScript Lint without warnings, will work in every JavaScript runtime. It tends to run as fast or faster than the equivalent handwritten JavaScript.

The new version of CoffeeScript translates CoffeeScript code into modern JavaScript syntax. So a CoffeeScript => is now output as =>, a CoffeeScript class is now output using the class keyword, and so on. While this has advantages, it does mean that you may need to transpile the CoffeeScript compiler’s output if your runtime doesn't support the most modern JavaScript syntax. CoffeeScript comes with built-in support for the Babel transpiler.

coffeescript2

The second major change in CoffeeScript 2 is support for async functions syntax, for the future object destructuring syntax, and for JSX. Other changes to JavaScript such as support for modules, tagged template literals, and the for..of construct were backported into CoffeeScript version 1.12.

JSX is a mix of JavaScript and XML elements, and CoffeeScript supports interspersed XML elements without the need for separate plugins or special settings.

ES2017 added async functions using the await keyword, and CoffeeScript uses the notion of an async function simply being a function that awaits.

The developers say there are minimal breaking changes from earlier versions, and most current CoffeeScript projects should be able to upgrade with little or no refactoring necessary.

Some new JavaScript features haven't been added to CoffeeScript, including let and const (and var), named functions and the get and set keywords to avoid ambiguity. The developers say that CoffeeScript’s lack of equivalents for these features does not affect compatibility or interoperability with JavaScript modules or libraries.

 coffeescript

More Information

CoffeeScript Site

Related Articles

 DeCaffeinate Converts CoffeeScript To JavaScript

CoffeeScript 1.9 Released

CoffeeScript Update

The Weekly Top 10: More JavaScript Development Resources

TypeScript 1.7

CoffeeScript Gets Regrind

CoffeeScript Supports Literate Programming

CoffeeScript in Action (Manning) (book review)

Programming in CoffeeScript (book review)

CoffeeScript: Accelerated JavaScript Development (book review)

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

 

Banner


Ai-Da's Portrait of Alan Turing At Auction
01/11/2024

Sotheby's Digital Art Day Action, now underway, features a large-scale portrait of  Alan Turing created by Ai-Da, the humanoid robot artist whose work, including this canvas, was exhibited at the [ ... ]



Google Updates Responsible AI Toolkit
01/11/2024

Google has announced updates to the Responsible Generative AI Toolkit to enable it to be used with any LLM model. The Responsible GenAI Toolkit provides resources to design, build, and evaluate open A [ ... ]


More News

 

espbook

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Thursday, 28 September 2017 )