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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Understanding Clojure's Persistent Vectors (2013)

64 点作者 sendilkumarn超过 3 年前

4 条评论

gugagore超过 3 年前
Persistent data structures are, in my opinion, underrated. Not so much for every day programming tasks, but specifically for code that resembles planning&#x2F;searching.<p>Here is one library I&#x27;ve heard of <a href="https:&#x2F;&#x2F;immutable-js.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;immutable-js.com&#x2F;</a> . I don&#x27;t know of others.
评论 #29506748 未加载
评论 #29497953 未加载
评论 #29496148 未加载
roenxi超过 3 年前
Clojure is a language that really puts the &quot;high&quot; in high level. It is quite difficult to trace a Clojure expression back to what will happen on the CPU - and the innovations on things like vector storage are part of that.<p>It was a bold decision with the potential to cause pain, but Clojure&#x27;s vectors are great fun to work with. The &quot;novel&quot; basic data structures get out of the way and generally cause more joy than pain. It is part of a fundamental strategy enabling a strongly immutable style which really pays off when it works in concert with the rest of the language.
tomp超过 3 年前
I just spent the last few days implementing a better version of an &quot;persistent list&quot; data structure (heavily modelled on Clojure&#x27;s vector) for a new programming language that I&#x27;m working on.<p>I did a quick survey of existing implementations in multiple languages and found all of them lacking. They are either overly complex, slow, or both. Even Clojure&#x27;s vector, while being simple and very performant, is only usable as a stack, not as a queue, and therefore IMO inadequate as a &quot;generic random-access array-like data structure&quot; (akin to Python&#x27;s list, i.e. &quot;just use it don&#x27;t worry about performance&quot;).<p>My version is about as fast as Clojure&#x27;s vector, while implementing a &quot;deque&quot;-like interface. It&#x27;s a bit more complex, but still significantly simpler than Scala&#x27;s vectors (both Scala 2 and Scala 3). Cyclops (a Java-only persistent collection library) is so slow I didn&#x27;t even bother finishing the benchmarks. I also compared my code to Rust&#x27;s `im` (way more complex), C++&#x27;s `immer` (stack, not deque) and `immutable.js` (slower than ClojureScript).<p>I&#x27;ll clean up the code and post it here.
评论 #29497728 未加载
评论 #29498266 未加载
PMunch超过 3 年前
Great series of articles. I used this to write a persistent vector library in Nim: <a href="https:&#x2F;&#x2F;github.com&#x2F;PMunch&#x2F;nim-persistent-vector" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;PMunch&#x2F;nim-persistent-vector</a>