Hacker News new | ask | show | jobs
by jeffdavis 2373 days ago
The continuing improvements to procedural macros are great!

I do a fair amount of integration with C, and the work the rust team is doing for procedural macros has helped a lot. Being able to use them in an extern blocks will surely help more.

Like many, I have a wish list that I complain about sometimes, but I feel bad about complaining because rust has done so much to improve my use case I don't know where to begin. I should write up a blog post about all of the difficulty I had, and how each release since around 1.28 has introduced features that solved these problems one by one.

To me, Rust/C interop is the killer feature. Not only is it a low-level language that can be used instead of C, it can also be used to extend C applications. I'm sure it was not easy to do this well, but what a great strategic decision by the rust team to spend the effort on it!

1 comments

Can you recommend any good blog or tutorial on integrating C/Python and newer releases of Rust?
I didn't use much except for the official docs (book and reference). Googling around shows some promising material.

Release notes are helpful -- when you see something added related to C, it's a strong hint to read about the new feature.

Macro features are important because rust has sophisticated macros and C macros are closer to text replacement. So when trying to emulate a C header, you need to do a lot of macro magic in rust sometimes.

Sorry that I don't have more to offer from personal experience.

Here's a common Rust foreign function interface for Python, with quite a few examples:

https://crates.io/crates/pyo3

Here's the one for C:

https://crates.io/crates/libc