TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Immutable data structures for the back end?

3 pointsby uptownhralmost 9 years ago
Immutable data structures are being adopted on the frontend with frameworks like redux. Can this same concept be applied to the server? An express like framework that works with immutable state?

7 comments

bbcbasicalmost 9 years ago
Well it is trite to say it but Haskell has many examples of servers and idiomatic haskell will almost always use immutable data. Examples are web frameworks like Yesod and web servers like Warp.<p>I&#x27;m working on a toy stock exchange app to learn haskell and of course it will be mostly immutable. It will use some shared global state. This will have mutable reference using mvars or transactional memory but the &quot;objects&quot; themselves will be immutable.<p>Communicating between threads makes total immutability hard (maybe impossible?) unless you have a very clever threading model.
armsalmost 9 years ago
Sure they can. You can use server side languages like Clojure, Erlang, Elixir, F# and a few others I&#x27;m sure I&#x27;m missing.<p>There also exist libraries for some languages that introduce immutable data structures, like pysistance for Python.
hakanderyalalmost 9 years ago
You can check out Datomic[0], a database built on immutability, championed by Rick Hickey of Clojure.<p>[0]: <a href="http:&#x2F;&#x2F;www.datomic.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.datomic.com&#x2F;</a>
gary__almost 9 years ago
See the event sourcing pattern for an example of immutability at the backend.<p><a href="http:&#x2F;&#x2F;martinfowler.com&#x2F;eaaDev&#x2F;EventSourcing.html" rel="nofollow">http:&#x2F;&#x2F;martinfowler.com&#x2F;eaaDev&#x2F;EventSourcing.html</a><p><a href="https:&#x2F;&#x2F;msdn.microsoft.com&#x2F;en-us&#x2F;library&#x2F;dn589792.aspx" rel="nofollow">https:&#x2F;&#x2F;msdn.microsoft.com&#x2F;en-us&#x2F;library&#x2F;dn589792.aspx</a>
_RPMalmost 9 years ago
Did you just learn about the concept of Immutable? It&#x27;s a very simple concept, it seems to be the buzzword lately, especially with JavaScript libraries.
uptownhralmost 9 years ago
Are there any examples of this being done?
galistocaalmost 9 years ago
What do you think would be the benefit?