#immutability

JavaScriptBuzzJavaScriptBuzz
2026-01-04

Object.freeze Is SHALLOW?!

Object.freeze LIES about immutability! It only freezes the top level. Nested objects are STILL mutable! This shallow freeze will cause bugs!

.freeze

youtube.com/watch?v=79-55kxm-FA

2025-12-22

Wenn du in Java programmierst, wirst du früher oder später auf den Begriff Immutability stoßen. Wörtlich übersetzt bedeutet das „Unveränderlichkeit“. Eine *immutable* Klasse ist also eine Klasse, deren Objekte nach ihrer Erstellung nicht mehr verändert werden können.

magicmarcy.de/immutability-–-w

#Immutable #Immutability #Unveränderlichkeit #thread-safe #Mutable #Synchronisierung #Stabilität #Programming #Java

2025-12-03

is #vicissitude the opposite of #immutability?

2025-11-18

Any TypeScript experts know how to make the language immutable by default? I got it working for Array and Record, but not plain objects... evanhahn.com/typescript-immuta

#TypeScript #JavaScript #types #immutability

2025-11-11

Monotonic Collections: a middle ground between immutable and fully mutable

This post covers several topics around collections (sets, lists, maps/dictionaries, queues, etc) that I’d like to see someone explore more fully. To my knowledge, there are many alternative collection libraries for Java and for many other languages, but I’m not aware of any that provide support for monotonic collections. What is a monotonic collection, I hear you ask? Well, I’m about to answer that. Jesus, give me a moment.

It’s become popular, in the JVM ecosystem at least, for collections libraries to provide parallel class hierarchies for mutable and immutable collections: Set vs MutableSet, List vs MutableList, etc. I think this probably originated with Scala, and has been copied by Kotlin, and various alternative collection libraries, e.g. Eclipse Collections, Guava, etc. There are plenty of articles out there on the benefits and drawbacks of each type. But the gulf between fully immutable and fully mutable objects is enormous: they are polar opposites, with wildly different properties, performance profiles, and gotchas. I’m interested in exploring the space between these two extremes. (Actually, I’m interested in someone else exploring it, hence this post). One such point is the idea of monotonic collections, and I’ll now explain what that means.

By monotonic I mean here logical monotonicity: the idea that any information that is entailed by some set of logical formulas is also entailed by any superset of those formulas. For a collection data structure, I would formulate that as follows:

If any (non-negated) predicate is true of the collection at time t, then it is also true of the collection at any time t’ > t.

For example, if c is a collection and c.contains(x) returns true at some point in time, then it must always return true from then onwards.

To make this concrete, a MonotonicList (say) would have an append operation, but not insert, delete, or replace operations. More subtly, monotonic collections cannot have any aggregate operations: i.e., operations that report statistics/summary information on the collection as a whole. For example, you cannot have a size method, as the size will change as new items are added (and thus the predicate c.size() == n can become false). You can have (as I understand it) map and filter operations, but not a reduce/fold.

So why are monotonic collections an important category to look at? Firstly, monotonic collections can have some of the same benefits as immutable data structures, such as simplified concurrency. Secondly, monotonic collections are interesting because they can be (relatively) easily made distributed, per the CALM principle: Consistency as Logical Monotonicity (insecure link, sorry). This says that monotonic collections are strongly eventually consistent without any need for coordination protocols. Providing such collections would thus somewhat simplify making distributed systems.

Class hierarchies and mutability

Interestingly, Kotlin decided to make their mutable collection classes sub-types of the immutable ones: MutableList is a sub-type of List, etc. (They also decided to make the arrows go the other way from normal in their inheritance diagram, crazy kids). This makes sense in one way: mutable structures offer more operations than immutable ones. But it seems backwards from my point of view: it says that all mutable collections are immutable, which is logically false. (But then they don’t include the word Immutable in the super types). It also means that consumers of a List can’t actually assume it is immutable: it may change underneath them. Guava seems to make the opposite decision: ImmutableList extends the built-in (mutable) List type, probably for convenience. Both options seem to have drawbacks.

I think the way to resolve this is to entirely separate the read-only view of a collection from the means to update it. On the view-side, we would have a class hierarchy consisting of ImmutableList, which inherits from MonotonicList, which inherits from the general List. On the mutation side, we’d have a ListAppender and ListUpdater classes, where the latter extends the former. Creating a mutable or monotonic list would return a pair of the read-only list view, and the mutator object, something like the following (pseudocode):

ImmutableList<T> list = ImmutableList.of(....); // normalPair<MonotonicList<T>, ListAppender<T>> mono = MonotonicList.of(...);Pair<List<T>, ListUpdater<T>> mut = List.of(...);

The type hierarchies would look something like the following:

interface List<E> {    void forEach(Consumer<E> action);    ImmutableList<E> snapshot();}interface MonotonicList<E> extends List<E> {    boolean contains(E element);    // Positive version of isEmpty():    boolean containsAnything();     <T> MonotonicList<T> map(Function<E, T> f);    MonotonicList<E> filter(Predicate<E> p);}interface ImmutableList<E> extends MonotonicList<E> {    int size();    <T> T reduce(BiFunction<E, T, T> f, T initial);}interface ListAppender<E> {    void append(E element);}interface ListUpdater<E> extends ListAppender<E> {    E remove(int index);    E replace(int index, E newValue);    void insert(int index, E newValue);}

This seems to satisfy allowing the natural sub-type relationships between types on both sides of the divide. It’s a sort of CQRS at the level of data structures, but it seems to solve the issue that the inheritance direction for read-only consumers is the inverse of the natural hierarchy for mutating producers. (This has a relationship to covariant/contravariant subtypes, but I’m buggered if I’m looking that stuff up again on my free time).

Anyway, these thoughts are obviously pretty rough, but maybe some inklings of ideas if anyone is looking for an interesting project to work on.

#dataStructures #FunctionalProgramming #immutability #Java #programming

Akseli :quake_verified:​ :kde:aks@scalie.zone
2025-11-04

I'm now convinced immutable/atomic distros do not remove ability to tinker. They just make it safer: Overlay your changes on top of the base. Something goes wrong, remove the overlay, try again!

Edit: I'm not saying everyone should use one, but for my use this is really good.

#Linux #Immutability

Akseli :quake_verified:​ :kde:aks@scalie.zone
2025-11-04

KDE Linux has been really great experience. I don't have to spend time building everything, resetting my dev session is literally just deleting one folder.. Really nice.

The only downside is having to fiddle with distrobox to get more CLI tools. Then again, it's not that bad. Some tools I have to download as a binary release directly though.

But for regular non-dev user that wont be a thing, unless you need some software not in Flathub.

I adapted to the immutability workflow rather well, and systemd-sysext is so great for Plasma development. It all Just Works.

Can recommend it for anyone interested, though it's still very much in development. But if you're adventurous or want to start contributing to KDE, it's good times.

#KDE #Linux #Immutability

Roy Charlesroycharles
2025-10-16

Immutable Linux delivers serious security - here are your 5 best options | ZDNET share.google/n3DoKFpVWFgDFD6yM

卡拉今天看了什麼ai_workspace@social.mikala.one
2025-09-04

Poor man's bitemporal data system in SQLite and Clojure | Hacker News

Link
Poor man's bitemporal data system in SQLite and Clojure
https://news.ycombinator.com/item?id=37705376

📌 Summary:
本文以作者個人開發經驗為背景,深入剖析使用 SQLite 與 Clojure 建立一套「窮人的雙時態(bitemporal)」資料庫系統。文章首重說明雙時態資料系統如何記錄「事實發生時間(valid time)」與「記錄交易時間(transaction time)」,且所有資料皆不可更改,只能附加新事實,確保完整的歷史追蹤與溯源能力。作者舉例以零售業結帳糾紛更正帳單過程,形象說明雙時態資料庫如何對於任何時刻的狀態進行查詢與還原。文中亦比較其他專業時態資料庫,如 Datomic、XTDB、Rama,並強調自己方案以 SQLite 為底、簡約且免除複雜分散式問題,契合獨立軟體開發者低成本架構。全文深入探討資料庫設計哲學,包括不可變性、冪等性、時間解析度、命名空間與使用者驗證等技術細節,以及如何利用 Clojure 的功能如 Specter API 實現查詢與視圖生成。文章底層核心理念是複雜性不可避免,透過垂直整合且可理解的單機架構,達成易於維護與擴充的獨立 SaaS 系統,並強調資料主權、在地化合規與系統可完全復原的重要性。

🎯 Key Points:
→ 【雙時態基礎概念】
★ 雙時態資料庫記錄兩種時間屬性:事件真實發生時間(valid time)與資料記錄時間(transaction time)。
★ 不修改舊紀錄,透過新增反向操作(如撤銷交易)及修正交易,保留完整時間序列。
★ 以 Entity-Attribute-Value (EAV) 與「assertion」方式,清楚表達某事實為真或假,支援多版本事實並透過「valid_preferred」欄位決定優先事實。

→ 【技術實作細節】
★ 建立嚴格命名空間規則管理 namespaces、users、entities,確保資料唯一與安全。
★ 利用 SQLite 的 WAL 模式實現單序列寫入、多讀者非阻塞架構,模擬 Datomic 單機版效能。
★ 使用 Honey SQL 以 Clojure 程式碼生成 SQL,增強 SQL 可組合性與維護性。
★ 視圖(views)用 Clojure 應用程式端實作(如 Specter API),避免 SQL 複雜查詢與索引失效問題,並用 FTS5 支援全文檢索。
★ 不支援寫入併發,以簡化系統,採用 Append-only(不可變)與冪等操作設計。

→ 【架構與營運策略】
★ 垂直整合架構-單臺伺服器包含應用、資料庫、快取等,便於部署與維護。
★ 採單租戶資料庫設計以因應合規且方便水平擴展。
★ 採用 UUIDv7 兼顧時間順序與全域唯一,作為交易 ID,便利版本管理與衝突解決。
★ 強調系統簡潔、易於理解,適合獨立開發者與小型 SaaS,避免雲端廠商鎖頭與過度複雜技術負擔。
★ 支持資料隨需匯出,確保資料主權與符合資料保護法規。

🔖 Keywords:
#雙時態資料庫 #SQLite #Clojure #Entity_Attribute_Value #垂直整合
#bitemporal_database #append_only #immutability #transaction_time #valid_time

Value semantics at scale with #Cpp github.com/arximboldi/i... #rustlang equivalent github.com/orium/rpds should not be too difficult to make #RStats bindings of any of the two #immutability #headerOnly #Cpp14

GitHub - arximboldi/immer: Pos...

Value semantics at scale with #Cpp
github.com/arximboldi/immer

#rustlang equivalent github.com/orium/rpds

should not be too difficult to make #RStats bindings of any of the two
#immutability #headerOnly #Cpp14

2025-07-23

✨ Update deeply nested data structures immutably in Java without drowning in boilerplate using higher-kinded-j and functional Optics.

🔍 Traverse complex records with Lenses, Traversals, and Prisms, all type-safe, compile-time generated, and fully immutable.

Full example: higher-kinded-j.github.io/opti
Explore more: higher-kinded-j.github.io/

#Java #FunctionalProgramming #Optics #Immutability #HKTs

Mohsen Mirhoseini 🍀🤖👨‍💻mohsenoid@androiddev.social
2025-01-13

🚀 New Video Alert! 🚀

Dive into the world of #FunctionalProgramming in #Kotlin and discover how it can elevate your #AndroidDev skills! 📱💡

Master functional programming and build better software! 🌟

#ADT #Immutability #YouTube #Android

youtu.be/LMGSapTmoiw

2024-07-07

Embracing Functional Programming in C# - CodeProject

An exploration of the benefits of **functional programming in C#**. The article covers code readability, efficiency, and unit testing. Other highlights are the challenges of state mutation, the importance of immutability, and the concept of pure functions.

#FunctionalProgramming #CSharp #CodeReadability #Immutability #PureFunctions #ErrorHandling #Programming

codeproject.com/Articles/53767

Karl Voit :emacs: :orgmode:publicvoit@graz.social
2024-07-03

@kaito02 Well, I try to get rid of #NixOS as soon as possible because of the large number of flaws it has according to my use-cases and my perspective. (WIll blog about it.)

However, this image contains just bullshit arguments.

For example, what entity defines what #filenames should contain and what not? 🤔

#Immutability has clear advantages for security reasons alone. (Not that I'd invest the additional effort here.)

"They have played us for absolute fools" -> who forced you to setup Nix?

Puneet Behlbehlp@jvm.social
2024-06-04

Interested in transforming your coding practices? Explore the world of #FunctionalProgramming to see how #purity, #immutability, and #modularity can lead to cleaner, more predictable, and maintainable code. My latest blog highlights the advantages and practical uses of Functional Programming in Java. Check it out and share your thoughts: link.medium.com/WX6cvXHC9Jb

#SoftwareDevelopment #FunctionalProgramming #CleanCode #Java #ProgrammingInsights #TechCommunity #CodeQuality

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst