New compilers prepare devs for the next generation of JavaScript

Ngoc Huynh

Babel and xto6 help developers move to ECMAScript 6 code and prepare for ECMAScript 7 features

Two projects geared to JavaScript compilation, Babel and xto6, are moving forward with the goal of helping developers navigate next-generation capabilities.

Version 5.0 of the Babel compiler, made available last week, includes ECMAScript 7 proposals like decorators, for annotating classes and properties at design time; class properties; and additional export-from statements. ECMAScript 7 is in development even as ECMAScript 6, the predecessor, still has yet to be formally released. With Babel, ECMAScript 6 or higher code is turned into ES5-friendly code, so it can be used without waiting for browser support.

Also in version 5.0, the internal traversal and transformation pipeline has been rewritten, increasing flexibility and enabling future performance optimizations. A plug-in API, meanwhile, allows consumers to plug in custom transformers to utilize Babel’s transformation mechanisms. Breaking changes include removal of the Babel “playground,” ES7 abstract references, and the experimental option, which has been replaced with a stage option. “The playground has been removed so development can be focused on mainstream ES features and proposals,” release notes state. “This also reduces the risk of syntactic conflicts preventing certain official features from being implemented.” The upgrade starts to align with the ECMA TC39 process, named for the technical committee developing ECMAscript. Babel can work with Node.js applications as well as other technologies.

With xto6, a college student in Iran is developing a transpiler that takes ECMAScript 5-compliant code and transpiles it into ECMAScript 6. Currently in an alpha stage of development, xto6 is being published under an MIT license. “It converts codes written in previous versions of JavaScript to ES6,” lead developer Mohamed Mohebifar, a student at Shahid Beheshti University, said in an email. “It can be used to find the most up-to-date approach of doing things in JavaScript — but is not limited to ES6. It also helps when doing projects in teams as ES6 is cleaner and offers a better way to organize codes using classes, arrow functions, etc.”

Mohebifar sees xto6 helping to educate on new features in JavaScript. “Some people are not familiar with ES6 features; they can pass their code to xto6 and get ES6 equivalents,” he said. “Also, it can be used to modernize old-fashioned JavaScript codes into ES6.” He is seeking feedback on xto6, which has its own repository on GitHub.

Share the news now

Source : http://www.infoworld.com/