Ask HN: Is it a good idea to combine Racket and Rust?

I am wondering whether it is a good idea to program in Racket, and use extensions in Rust.

What I am specially interested in are programs which both use very computing-intensive integer and floating point arithmetic (for example, backtracking algorithms, signal processing, and numerical optimization), and interactive / exploratory programming with easy visualization.

I am quite interested in using a combination of a Lisp and Rust in the long term for algorithm development. Here is why I think the combination of Racket and Rust might be a good idea:

* It seems easy to call into Rust functions from Racket.

* Both Racket and Rust favor a functional programming style, while allowing for local mutation of vector data where needed. Currently, I think this is essential to write high-performance numerical codes.

* If one accepts the toy programs in the computer language benchmarks game as evidence, Racket seems to allow for very compact and easy-to-read expression of algorithms. For complex numerical stuff, this is very important.

* By all accounts, Rust is speed-wise comparable to C. Racket is, according to my impression, usually about 5 - 10 times slower than C.

* Racket seems to have a good math and vector library and good support for plotting.

* Racket seems excellent for scripting: Quick start-up time and concise notation.

* It is possible to pack together everything which is needed to run a program in a single executable. That makes deployment easier.

* A gray area for me is how both language's concurrency paradigms would interact. Racket seems to rather avoid shared-memory concurrency. I think however that the paradigm used by Rust is easy to understand from the calling function's po\ int of view. I guess the match between Racket and Rust is much better than it would be with, for example, SBCL/Rust.

But my view might be too optimistic. Any experiences and thoughts to share? I'd love to learn more.

  • Try sending the question to the mailing list, perhaps there is someone that tried something similar before. (I don't remember a case with Rust, but I'm sure someone did something similar with C.)

    It would be nice to see a blog post of your results with the integration of Racket+Rust preferably with some examples and benchmarks.