js_of_ocaml vs JSweet
js_of_ocaml
ocsigen.orgJSweet
jsweet.orgSide by side
| Figure | js_of_ocaml | JSweet |
|---|---|---|
| Price from | Free | Free |
| Free plan | Yes | Yes |
| Free trial | — | — |
| Open source | — | Yes |
| Web | Yes | Yes |
| Windows | — | Yes |
| macOS | — | Yes |
| Linux | Yes | Yes |
| iOS | — | Yes |
| Android | — | Yes |
| API | Yes | Yes |
| Self-hosted | — | Yes |
| Plans published | 1 | 1 |
| Spec score · Code Transpilers | 8.4 (#5) | 8.7 (#1) |
| JavaScript interoperability | The library provides a typed interface for bridging OCaml and JavaScript values, with PPX syntax for JavaScript properties, methods, constructors, and objects. | Generated output is ordinary JavaScript intended to interoperate directly with JavaScript code and libraries. |
| License | The repository lists GPL-2.0-or-later and LGPL-2.1-or-later with the OCaml linking exception as its licenses. | The repository links to a license file but the opened page does not state the license name in its displayed README text. |
Plans
In their own words
js_of_ocaml
js_of_ocaml compiles OCaml bytecode programs into JavaScript for browsers and Node.js. It works with an existing OCaml installation and does not require libraries to be recompiled. Installation is available through opam, while Dune supports separate compilation in development and whole-program compilation in release builds. Whole-program compilation performs global dead-code elimination and cross-module optimization. The library provides a typed bridge between OCaml and JavaScript, including PPX syntax for properties, methods, constructors and objects. Browser bindings cover the DOM, Fetch, WebSockets, WebGL, workers and typed arrays. Optional packages add Lwt support, TyXML, JSON derivation and an OCaml toplevel in the browser. Documented targets include Node.js 18 or later, QuickJS-NG and modern ECMAScript 2020 browsers, including Chrome 80+, Firefox 74+, Safari 13.4+ and Edge 80+. Requirements include OCaml 4.13–5.5, Dune 3.20 or later and Menhir. The project is free and open source.
JSweet
JSweet converts Java programs into TypeScript and JavaScript for browsers, mobile Web views, or Node.js. It uses Oracle's Java compiler alongside Microsoft's TypeScript compiler to generate type-checked JavaScript. The project describes the output as regular JavaScript that can work directly with JavaScript programs and libraries. Listed language features include Java-to-TypeScript syntax mapping, Java constructs, async/await, and ECMAScript targets from ES3 to ES6. JSweet lists support for more than 1,000 JavaScript libraries, frameworks, and plugins, packaged as Maven artifacts called candies. It provides Eclipse, Maven, and Gradle plugins, and names Angular, Cordova, Node.js, and Three.js among example integrations. Generated programs can use CommonJS, AMD, or UMD modules and run in browsers or Node.js. A debug mode supports debugging Java code in a browser. Setup instructions call for Git, Node.js, and Maven, then use Maven to generate JavaScript from a quickstart project. JSweet is open source and free, and is presented for Java developers building web and mobile HTML5 applications with JavaScript libraries and frameworks.