Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT VS Google Closure, what is the difference?

If I understand correctly, both GWT and Google Closure are JS API's for building web applications. What is the difference between them?

like image 948
MichaelS Avatar asked Sep 12 '11 05:09

MichaelS


People also ask

What is closure Google what is closure in JavaScript?

The Closure Compiler is a tool for making JavaScript download and run faster. Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. It parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what's left.

Does Google have a compiler?

You can access the compiler in a JS program by importing google-closure-compiler : import closureCompiler from 'google-closure-compiler'; const { compiler } = closureCompiler; new compiler({ js: 'file-one.

What is the function of a closure compiler?

Explanation: The Closure Compiler is a tool for making JavaScript download and runs faster. It parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what's left. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls.


1 Answers

Closure is a JavaScript library (really more like a collection of libraries, but that are all packaged as a single library and that can be imported using goog.require from the base library). Closure simplifies a bunch of common JavaScript tasks in a way that is compatible with multiple browsers. Closure is also a JavaScript compiler that can both minify and optimize JavaScript code.

GWT is a Java toolkit (and associated libraries) that can take code written purely in Java, and convert it into HTML, CSS, and JavaScript, allowing a web application to be written purely in Java (but served as a real, HTML5 website, rather than as an annoying, slow-to-load Java applet).

A project written in GWT can make use of the Closure library and can include JavaScript code. However, Closure is really targeted toward developers writing JavaScript, while GWT is for Java developers.

To summarize...

Use Closure when:

  1. You are writing standalone JavaScript code.
  2. You are writing JavaScript that you connect with GWT via the "JavaScript Native Interface" (JSNI).
  3. You prefer rolling your own HTML, CSS, JavaScript.

Use GWT when:

  1. You are developing new or large web applications.
  2. You have a preference for writing code in Java.
like image 93
Michael Aaron Safyan Avatar answered Oct 11 '22 02:10

Michael Aaron Safyan