rhaiscript / rhai-sci

Scientific computing for Rhai.
https://crates.io/crates/rhai-sci
Apache License 2.0
15 stars 1 forks source link

Why write functions in Rhai? #1

Closed schungx closed 2 years ago

schungx commented 2 years ago

Is there a particular purpose of writing the functions in Rhai script?

Otherwise, this package would really be a very useful one for many people...

But having to run scripts for every function will probably make it too slow for most applications?

cmccomb commented 2 years ago

Great question! The purpose of the project is to provide some extra MATLAB-esque functions for use in Rhai scripts, and I started with a "how far can I take pure Rhai?" mentality. As I get to more computationally intensive functions (e.g., matrix inversion) I've been implementing those as Rust plugins.

I guess I accepted the fact that since Rhai is always going to be a bit slow since its a scripting language. Anybody working on a speed-critical application would probably write it in pure Rust from the start.

Thoughts?

schungx commented 2 years ago

how far can I take pure Rhai?

I understand your logic, and writing in Rhai give more flexibility for patching code later on without recompiling. Having fun while doing it is one of the most important aspects of programming!

I just think that, if you'd implement the functions in native Rust, then this library is really going to be extremely useful to many people! I would encourage you to move it under the rhaiscript org so others can also use it.

I am also intrigued by your way of generating online docs for scripted functions via a build step.

cmccomb commented 2 years ago

You make some good points! I'll start working to move away from Rhai and into rust.

I'd also be happy to transfer it under the rhaiscript org. Should I do any cleanup before?

cmccomb commented 2 years ago

And the build script is a bit hacky... but it does run the Rhai doc comments!

schungx commented 2 years ago

I'd also be happy to transfer it under the rhaiscript org. Should I do any cleanup before?

Depends on you. You can move it into the org first, then clean up later. You can release a few 0.x versions to crates.io and then bump it up to 1.0 when you're ready.

I'll send you an invitation to the org.

cmccomb commented 2 years ago

Thanks! This project lives in the org now. I'll work to update the functions.

schungx commented 2 years ago

I'll put rhai-sci in the Book.