Back to the Future: let’s stop buying new Laptops and Smartphones ;)

When I was a teenager, I used to go to the center of Paris to buy specific parts to build my PC myself: sound cards, video cards, power blocks, hard drive, CPU, fans, memory, you name it. Not only it was fun and instructive, but it was also good for the planet.

Continuer à lire

AI vs. Maths

Quite recently, I had the chance to discuss with Philippe de Reffye, a French researcher who spent his life studying how plants grow. He built a generic mathematical model that can simulate the growth of any plant, assuming we can mesure some environmental parameters to calibrate the model. He wrote a very complete book about it (in French).

The book of Philippe de Reffye

The interesting point from my perspective is that his work managed to lower the computational complexity of simulating plant growth from an exponential to a linear function. What would take days to calculate can now be done in seconds, and it grows linear w.r.t. the plant complexity.

Philippe and I talked about AI. His opinion is that AI can help calibrating the models. However, without the maths, you cannot really understands what happens when the plants grow and you have no chance finding an optimization of the kind he found.

Philippe warned me about the danger of replacing maths with ML when we don’t have a model. Indeed, it is a potential workaround, but it is expensive in computation time and it blurs our understanding of the world.

JSweet transpiles Sweet Home 3D open source project to help creating a web version

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).

Continuer à lire

JSweet version 2.0.0 has been released

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:

  • More interoperability with JavaScript. By default the generated code gets rid of Java APIs and uses pure JavaScript objects (for instance Java lists and maps will translate to pure JavaScript arrays/objects). No Java runtime is required anymore (on contrary to other Java to JavaScript transpilers) and your JSweet APIs can be used as is by JavaScript and TypeScript programs. JSweet even translates Javadoc comments to JSDoc for full API support. Try it.
  • Support for tuning and extending the transpiler. With JSweet 2, there are several ways to tune/extend the generated code: Java annotations, configuration file, or through the JSweet transpiler extension API. In short, JSweet is now an open transpiler, which means it can be easily extended/adapted, as fully explained here. Also check out the small example right below.
  • Much improvements to bridge external JavaScript libraries. With JSweet 2, it becomes really easy to write your own candies (a.k.a. bridges). First, you can write definitions on-the-fly in your program within the 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.
  • More extensive support for Java (semantics and core APIs). Partial and extensible support for many Java APIs such as java.io, java.lang.reflect, or java.math, is now built-in or easy to plug in with the extension API.

Example

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");
    }
}

Know more / get involved

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.