News for hackers. Stuff that matters.
Re:Many small queries are efficient in SQLite by Spivak on Tuesday February 16, 2021 @11:48AM (#26155850)
I mean I have to deal with this crap at $dayjob but I genuinely can't believe of the terrible code I see that borrows a resource (connection, transaction, file handle) and then only the happy path gives it back. I desperately wish that languages would make this a compile error if all code paths don't lead to the resource being freed.

The only thing that should ever stop you from returning a resource is a malicious scheduler.

Re:Many small queries are efficient in SQLite by lixtra on Tuesday February 16, 2021 @01:50PM (#26157323)
> I desperately wish that languages would make this a compile error if all code paths don't lead to the resource being freed.

You might want to take a look at rust.

Re:Many small queries are efficient in SQLite by AtlasBarfed on Thursday February 18, 2021 @01:20PM (#26183451)
I can see the obvious parallels between memory management lifetimes and transaction management, does rust have explicit features for extending lifetimes to resources besides memory?
Re:Many small queries are efficient in SQLite by lixtra on Friday February 19, 2021 @01:44AM (#26190412)
Yes, it works for files, network connections and database transactions[1].

To span a transaction over two functions, it has to be assigned to some variable and the lifetime of this variable is tracked by the compiler.

[1] https://docs.rs/sqlx/0.3.0/sqlx/struct.Transaction.html