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

КОМЕНТАРІ • 27

  • @kevinkkirimii
    @kevinkkirimii 27 днів тому +17

    I find GO wait groups syntax very straight forward especially coming from Java.

  • @josephcopenhaver6604
    @josephcopenhaver6604 28 днів тому +24

    9:20 to 9:51 appeared blank (black screen) and silent for some reason.

    • @Rogueixpresents
      @Rogueixpresents 27 днів тому +18

      segmentation fault there

    • @KX36
      @KX36 22 дні тому +1

      deadlocked.

  • @kamertonaudiophileplayer847
    @kamertonaudiophileplayer847 24 дні тому +1

    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.

  • @miriamramstudio3982
    @miriamramstudio3982 25 днів тому +2

    Great video. Thanks.

    • @ardanlabs
      @ardanlabs  25 днів тому +1

      We're glad you liked it!

  • @felixinit
    @felixinit 24 дні тому

    I tried, but it is advanced for me at this point. Looks relly interesting. Definitivamente lo revisaré más adelante en mi desarrollo profesional.

  • @kamertonaudiophileplayer847
    @kamertonaudiophileplayer847 24 дні тому +1

    Do not forget that you can use volatile stead of Mutex in C++.

    • @mk72v2oq
      @mk72v2oq 24 дні тому +7

      No you can't. Volatile has nothing to do with synchronization and you will get the same inconsistent results.

    • @kamertonaudiophileplayer847
      @kamertonaudiophileplayer847 24 дні тому

      @@mk72v2oq Strange, what's purpose of volatile then? I use it widely in a multithreading programming, and you ruined my career.

    • @yurcchello
      @yurcchello 23 дні тому

      @@mk72v2oq why not? for primitive data types volatile must be enough

    • @maxbd2618
      @maxbd2618 23 дні тому +3

      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

    • @mk72v2oq
      @mk72v2oq 23 дні тому +2

      @@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.

  • @KhaledKimboo4
    @KhaledKimboo4 25 днів тому +12

    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.

    • @andreiterec7606
      @andreiterec7606 24 дні тому +5

      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

    • @KhaledKimboo4
      @KhaledKimboo4 24 дні тому +3

      @@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

    • @aGFteg
      @aGFteg 24 дні тому +16

      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)

    • @maxbd2618
      @maxbd2618 23 дні тому +1

      ong you won't catch me explicitly creating a mutex in C++ and forgetting to use it

    • @lufenmartofilia5804
      @lufenmartofilia5804 23 дні тому

      chamomile my friend. C.H.A.M.O.M.I.L.E 😅

  • @awksedgreep
    @awksedgreep 24 дні тому +4

    There’s nothing better than concurrency in OTP/Erlang/Elixir.