• GolfNovemberUniform@infosec.pub
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    1
    ·
    1 day ago

    I do agree with you. Safety is important nowadays. Though if there’s a use case where Rust gets a very noticeable performance disadvantage (like UI), it may be better to just use C.

      • qaz@lemmy.world
        link
        fedilink
        English
        arrow-up
        3
        ·
        edit-2
        1 day ago

        I wrote a GTK application in Rust some time ago and it was filled with macros to deal with lifetime issues. Most issues could only be solved with unsafe macros or Rc<RefCell<T>>. The experience working with it is probably a lot better when using newer declarative frameworks, but using it with a toolkit written for C wasn’t fun.

        I personally prefer it for cli programs. The executables are considerably larger than C programs due to static linking, but that does mean that it works regardless of what libraries you have installed without any hassle.

        • onlinepersona
          link
          fedilink
          English
          arrow-up
          4
          ·
          1 day ago

          Rust on top of a C/C++ lib is not fun, that’s for sure. It has to setup a firewall around C which adds complexity. Using a rust native framework is better, IMO. Slint and egui are good examples thereof.

          As for application size, check this out.

          Anti Commercial-AI license

          • qaz@lemmy.world
            link
            fedilink
            English
            arrow-up
            5
            ·
            1 day ago

            Yeah, I wrote two “plugins” some time ago and the Assembly implementation was shorter than the Rust implementation due to the need to convert from C ABI and back 😅.

            I have taken a look at both Slint and Egui before, but they didn’t seem to integrate that well with the Linux desktop last time. I just checked again and it seems like Slint has a Qt backend now which is nice. I don’t really like immediate GUI frameworks, but JavaFX has so far been my favorite framework to work with so maybe I’m just weird.

            And yes, I have used min-sized-rust’s tricks for several of my projects, and it’s very effective. However statically compiling just doesn’t compare to using C and linking with the system libraries.

            • onlinepersona
              link
              fedilink
              English
              arrow-up
              2
              ·
              edit-2
              1 day ago

              JavaFX has so far been my favorite framework to work with so maybe I’m just weird

              I found Java Swing to be the easiest GUI framework to use. Never tried JavaFX. Would you call it an upgrade?

              However statically compiling just doesn’t compare to using C and linking with the system libraries.

              Rust does support dynamic linking (doc, stackoverflow), but AFAIK the crate has to explicitly be configured to do so (I might be mistaken though as I’ve never tried it). And from what I gather the rust ABI isn’t stable (which is a pity) so it’s “safer” to output a cdy-lib than a dy-lib.

              Maybe in the future the rust ABI will be stabilized.

              Anti Commercial-AI license

              • qaz@lemmy.world
                link
                fedilink
                English
                arrow-up
                2
                ·
                edit-2
                23 hours ago

                It is definitely an improvement over Java Swing. One thing I really love and miss with other frameworks is how easy it is to connect properties with each other. All values are exposed as Properties and Values. Values can be listened to, mapped and used. They are similar to RXJS’s Observables except that you can always get the internal value without a lastValueFrom that may fail. Properties can also be listened to, mapped, etc but their value can also be set from everywhere (RXJS instead has Subjects which can only be set from inside the constructor). It’s a really easy, yet powerfull system. I have yet to find a single framework that does that part as well as it does.

                And regarding Rust lack of stable ABI, even if that’s resolved (and last time I checked there wasn’t much interest from within). The main Linux distributions will still have to ship the Rust stdlib as a shared library to be able to reliably depend on it being available.

                I do wonder if it would be advantageous to write a safe wrapper around the C and C++ standard libraries. It would mean being able to use it’s functionality, while being relatively sure that those dependencies are available while only having to add a little extra code (and thus size) to the executable for the wrappers.