#Wrap Rust code with Gleam?
1 messages · Page 1 of 1 (latest)
Using natively implemented code has massive drawbacks so you should avoid it as much as possible
But if you really have no other option available to you (for example, to use SQLite) then you can use Erlang NIFs or the native binding features of whatever JavaScript runtime you are using
I understand. I was mostly curious in case there's some Rust crate I want to wrap for performance reasons.
What's the crate?
Native FFI has a performance overhead and can easily negatively impact the scheduler, so often it's slower than well written BEAM code
Is there somewhere I could read about this? What are the drawbacks, why they occur, etc.
I also read here somewhere that some languages are not a good target for Gleam, I think it was Go that was discussed -- does it have anything to do with it?
the warning box there for example
(and further docs on that page)
No, the suitability of a language as a compilation target is unrelated to NIFs on the BEAM
Thanks, I will read
Where can I find out more about that?
About what, sorry?
What makes a language a suitable target
That's a very large subject
I tried searching for the go discussion here on discord but go is a very generic word
Implementation of programming languages is a whole area of computer science
For Go and functional languages specifically their memory allocator and GC is a bad fit
They want a small number of large allocations
FP is about a large number of small allocations
Interesting, thanks. That's surely enough to send me down a rabbit hole
Ok so, to give you a bit of context. I'm learning Gleam right now and I really like it. It also seems very well suited for data analysis and manipulation. It's functional, thus data is immutable and transforming data is very easy, but it is also statically typed. This got me thinking about a dataframe library in Gleam, which I believe doesn't exist (or at least, I have not found it). So I thought that it would be cool to wrap polars from Rust with Gleam, because it is very performant already and I got the feeling the Gleam isn't suited for highly performant operations (which is fine, it doesn't need to be) but maybe I'm just wrong
Is this one suitable?
https://github.com/tynanbe/argamak