Google's Closure compiler moves from Java to JavaScript

The tool has shed its Java dependency in favor of compiling Java source code to JavaScript

Google Closure compiler moves from Java to JavaScript
Credit: Patrick Hund

Google's Closure compiler, for optimizing and transpling JavaScript, no longer needs Java to run. Instead, Java source code is compiled to JavaScript so it can run under Node.js or in a browser. Java-dependent Closure had been introduced by Google in 2009.

The experimental release detailed this week supports ECMAScript 2015 features like arrow functions and let and const, and it provides polyfills for some ES2015 methods. It will check both syntax and types, and will provision warnings for JavaScript "gotchas." Google cautions, though, that some features are not available, and performance may not equal the Java version.

The upgrade is not a rewrite of Closure in JavaScript. To use the new version, developers should add it as a dependency in a project via NPM, though it also can be used with the Gulp streaming build system.

"If you'd like to migrate from google-closure-compiler, which requires Java, you'll have to use gulp.src() or equivalents to load your JavaScript before it can be compiled. As this compiler runs in pure JavaScript, the compiler cannot load or save files from your file system directly," Google's Sam Thorogood, developer programs engineer, said. Developers not using Gulp or Webpack plugins will need to specify code via flags, release notes in GitHub state.

Closure is available under an Apache 2.0 license.

This story, "Google's Closure compiler moves from Java to JavaScript" was originally published by InfoWorld.

To express your thoughts on Computerworld content, visit Computerworld's Facebook page, LinkedIn page and Twitter stream.
Windows 10 annoyances and solutions
Shop Tech Products at Amazon
Notice to our Readers
We're now using social media to take your comments and feedback. Learn more about this here.