Skip to content

Instantly share code, notes, and snippets.

@michaelfairley
Created October 31, 2012 03:12
Show Gist options
  • Save michaelfairley/3984586 to your computer and use it in GitHub Desktop.
Save michaelfairley/3984586 to your computer and use it in GitHub Desktop.
Immutable Ruby (Brit Ruby)

Immutable Ruby

Most Ruby code makes heavy use of mutable state, which often contributes to long term maintenance problems. Mutability can lead to code that's difficult to understand, libraries and applications that aren't thread-safe, and tests that are slow and brittle. Immutability, on the other hand, can make code easy to reason about, safe to use in multi-threaded environments, and simple to test. Doesn't that sound nice?

This talk answers the question "why immutability?", covers the building blocks of immutable code, such as value objects and persistent data structures, as well as higher order concepts that make heavy use of immutability, such as event sourcing and pure functions, and finally discusses the tradeoffs involved in going immutable.

Michael Fairley

Michael Fairley is a developer at Braintree Payments, where he uses Ruby to make it easy for businesses around the world (including the UK!) to accept credit card payments online. He’s an active open source contributor, and maintains a handful of side projects including mincemeat.py and bestintrobook.com.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment