Immutable Data Structures in C++ - Alistair Fisher - ACCU 2024

Поділитися
Вставка
  • Опубліковано 12 вер 2024
  • ACCU Membership: tinyurl.com/yd...
    ---
    Immutable Data Structures in C++ - Alistair Fisher - ACCU 2024
    ---
    Immutability remains one of the great dividing lines between procedural languages like C and C++, and functional languages like Haskell and Clojure. While many other traditionally functional features -- such as higher order functions, lambda expressions, and lazy evaluation -- have made their way into C++ over the past decade, mutability remains at the core of the language.
    This talk aims to offer a fresh perspective. Immutable data structures offer a solution to a challenge many developers face every day -- safety in a multithreaded environment. Unlike other data containers, they are thread safe by design and allow processes to be optimised through the sharing of data, with no risk to one another. They also make it easier to reason about and debug code, as the state of the program and its environment at each stage is persisted.
    After discussing the unique value that these data structures can bring, we will turn to the traditional drawback of immutable data -- performance. We will examine some of the modern data structures developed for other programming languages, such as Clojure’s persistent vectors, and learn how these challenges can be overcome, sometimes to the point where what once was a weakness becomes a strength.
    Sponsored By think-cell & Bloomberg Engineering
    ---
    Alistair Fisher
    Alistair Fisher is a Team Leader at Bloomberg. He works in the Multi-Asset Risk System (MARS) Pricing group in London, where he is focused on building scalable and reliable components for portfolio pricing and risk analysis. He is interested in the use of functional programming techniques for writing simpler and safer software. Prior to joining Bloomberg, he completed a master's degree at the University of Cambridge.
    ---
    The ACCU Conference is the annual conference of the ACCU membership, but is open to any and all who wish to attend. The tagline for the ACCU is 'Professionalism in Programming', which captures the whole spectrum of programming languages, tools, techniques and processes involved in advancing our craft. While there remains a core of C and C++ - with many members participating in respective ISO standards bodies - the conference, like the organisation, embraces other language ecosystems and you should expect to see sessions on C#, D, F#, Go, Javascript, Haskell, Java, Kotlin, Lisp, Python, Ruby, Rust, Swift and more.The ACCU Conference is a conference by programmers for programmers about programming.
    Discounted rates for members.
    ACCU Membership: tinyurl.com/yd...
    2024 Program: accu.org/conf-...
    accu.org
    www.accuconfer...
    mastodon.socia...
    / accu-conference
    bsky.app/profi...
    / accuorg
    / accuconf
    ---
    UA-cam Videos Filmed, Edited & Optimised by Digital Medium: events.digital...
    #accuconf #cppprogramming #datastructures #cplusplus #cpp

КОМЕНТАРІ • 10

  • @stefanbruns6209
    @stefanbruns6209 29 днів тому +2

    Using value semantics for the vector is also not thread safe (trivailly) - when you call the function, the original vector is copied, and that itself is not thread safe. For thread safety, you have to either make the data is either exclusive to a thread (e.g. by wrapping it into a unique_ptr from the beginning), or making it const at construction time, or make any accessors thread safe (e.g. by using a mutex).

  • @_noisecode
    @_noisecode 6 днів тому

    Really enjoyable talk and a great speaker. The insight that const& has value semantics is powerful and it’s at the core of many optimization tricks that make the world go round (copy on write is another example).

  • @surters
    @surters 29 днів тому

    Now you have to do ref counting unless you only do a some limited stuff or you will run out of memory.

  • @sanjaygatne1424
    @sanjaygatne1424 29 днів тому

    Nice talk.

  • @tomkirbygreen
    @tomkirbygreen Місяць тому

    Cracking presentation. Thank you.

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

    What about std::deque?

  • @alexpyattaev
    @alexpyattaev 29 днів тому

    Is there a bug in the example shown at ua-cam.com/video/v6djyBvfmJM/v-deo.html ? It seems that indexing into appendFrom is actually incorrect, there should be just push_back(i) instead.

    • @Roibarkan
      @Roibarkan 14 днів тому +1

      11:34 Yeah, Alistair probably meant: appendTo.push_back(*i);

  • @christianjensen7699
    @christianjensen7699 28 днів тому +2

    I know it wasn't the point of the talk, but almost all of this is solved by Rust's borrow checker. Rust annoys me in a bunch of ways, but it has its merits

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

      The borrow checker isn't a complete solution either. It's just another point along the line of tradeoffs. Sure it lets you keep performance and safety, but at the price of disallowing many correct and safe operations as well.