Tero Parviainen
Profile_image?user_id=14157530&size=bigger
Ranked 14 in Phase 2 with a weighted final score of 221

Immutability in Ruby

What does the concept of immutable data mean from a Ruby programmer’s perspective? How is immutability supported in Ruby, and why should you care?

Immutable objects and data structures have existed for a long time, but in the last few years they have started getting more attention than ever before. Partly this is because of the movement towards concurrency and parallelism. That's a very good reason, but there's also a more fundamental one: In this talk we will see how using immutable data can actually make code more readable and easier to reason about. We will also see how immutability is the most natural way to deal with many kinds of data - much more than what we are used to doing in Ruby.

We'll discuss immutability the Ruby standard library, and which parts of it deal with mutation and which don't. We'll see how to become aware of operations that mutate objects in-place, and why the use of those should be minimised.

We'll also discuss object-oriented domain models, and how immutability shows up in them. Immutable values have been discussed in many of the most important OO design books throughout the years, but their use in the field has been nowhere as common as it could have. In Ruby classes mutability is always the default, and to achieve immutability we always have to do some work. We will see how to do this effectively.


Previous Next

Suggestions

  • D87dddeb300217e6c6574f5ffae220be?d=retro Nikos Dimitrakopoulos suggested 8 months ago

    @Nicolas you have some good points but not the whole audience will be composed from beginners.

    I'm totally interested in this topic, but indeed, providing some concrete examples with the direct benefits of immutability would be more than useful.

  • Ca1e596b035117dc7c41b1d99469fe91?d=retro Nicolas Mérouze suggested 8 months ago

    I like this topic but feel like your proposal is too much theory and not enough practical use. Will you show a real-world application using immutability in Ruby?

    You explain that immutability is getting more attention because of concurrency and parallelism. Maybe you could explain why because some people may not understand the relation you made (I'm thinking about beginners who can have a hard time understanding these concepts, especially if they began learning Ruby before any other language).