Hacker News new | ask | show | jobs
by megadal 778 days ago
> Besides the main compiler part, the project comes bundled with an interop layer, which allows you to easily call C# code from Rust and vice versa.

I guess the part I am still missing is when you say Rust in this context, it seems like you're essentially referring to "Rust.NET" really, and not Rust. E.g. it makes it easier to call .NET code from Rust _if_ it's using your .NET target, but Rust for other targets, not so much.

(^correct me if I'm wrong here, as the rest of the points made are based on this assumption)

This just seems contradictory to the goals of someone using .NET/Rust interop in the first place. If you're bringing in Rust, it's because you want the raw power of native code, not just the ability to easily write Rust code where you absolutely could've just written in your original .NET language (because ultimately, your compiler target is .NET, not executable code itself).

I can see many layers of abstraction dealing with this issue, but it still makes me wonder why someone wouldn't just compile Rust to a DLL and call that from .NET.

The calls from Rust -> .NET runtime could be useful, however, as I'm pretty sure you can't just load a class library dll in rust and start instantiating things from it. But at the end of the day, I can't see that being possible without loading the .NET runtime in your Rust program, which involves loading all those dependencies, which .NET languages already do very well by themselves so why not just, for example, write a Rust app and a .NET app and use IPC in such a scenario.