7
submitted 4 months ago by [email protected] to c/[email protected]
top 6 comments
sorted by: hot top controversial new old
[-] [email protected] 2 points 4 months ago
[-] [email protected] 2 points 4 months ago

haha it's definitely a very different way to think about computing :)

[-] [email protected] 2 points 4 months ago

Just tell me which is the most performant, while also being immutable.

[-] [email protected] 2 points 4 months ago

I would guess most of them would have roughly the same performance. Ultimately, it's just going to be O(n) iteration, and since it's generator it's not mutating anything. :)

[-] [email protected] 1 points 4 months ago

I've read about faux-mutability via use of monads to manage state. Obviously, being a Reddit post and not a well-written article, it does not go into depth about the topic. Would that be performant for a unstable-but-stable quick-sort operation?

[-] [email protected] 2 points 4 months ago

Monads are mostly a popular pattern in Haskell because encapsulating side effects within monads allows the type system to enforce their proper usage. They're not necessary for immutability or state management in general. It's just a way to enforce discipline more than anything.

The way immutability is implemented is using persistent data structures. The idea is that you do structural sharing for the common data when creating changes, so you don't have to pay the price of a full copy of the data structure. In terms of performance, this approach works pretty well in most cases. It's more expensive than direct mutation, but far cheaper than a deep copy making it a good compromise for the general case.

this post was submitted on 17 May 2024
7 points (88.9% liked)

Lisp Community

674 readers
1 users here now

A community for the Lisp family of programming languages.

Lisp (historically LISP) is a family of programming languages with a long history and a distinctive, fully parenthesized prefix notation. Originally specified in 1958, Lisp is the second-oldest high-level programming language. Only Fortran is older, by one year.

History

Associations and meetings

Resources - TODO

Related communities (dialects) - TODO

founded 5 years ago
MODERATORS