Emscripten interface to model

Dear All,

I’m interested in using Emscripten to compile parsed stan model into Webassembly, and pass it data (as JSON) from Javascript. I see that something along those lines was discussed in GSoC 2017 (mentor: @bgoodri), but I haven’t found anything since. If starting from scratch, would it be better to fork cmdstan, or start from the core C++ libaries?

Best wishes

I think the best thing to do would be to start a new project (i.e. repository) which includes the stan-dev/stan as a submodule (which in turn has stan-dev/math as a submodule). Alternatively, include a tagged version of Stan and Math into the project.

It’s fine to use CmdStan as a blueprint, but my guess is that most of the things in there will not be relevant for a project like this.

Dear @syclik

Thanks for the feedback - I did find an example on the old Google Groups site https://groups.google.com/forum/#!searchin/stan-users/emscripten/stan-users/cps0AgFneMw/Nms1InXpGdIJ

Inclusion of SUNDIALS makes it a bit more fiddly, but still doable - probably best to get stan-dev/math working first…


You should be able to run models that don’t call the ODE integrators without having Sundials available. You’ll just have to exclude the paths manually from the includes.

Dear Bob,


Following on from this, I’m generally interested in developing easily deployable models. If you know of any grad students or postdocs who might want to work on this, in the context of epidemiological modeling, please let me know. I can apply for 6-12 months funding if I have a named person.


I don’t, but I can suggest our jobs category. This isn’t the kind of thing we’ve found that grad students or postdocs want to do, because it doesn’t lead to publications and hence academic job prospects.