Don't write Rust like it's Java - eviltoast
  • Knusper@feddit.de
    link
    fedilink
    arrow-up
    10
    ·
    1 year ago

    Wow, man, I forgot just how object-oriented Java is. You’ve got all these services pretending to run independently, except they’re not actually running asynchronously, and every service has a pointer to all the other services they need to talk to, leading to a huge tangled net of cross-dependencies. That’s why everything needs to be an interface, so you can mock it in tests.

    Rust is a lot more …tree-shaped, with the main passing data into functions which call other functions and those return data, which can be passed into the next function.
    Obviously, you can also build services running independently, but it’s usually done a lot more intentionally, by spawning own threads, passing around an (explicit) Arc, and then because you’re actually running asynchronously, you do need mutexes and such…