Compiler to convert Go language to JavaScript

Posted on 19-12-2017 , by: admin , in , 0 Comments

Developers wanting to use the Google Go language, aka Golang, for web programming can try the beta open source Joy compiler, which promises—when it reaches production release—to turn Go code into JavaScript code.

With Joy, idiomatic Go code will be translated into JavaScript that will work in every browser (as ECMAScript 3 code, with ECMAScript 5 code on the roadmap as well), the open source project claims. It also means JavaScript developers will be able to use Go’s type system and tools. Joy project creator Matthew Mueller says the Go-to-JavaScript translation work is about 90 percent complete.

Translation to additional variations of JavaScript also is on the roadmap, as is compilation to the WebAssembly portable code format. Plans also call for Joy to support both the React JavaScript UI library and Preact, a React alternative. 

The Joy compiler will parse code into an abstract syntax tree (AST), index these processes, and create a dependency graph. The Go AST will then be translated into a JavaScript AST, whereupon JavaScript code is created.