When is it better not to use Rust?

95 points thomasc_

Here's some background, I'm writing a widget system similar to EWW or Rainmeter. I'm using Luau as the configuration language, and GTK4 for the actual widgets. I created a proof-of-concept in C, but I wanted to use Rust or C++ in the long run.

I'm not a very experienced programmer, and this would be the first big project I've written both in general, and specifically with Rust or C++. When starting work on the Rust version, I felt that things were often "hacky". This is quite possibly my lack of experience showing, but it just felt weird trying to get widgets out of the Lua state. When trying to extract the UserData I was constantly fighting with the type checker, which wasn't ever a struggle when I was using C/C++. Am I just approaching this from the wrong angle, or is this a case where using Rust would be a lot more painful than C/C++.

Edit: Figured I'd add a code snippet I've been struggling with.

let lua = Lua::new();

// A simple function that should receive widget userdata as an argument
// and present it in a new window
let present = lua.create_function(|_, widget: ?| {
    ApplicationWindow::builder()
        .application(app)
        .set_child(widget)
        .build()
        .present();

    Ok()
})?;

Because of Rust's lack of inheritance, I've struggled to find a good way of taking any IsA<gtk::Widget> as an argument.

Edit 2: Thank y'all for all the feedback! Based on what's been said, I've decided to stick with Rust! I've just pushed the first bit of code to my GitHub and should be making quick progress now that I've overcome some of the hurdles I mentioned! I'll check back in once the program's more complete for a code review.