tla-org / poweranalyses

Statistical power analyses in the browser
https://poweranalyses.org
GNU General Public License v3.0
4 stars 0 forks source link

Implement `pnt` in Rust #25

Closed rikhuijzer closed 9 months ago

rikhuijzer commented 9 months ago

Works towards fixing #24.

This is a way in which we could get rid of C and, hence, emscripten. We just incrementally port the C code to Rust. It's a lot of work, but not super difficult. Once this is done, it should make other things such as plotting and handling the browser DOM easier, so then it's a net win?

The code tries to stay as close as possible to the original implementation. This should make it easier to find bugs in our port.

I've also tried c2rust. Apart from some warnings, it seemed to work after generating compile_commands.json with intercept-build. The generated code was not very pretty, however, and relied heavily on libc, so I think a manual rewrite is more future proof.

storopoli commented 9 months ago

Once this is done, it should make other things such as plotting and handling the browser DOM easier, so then it's a net win?

Exactly!

storopoli commented 9 months ago

The code looks fine. But since we are rewriting this in Rust, could we add documentation to the new function and modules.

rikhuijzer commented 9 months ago

The code looks fine. But since we are rewriting this in Rust, could we add documentation to the new function and modules.

I did that apart from the module. With module, the call would become pnt::pnt::pnt which is a bit too nested IMO

storopoli commented 9 months ago

Yes, what you did with the //! is what I've meant with module. Thanks!