• 2 Posts
  • 50 Comments
Joined 2 years ago
cake
Cake day: August 8th, 2023

help-circle
  • Cpo@lemm.eetoRust@programming.devAnnouncing Rust 1.84.1
    link
    fedilink
    arrow-up
    3
    arrow-down
    4
    ·
    edit-2
    11 days ago

    It is just because people are sensitive. Period.

    His comment should be read as “I don’t get the borrow checker”.

    Response of the Rust community: “lets vote him to oblivion”.

    Response should be: what part of it is not clear, hand him reference material etc.

    This was the same with scala (which has its userbase cut in 1/10th of what it is). Scala is now almost extinct.

    I would hate for Rust to become the next Scala because it offers so much nice features (for me that is native binaries) among others.

    I’ve had my share of response to honest questions which resulted in comments that I should be using language X, or that I have some nice term wrong (which does not relate to the problem I was experiencing), I am asking the wrong question and so on.

    Luckily there also were helpful comments, which kept me in the Rust ecosystem.

    The other behaviour is not productive and just makes Rust look like a niche, elite and too hard language.

    Be nice to each other. It will only make Rust and its community stronger.


  • Cpo@lemm.eetoRust@programming.devAnnouncing Rust 1.84.1
    link
    fedilink
    arrow-up
    12
    ·
    edit-2
    12 days ago

    I am in the process of learning rust by creating software for my own use.

    While the borrow checker feels like “fighting the compiler” at times (it took me a week before it started to land, and i have used my share of programming languages!), you will learn.

    I compare this to the C world where you can have quite complex constructs with pointers and references. That used to be hard as hell as well. Until it clicks.

    The only difference is that in C land, your software will segfault during runtime. In Rust your code will complain during compilation.

    Rust without borrow checker is just a bad version of C in my opinion. Rust with borrow checker actually brings value.

    In rust it is still possible to make circular references and cause memory leaks but it is very less likely.

    So: i understand where you are coming from but give it a chance to land. I am glad I did.

    The only thing which is bothering me at times is that the Rust community can come across as highly unfriendly/intolerant at times (comparable to the scala community, which in effect killed the adoption of scala).

    The response to your comment should not have been burning it to the ground but to ask why the borrow checker does not click for you.

    I can highly recommend the series “lets get rusty” on YT from Bogdan. He is explaining the main constructs in very easy to follow instructions videos.

    Have a look and see if it makes it work for you!














  • Well. I did read up on the “XY” problem and apparently you assume that what I want to do is somehow bad practice.

    To elaborate more on the problem: I am writing an axum backend which (like other backends) needs to do stuff in the database. As some endpoints update the database (and sometimes over multiple sql statements) I want to pass around the transaction as this embodies the connection I am using to update the database.

    To separate the axum stuff (parameters, urls and whatnot) from the actual database logic, I’ve first pulled out all the database interactions into separate functions. Because those functions are logically groups (e.g. stuff happening with invoices, others with contacts etc), I thought it was a good idea to create a “dao” struct (and agreed: my OO brain kicked in here which might be debatable). This would group the interactions for each logical domain into a short-lived data access struct.

    To prevent passing around the transaction/connection, i wanted to pass that along during construction, so the functions in the DAO could just access the connection when needed.

    Non “OO” would be fine to be honest (just having all the DAO as functions in a separate package).

    Sorry, no code, not at the computer atm.

    (And yes, I am aware that rust is not OO, put away the pitchforks please 🙏)







  • I am currently using it from a backend to generate pdfs.

    One thing that prevents me from letting users build their own templates is the scripting capabilities. A joker creating an endless loop could block the whole server.

    What would be nice is a “safe” mode in which no access to the file system (include and sorts) and limited runtime makes it safe to let users build their own templates.