TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Thoughts on immutability in programming languages?

2 点作者 diegojromero将近 4 年前
I have developed a proof-of-concept Python package to freeze objects [1]<p>I&#x27;ve developed it for the fun of doing it, without any useful use-case in mind, and to tell you all the truth, I can&#x27;t find any. I have some idea of what a functional language is (have developed a bit with Haskell and Erlang), but I&#x27;ve not used them in any job. I suppose that&#x27;s why I can&#x27;t find a way to use this package to solve any real issue.<p>What are some sources to learn about immutability on programing languages? How could you use a freeze package in Python or other languages? Would it be useful to share information between threads?<p>Any advice&#x2F;idea&#x2F;feeback&#x2F;criticism or comment on this matter is appreciated.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;diegojromerolopez&#x2F;gelidum" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;diegojromerolopez&#x2F;gelidum</a>

1 comment

aszen将近 4 年前
I think immutability isn&#x27;t really a feature with use cases.<p>It&#x27;s a way of programming without modifying data structures in place&#x2F;in memory. It&#x27;s also enables us to retain old values by generating new ones without modifying them. To learn the value of immutability, I suggest watch rich hickeys talk titled &quot;The value of values&quot;.<p>Coming back to freezing a python object, the most obvious way to use that is to ensure that the object isn&#x27;t modified by another function when passing it around, this may not seem like a feature at small scale but when working it large code bases it absolutely is.<p>Immutability&#x27;s main feature is that it makes concurrency easier, if you have some data that&#x27;s immutable, you can share it freely and everyone can read from it and is guaranteed to get a consistent view of the data without placing any locks or synchronisation.
评论 #27505303 未加载
评论 #27504168 未加载