

Your Thoughts About Immutable Data
source link: https://www.tuicool.com/articles/hit/AZviAfI
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

This week 8 devs made 14 comments about immutable data. Big thanks to all of you!
My Impression
In general, you favored immutability over mutations and I was the sole 'antagonist' of the thread. There were two distinct uses cases mentioned.
Some of you wrote about immutability as a way of thinking and building whole apps. Unsurprisingly, these comments leaned towards functional programming and mentioned clear data flow and increased code quality as benefits in exchange for added complexity . A commenter quite nicely described these apps as 'data flowing through a pipe of transformations' and mentioned that badly implementing this model can make things unnecessarily complex.
I have to agree with this, embracing this mindset is not an easy task. Don't give up or judge early if it seems messy on the first try, but keep trying until it makes sense.
Others brought up stories where locally applied immutability helped them. In these cases, immutability fixed issues with unexpected mutations of long living objects. My favorite example was a story of mutating events, which the event bus reused later without mentioning this in the docs. Moral of the story: you never know who else keeps references to your objects, always be suspicious towards third-party libs if you work with mutable data.
On the practical side, you mentioned testing, memoization, and time travel as areas where immutability really shines.
As the contra team, I mentioned the strictness as the biggest turn-off. I like to 'hack around' and I usually feel bad when I am forced into a set of best practices . The example I gave was about a (mutable) state management lib that I maintain. A big chunk of the issues are about very basic operations - like getting / settings values or applying (async) side effect. I always explain to simply use obj.prop
, obj.prop = value
, and async functions which the issuers are already familiar with. They are too afraid to even try them though because of their functional background.
Ultimately I think all of the comments were high quality and constructive. I was also hoping for some junior opinions though. Your comments matter, don't be afraid to express your initial thoughts, ideas, enthusiasm, or frustration.
About the Future
This was the first post of the series and I realized I will have to change a few things:
-
I tried to avoid direct quoting in this summary but feel free to PM me if I should remove something. Next week I will add a disclaimer about the possibility of linking / quoting comments. I will never quote anybody in a negative context.
-
In the future, I will bring up topics on Mondays and write summaries on Fridays. Sorry for the short commenting window this week.
Next week's topic will be types . See you on Monday!
Recommend
-
34
Recently I have been learning some Functional Programming using JavaScript. I started to really like Functional Programming due to the elegance of functi...
-
22
Shared state is easy to understand and use, but can lead to subtle bugs that are extremely hard t...
-
18
Immutable data constructs are those that cannot be mutated (altered) after they've been initialized. The Dart language is full of these. In fact, most basic variable types operate this way....
-
17
DO Principle #3: Data is immutable Oct 2, 2020 • Yehonathan Sharvit This article is an excerpt from my upcoming book about Data Oriented Programming...
-
11
ASP.NET Core 5: Make your options immutable 2020-08-19 by anthonygiretti Introduction If you’ve been us...
-
6
How Immutable Data Can Make Your Ionic Apps FasterIf you are not already using immutable data concepts, you might have seen all the cool kids updating their arrays like this: public myArray: number[] = [1,2,3]; ngOnInit()...
-
5
27 June 2015 Immutable Data In this article I’ll be talking about the advantages and disadvantages of immutable data in databases. As a demonstration I’ll walk through a simple blog application in PostgreSQL. I highly recom...
-
6
Using Immutable Storage to Protect Data Against RansomwareNotifications💰 144k+ in Contest Prizes Year to Date! Join now!Last Tuesday at 1:33 PM🆕 TOP 12 Product Featur...
-
12
Revolutionizing Data Accountability Through Immutable Tracking Data producers and consumers need to understand and control their usage of said data, especially in the finance and entertainment industries...
-
2
Lenses for Immutable DataLenses for Immutable DataPublished on 20 January 2023Last time we talked about isomorphisms and I mentioned at the end of the
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK