Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Turning Java into Javascript with J2S

Turning Java into Javascript with J2S

Interface21's Ben Alex has recently been examining Java2Javascript Pacemaker (J2S). J2S includes a Java to Javascript compiler along with support for standard Java packages such as java.lang, and java.util. It also includes a Javascript version of Junit and Eclipse SWT. Alex compares J2S to the more well known GWT:

J2S provides comprehensive runtime reflection and widget binding capabilities. GWT prefers compile-time JavaScript optimisations, at the expense of these runtime services. J2S – on the other hand – recognises that a combination of Moore's Law, improved browser JavaScript interpreters and JNI-like JavaScript optimisations collectively provide scope for adequate performance, whilst still enjoying fuller JRE emulation and other runtime services.

He then goes on to examine the pros and cons of each. Noting that while GWT provides it own Swing like API, J2S provides an implementation of SWT allowing targeting of a clien to both a rich client (JVM) and web UI (web browser via Javascript). Given Interface21 is the company behind Spring, Alex then looks at integrating J2S with the technology. In conclusion he writes:

In conclusion, J2S promises some attractive benefits for projects that require JavaScript compilation or a web browser implementation of SWT. It also interoperates successfully with a Spring backend. J2S' deliberate choice to leverage proven existing technologies such as AST and SWT make it a good example of reusing existing code and developer skills, in turn lowering adoption barriers and the prospect of material API change. If you consider yourself an early adopter, SWT devotee, or need a client-centric, web-based user interface that is built upon the mature SWT UI framework, it is definitely worth taking a closer look at J2S.

Rate this Article