This comparison is of compile time, not of generated code.
I don’t have hard data for this. However, from goofing around, rescript/bsc seems quite a bit faster than jsoo. Anyone else experiencing this? If so, any intuition on why rescript/bsc is able to achieve these compile time speed ups?
When targeting js with js_of_ocaml, you have the extra step through byte code.
Use cases and features are different between jsoo and rescript. For instance, jsoo ppx might be responsible for additional typing time. The jsoo minifier, enabled by default (with program compilation) could affect timing. Same thing with source map support.
I would suggest collecting data if you want a better answers.
Maybe @jeffsco could provide some data as he moved some project from rescript to jsoo.
We are adding a “\n” to a ~400 line file, doing an incremental build. My measurements are 1.6s, your measurements are 0.97s. Either way, this feels slow compared to the likes of esbuild / bsc. In fact, this feels slower than Rust → wasm incremental builds, and makes me hesitant to build largeish (50k loc projects) on this tech.
I understand that jsoo currently goes through various ocaml stages; but I’m really wondering about the costs in compile time.
I’m not exactly sure why recompiling that webgldemo.cmo takes so much time.
Just to test I tried this test_gl which uses Brr’s interface to webgl and doing exactly what you suggest (adding a \n in the shader). With separate compilation I get the recompilations below, that is 39.3ms for the regenerating the cmo. The example is a bit simpler but not dramatically simpler.
Wild speculation ahead: are we perhaps looking at slowness due the typing of objects ?
The webgl demo is using the jsoo ppx that has a significant impact on typing I think. sourcemap is responsible for ~75% of the link time.
Again, you need to compare comparable things … and collect numbers.
passing --no-runtime to js_of_ocaml compile would reduce timing a lot … at the cost of less efficient code. (We currently parse the entire js runtime everytime we compile something, just to extract few informations to run optimisation, on my TODO to improve)
First without source-map we shave 15ms of the above 291ms but then if we add --no-runtime it reduces by an order of magnitude. So a \n addition in the test file reduces to: