Hacker News new | ask | show | jobs
by studius 2011 days ago
const is really popular in JS... (i.e. could they surreptitiously be taking on Orinoco?)
1 comments

I don’t think const or non const is the main issue- some data structures just require cycles like graphs or circular linked lists.
I don't disagree, but I also suspect that a very large number of real world JavaScript applications have few to no application-induced cycles. I might even go further and say this extends beyond JavaScript--the most common reason I even define recursive data structures in a language like Rust is for AST-like data that almost invariably forms a tree.
I supposed you could construct as dynamic and then make it constant? I wonder why that feature isn't seen in common languages, even though I know it sounds crazy.
Clojure has transient mutable collections that are designed to become persistent once "complete". [1] Some systems have made use of using reference count of one (unique owner) as permission to mutate, something that TFA generalizes as memory reuse.

1: https://clojure.org/reference/transients