A real-life example of migrating a Java application to JavaScript.
In this post, I will explain how JSweet helps building the online JavaScript Web version of an Open-Source interior design application called Sweet Home 3D developed and maintained by Emmanuel Puybaret.
Sweet Home 3D represents 130K Java Lines of Code (LoC). Amongst these, Emmanuel and I are able to transpile automatically around 50K LoC, leading to 68K JavaScript-generated LoC (by automatic transpilation, I mean that the generated JavaScript code can be run in the browser as is, without any manual adaptation of the code).
(more…)A transpiler is an Open Transpiler if programmers can open the hood of the transpiler and tune it for their own needs. In this post, I will explain what it means exactly, why we need it, and how it works. I’ll end up showing some specific JSweet v2 examples.
(more…)
We are pleased to announce that JSweet 2 is now available.
JSweet 2 is the outcome of several months of intense work with several partners that have been using JSweet for different purposes. It brings to you major improvements in the way you can transpile your Java code to JavaScript. Here are the main changes:
def
package. With the candy generator tool, you can translate the TypeScript definitions and get a first Java version, which you can modify for your own purpose, and share with the community in the jsweet-candies organization.java.io
, java.lang.reflect
, or java.math
, is now built-in or easy to plug in with the extension API.For the sake illustrating new JSweet v2 brand new power, let us say your Java program uses java.util.Date
objects. By default, JSweet translates java.util.Date
objects to JavaScript dates. However, for your context (and some personal reasons), you may want to translate dates to strings. With JSweet 2, you can simply use the extension API to write an adapter that will map the java.util.Date
type to the TypeScript string
type. It is as simple as this (see the complete example here):
public class HelloWorldAdapter extends org.jsweet.transpiler.extension.PrinterAdapter { public HelloWorldAdapter(PrinterAdapter parent) { super(parent); addTypeMapping(java.util.Date.class.getName(), "string"); } }
For more details and secondary features, please read the release notes.
We hope to keep in touch with you soon and plan to post some real-world success stories about using JSweet. Don’t hesitate to contact us in the meantime if you have any questions.
We are pleased to announce stable release 1.2.0.
This release contains many bug fixes and new features. It takes into account our last-months experience developing real IONIC/Cordova applications with JSweet, but also many excellent feedback from the community (many thanks to the reporters!). Also, it is compatible with Angular 2.
Check the release notes.
That’s official! JSweet allows using Java to write Angular 2 applications. It even was presented at JavaOne in the following talk:
This is a major release. JSweet now supports much better the Java language without loosing its original spirit of low-impedance between Java and JavaScript.
(more…)
This is quite serious! The famous JavaScript framework React.js is now available to Java as a JSweet candy.
Of course there are still details to be tuned, and the JSX syntax is not supported (yet?), but there is enough there to start having fun with React.js in Java.
I will step through some examples to give you the basics on how to program a React.js application in Java. (more…)
Let’s focus on two brand new JSweet projects that will help making Java and TypeScript more interoperable.
(Java loves TypeScript :)) (more…)
Recently, I came across this mccarroll.net’s post, which shows how to use the GWT transpiler in a standalone mode. It is quite interesting to look at the output of the given simple example and to compare it with JSweet output. (more…)
JSweet version 1.0 was released today.
JSweet is a Java to JavaScript transpiler built on the top of TypeScript and it gives access to hundreds of up-to-date and well-typed JavaScript APIs from Java. The following figure shows how JSweet translates from the TSD repository and uses the TypeScript tsc compiler and APIs (d.ts
) to transpile Java into JavaScript.
With the release of version 1.0, I would like to explore the main reasons why you, as a programmer, would want to try JSweet out, and ultimately use it to program Web applications in a better and safer way.
This is the most obvious reason, of course. JSweet ensures strong typing on JavaScript APIs and programs. JSweet has been designed to match TypeScript typing concepts and a JSweet program can bring the same type safety level as a TypeScript program. (more…)