Exploring Concurrency Pitfalls: Rust vs. C++ and Go
Вставка
- Опубліковано 16 тра 2024
- Welcome to the Rust: Safe at Any Speed series, Episode 6! A series of short videos on Rust and its diverse advantages when it comes to speed and security. Watch now to learn about Memory Safety, Avoiding Vulnerabilities with Clear Intent, and Data Races, and how Rust keeps your data safe!
In this episode, we explore data races in concurrent programming, comparing Rust's approach with C++ and Go. We demonstrate the chaos data races can cause and how Rust's compiler prevents them. We delve into Rust's atomic operations, mutexes, and interior mutability, showcasing their effectiveness in concurrent programming. Additionally, we highlight Rust's avoidance of null pointers, error handling mechanisms, and strict aliasing rules. Despite its imperfections, Rust's safety features make it a valuable tool for building reliable systems.
Whether you're a seasoned developer or just starting your journey, this episode offers invaluable insights into mastering memory safety and building reliable software systems. Tune in now to embark on a journey toward safer and more efficient programming practices!
Things you will learn in this video:
- The significance of understanding data races in concurrent programming.
- Demonstrations of chaos caused by data races and how Rust's compiler prevents them.
- Rust's avoidance of null pointers and its error handling mechanisms.
----
The clips from this series are from our October 2024 UA-cam Live-Stream, 'Rust: Safe At Any Speed', with instructor Herbert Wolverson.
----
What are your thoughts on Rust's approach to concurrency and memory safety compared to other languages you've used?
Share your experiences and solutions in the comments below!
Comment below or tweet us on twitter & let us know your thoughts, we want to hear from you! ~ If you found this video helpful, hit that like button & subscribe for more content like this.
----
Access our online courses → www.ardanlabs.com/education/
Attending a live training → www.ardanlabs.com/live-traini...
Other Links:
Website: www.ardanlabs.com/
Github: github.com/ardanlabs
Twitter: / ardanlabs
#rust #rustprogramming #education #tutorials #tips
I find GO wait groups syntax very straight forward especially coming from Java.
9:20 to 9:51 appeared blank (black screen) and silent for some reason.
segmentation fault there
deadlocked.
Your video is a very on time. I just finished a blog exactly about the same problem in C++, Java and Rust. I am only learning Go, so you somewhere surpasses me.
Great video. Thanks.
We're glad you liked it!
I tried, but it is advanced for me at this point. Looks relly interesting. Definitivamente lo revisaré más adelante en mi desarrollo profesional.
Do not forget that you can use volatile stead of Mutex in C++.
No you can't. Volatile has nothing to do with synchronization and you will get the same inconsistent results.
@@mk72v2oq Strange, what's purpose of volatile then? I use it widely in a multithreading programming, and you ruined my career.
@@mk72v2oq why not? for primitive data types volatile must be enough
volatile is for like telling the compiler not to touch a particular variable that might change values and you don't want optimization to possibly interfere with it, its not related to thread safety at all im pretty sure
@@maxbd2618 yeah, it only tells the compiler not to put intermediate value into a CPU register and always fetch it from RAM. It could help in certain scenarios, but:
1. Volatile variables still use regular (non-atomic) instructions, which means that the concurrent access will likely bork it.
2. Volatile also doesn't prevent the value to be cached by CPU cores (private L1/L2 caches for each core), which completely throws away any possibility to use it for synchronization.
What a waist of time an entire video to show rust mutex wrapper that you can make even with python as if it's a hell of a feature of rust.
In Python, C++ and Go you still can access the data without locking the mutex, even with the wrapper. You can lock the mutex and store a pointer to the data and use it later without locking the mutex again.
You can't do that in safe rust
@@andreiterec7606 who cares, I want that freedom and responsibility, how does stuffing boilerplate code into std library constitute as a feature is beyond me. How hard is it for go team to deliver such wrapper in stdlib literally 1hour . I love rust and I dislike it's overly hyped community
This isn’t “just a wrapper” and can be done in Go in one hour. That’s an entire language design, it requires RAII which go doesn’t have. It requires explicit unboxing (or deref in rust). And more languages feature.
Let’s not disrespect Rust just because it’s getting hype (which after using multiple languages over the years, Rust deserves this hype)
ong you won't catch me explicitly creating a mutex in C++ and forgetting to use it
chamomile my friend. C.H.A.M.O.M.I.L.E 😅
There’s nothing better than concurrency in OTP/Erlang/Elixir.
true