Hey all! Read a lot of good things about Rust and I was getting pretty bored and often annoyed with building new FastAPI apps. I’m just getting started, from my research Poem seems to be doing the same thing as FastAPI kinda and I’m using SeaORM for the DB.

So far I’m loving it, Cargo.toml looks a lot like Poetry in Python but in VSCode it magically shows me the latest versions of all dependencies. Debugging is really nice because I can just copy & paste compiler messages into an LLM or Google them. It was a bit of a hassle to get all dependencies to work together and to get the thing to compile at first but now it works and I’m happy.

That being said is there anything else I need to know? I still have a very limited understanding of the whole ownership thing but e.g. I understand the benefits of passing variables instead of copying them so I guess that’s a start?

  • FizzyOrange
    link
    fedilink
    arrow-up
    8
    arrow-down
    1
    ·
    5 days ago

    I would say:

    1. Avoid async if you can. It’s way more difficult and error prone than non-async Rust. Unfortunately a lot of web stuff insists on async.
    2. Don’t be afraid to .clone() stuff to fix lifetime errors. It’s not optimal but consider that in C++ everything is pretty much cloned by default, and nobody ever said C++ was slow.
    3. Use anyhow::Result for error handling. It’s the easiest option.
    • echodriftOP
      link
      fedilink
      Deutsch
      arrow-up
      2
      ·
      4 days ago

      Thanks! One of the reasons for choosing Rust was actually concurrency. So I’m building a bunch of endpoints that connect with some microservices and I expect to have many simultaneous requests. I’m honestly not like super senior but for the Python backends we’ve been building we always made everything asynchronous so I kinda got the impression that that would be necessary for my use cases. Should I also be careful with async functions when using Poem?