Paul Krill
Editor at Large

GopherJS nudges Google Go past Dart in JavaScript Web development

news analysis
Oct 20, 20142 mins

With GopherJS, front-end code can be written in Go language, then compiled to JavaScript

Just when we thought Google Dart was Google’s answer to JavaScript, a compiler project is emerging to enable front-end code written in Google Go to run in all browsers.

The GopherJS project, started by developer Richard Musiol in August 2013, compiles Go code to pure JavaScript code, the project’s GitHub page states: “Its main purpose is to write front-end code in Go, which will still run in all browsers.” Thus, Go can be used in front-end Web development, Musiol said in email.

“With GopherJS, you can take advantage of Go’s elegant type system, compile-time checks, and concurrency model to build client-side applications,” said developer Joseph Hager. “By abstracting out the small parts of your project that are specific to either native or Web, you can recompile to JavaScript without changing a single line of code.”

Dart and GopherJS are similar in what they intend to accomplish, but Go was designed as a systems programming language, according to Hager. “Dart, on the other hand, was built with the needs and constraints of the Web in mind from the beginning.”

GopherJS also supports the Go language’s Goroutines concept, getting around JavaScript’s restriction on concurrency. “Go’s concurrency model takes inspiration from quite a few languages over the past 30 years,” Hager says. “Goroutines are the star feature of that model, and GopherJS supports them fully. Keep in mind that JavaScript has no real concept of concurrency, so an instruction can never block. This sort of behavior comes up quite often in Go, and it was an heroic effort on Richard’s part to devise a way to make it all work.”

Design goals for GopherJS include performance of generated code, similarity between Go and generated JavaScript code for debugging, compatibility with existing JavaScript libraries, and small size of generated code. While the project has no official development status, such as a 1.0 or beta release stage, it could use more developers, says Hager. “If we are going to convince others to give GopherJS a chance, there need to be solid libraries and frameworks they can bet on. There are quite a few intrepid developers trying to make that happen, and I hope we will be able to count you all among them some day.”

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author