News for hackers. Stuff that matters.
Re:Speed of Rust vs. C by bluejekyll on Saturday March 13, 2021 @06:31AM (#26445900)
Rust won’t prevent all manner of bugs, but if you need to prevent multiple parts of your application from accessing a resource concurrently, it’s fairly trivial to design types that would guarantee that at compile time.

If you need to do it across processes, then you need a file system that supports exclusive file opens.

The db question is a red-herring, because to properly solve for concurrency in the db, you need to use locks in the db (table and row locks), not the code accessing the db.

Re:Speed of Rust vs. C by Chilinot on Saturday March 13, 2021 @06:38AM (#26445927)
You dont necessarily need to use locks in the db. You can use transactions as well, unless you want to do major changes to the DB where transactions would be in constant conflict state.
Re:Speed of Rust vs. C by bluejekyll on Saturday March 13, 2021 @06:46AM (#26445956)
You’re right, though that wasn’t really the point of my reply. More that concurrency in the DB is a DB design choice and not the responsibility of the language accessing the DB. This is especially true when accessing the DB from multiple nodes, which most deployed software does.
Re:Speed of Rust vs. C by branko_d on Sunday March 14, 2021 @06:07AM (#26454044)
Locks and transactions are intertwined. Write locks are typically released only when the transaction ends, and read locks too at some transaction isolation levels.
Re:Speed of Rust vs. C by masklinn on Saturday March 13, 2021 @12:20PM (#26448030)
> Rust won’t prevent all manner of bugs

Nit: rust will prevent all manner of bugs. Rust won't prevent every manner of bugs.

Re:Speed of Rust vs. C by pjmlp on Saturday March 13, 2021 @06:54AM (#26445987)
Indeed, but the fearless concurrency sales pitch tends to overlook that.
Re:Speed of Rust vs. C by trunnell on Saturday March 13, 2021 @12:20PM (#26448019)
It’s hard to see how you could be arguing in good faith given that your point of “fearless concurrency” being an overstated “sales pitch” has now been answered with multiple substantive answers.

Please stop moving the goal posts from “program concurrency” to “distributed or multi-process transactions.” It subtracts from the conversation.

Rust is honest about what it does and doesn’t do.

Re:Speed of Rust vs. C by pjmlp on Sunday March 14, 2021 @10:43AM (#26455825)
Rust is honest, https://doc.rust-lang.org/nomicon/races.html

I am not moving goal posts, rather talking about issues that many apparently lack the knowledge to understand how many variants of data races exist in an application.

Quite understanable given the majority of developers that keep writing single threaded applications.

Re:Speed of Rust vs. C by ben0x539 on Saturday March 13, 2021 @08:16AM (#26446342)
The fearless concurrency sales pitch doesn't overpromise. You're trying to stretch it, but it's pretty clear on what kind of concurrency issues it covers (eg. data races).
Re:Speed of Rust vs. C by hderms on Saturday March 13, 2021 @08:52AM (#26446551)
Yeah it would be a grave misinterpretation of "fearless concurrency" to think Rust somehow validates that access to some shared resource with it's own semantics is also safe. I'm not educated on the subject but that problem seems pretty intractable for a language to solve in a general sense.
Re:Speed of Rust vs. C by pjmlp on Saturday March 13, 2021 @12:30PM (#26448125)
Indeed, yet that is not how many Rust advocacy blog posts sell it.
Re:Speed of Rust vs. C by shakow on Sunday March 14, 2021 @07:09AM (#26454360)
Such as?
Re:Speed of Rust vs. C by pjmlp on Sunday March 14, 2021 @10:48AM (#26455858)
Any blog post that gives examples accessing shared variables and never goes beyond anything else, leaving to the reader that it works the same way regardless of what resources are being accessed.

https://blog.knoldus.com/how-we-can-do-fearless-concurrency-...

Now rewrite the same blog post using SQL queries to update the same counter variable on a table row.

The Rustonomicon is quite clear that it wouldn't work,

> However Rust does not prevent general race conditions.

https://doc.rust-lang.org/nomicon/races.html

Re:Speed of Rust vs. C by shakow on Sunday March 14, 2021 @12:13PM (#26456482)
You really had to dig a post that has less text than code?

> leaving to the reader that it works the same way regardless of what resources are being accessed.

If that's how readers envision that non-language-managed resources work, they should go back to CS102 right now.

And concerning the nomicon, it explicitly states that Rust can't handle all races condition, I don't get your point.