ClojureScript vs js_of_ocaml
ClojureScript
clojurescript.orgjs_of_ocaml
ocsigen.orgSide by side
| Figure | ClojureScript | js_of_ocaml |
|---|---|---|
| Price from | Free | Free |
| Free plan | Yes | Yes |
| Free trial | — | — |
| Open source | — | — |
| Web | Yes | Yes |
| Windows | Yes | — |
| macOS | Yes | — |
| Linux | Yes | Yes |
| API | — | Yes |
| Self-hosted | Yes | — |
| Plans published | 1 | 1 |
| Spec score · Code Transpilers | 8.4 (#4) | 8.4 (#5) |
| License | Use and distribution are covered by the Eclipse Public License 1.0. | The repository lists GPL-2.0-or-later and LGPL-2.1-or-later with the OCaml linking exception as its licenses. |
| Optimization | Its JavaScript output is compatible with Google Closure Compiler advanced compilation, which can minify output and eliminate dead code. | Whole-program compilation performs global dead-code elimination and cross-module optimizations to produce smaller and faster output. |
| Runtime targets | The quick start describes browser output by default and Node.js output when the node target is selected. | Generated JavaScript is documented to work with Node.js 18 or later, modern ES2020 browsers, and QuickJS-NG. |
Plans
In their own words
ClojureScript
ClojureScript is a compiler that turns Clojure code into JavaScript for client and embedded application development wherever JavaScript reaches. It brings Clojure data structures and constructs—including functional programming, macros, destructuring, and polymorphism—into JavaScript environments. Its output is compatible with Google Closure Compiler advanced compilation, which can minify output and eliminate dead code. REPL support enables interactive development and testing in a browser or Node.js; the quick start uses browser output by default and selects Node.js output with a target setting. ClojureScript supports both ClojureScript and JavaScript dependencies, with React demonstrated in the quick start. Listed build tools include shadow-cljs, Figwheel, Leiningen, and lein-cljsbuild. Editor resources cover Cursive, Emacs, VS Code, Light Table, Sublime Text, Vim, and Atom. Documentation includes compiler and REPL options, dependencies, advanced compilation, source maps, and JavaScript module support marked Alpha. The project is open source under the Eclipse Public License 1.0 and lists Linux, macOS, Windows, web, and self-hosted environments.
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.