cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.45k stars 159 forks source link

Using JSweet for Flutter #717

Open WhiteTrashLord opened 2 years ago

WhiteTrashLord commented 2 years ago

I was thinking about writing Flutter apps in Java instead of Dart. JSweet can compile also to Typescript. I found this Typescript to Flutter transpiler: https://github.com/hydro-sdk/hydro-sdk Do you think it might work to use 2 transpilers ( JSweet and Hydro-SDK ) to produce working Dart code for Flutter while using Java source code? Or would it be better to write a Java to Flutter transpiler from scratch?

lgrignon commented 2 years ago

That sounds like an amazing (and crazy) idea :) I hope you will manage to make it work, whatever are the choices you will make. That being said, if you want to use JSweet (or any tool which integrates in a Java compatible environment), you will need what we call a candy, which is a jar containing the definition (classes, interfaces etc) of the lib you want to use.

In TS, Hydro SDK seems to provide the proper TS definitions. You need the Java ones. If this framework is simple enough, you can write it manually, but it could quickly get painful. Otherwise, you can give a try to this good old https://github.com/cincheo/jsweet/tree/develop/candy-generator Which is exactly the tool you would be looking for, turning TS definitions to a beautiful JSweet candy but ... it's rather old. It was compatible with TypeScript until version 2.x I think. If HydroSDK's TS defs use exotic / modern syntax, it would require you to upgprade the candy generator to support modern constructs. That would be amazing though. If you do so, please file a PR with some tests and I will merge it inside official repo!

I hope you will succeed and keep us posted with this nice idea :)