←back to thread

205 points michidk | 2 comments | | HN request time: 0.013s | source
Show context
nsoonhui ◴[] No.41835659[source]
I'm ignorant about Rust, but to me it's just static type language akin to C#. And C# has IOT library which seems to target Rust most usual use case, namely on embedded platform. C# also has memory safety just like Rust.

So why do we need Rust at all? What's the use case for it?

Anything that I'm missing?

replies(5): >>41835666 #>>41835762 #>>41836656 #>>41839000 #>>41843390 #
lionkor ◴[] No.41836656[source]
You're missing that Rust has safety in terms of multithreading, which C# doesn't have. Writing a data race in C# is the default, writing thread safe code takes work. In Rust, the default is that it's safe, you have to jump through a lot of hoops to try to make it not thread safe. The same is true for async, which in C# is also a problem.

In all C# codebases I've seen, you have threads and tasks, and you often run into multiple threads or tasks holding a mutable reference to the same data. That's not legal in Rust without synchronization/locking.

If you don't believe me, just spin up a new main.rs file and write code that has a data race.

replies(2): >>41838790 #>>41839112 #
1. throwawaymaths ◴[] No.41839112[source]
Easy. Decide to use an ecs system because of its lower memory footprint. Pass around integer indices. Use two threads. Data race.
replies(1): >>41847247 #
2. lionkor ◴[] No.41847247[source]
That seems like a lot more effort than in C#