Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Indeed. That may mean fewer opportunities for "meta-programming" if by meta-programming we mean mutation of core structures. It could also be a good chance to turn around the default of declaring variables to declaring constants instead. Complex data structures would still have to be mutable by default I guess, but they would be the obvious next target to becoming immutable by default.


Why would your complex data structures be mutable? Wouldn't immutability pay off especially in complex cases?


If you make my huge NumPy arrays immutable, I will be very unhappy (unless I am significantly misunderstanding how this everything-is-immutable strategy works).

There might be a lot to be said for rust-style immutable-by-default.


First, you'd still have optional mutability. Second, arrays are rather simple data structures, but ones where you often care about performance--small tight loops are common. Compare that to the data structure that eg holding your options and flags for the computation: you don't do much computation on that, but you have lots of invariants that you want to uphold---ie lots of code, but each bit executed roughly once, no tight loops.


I assume using some form of copy-on-write.


Algorithms on immutable data structures tend to have very bad worst case peformance.


Naïve algorithms on immutable data structurs tend to have very bad worst case performance.


And there would always be the optional mutability. Your complex data structures are seldom the ones driving performance.

Ie often you have to get the complex data structures right (lots of logic, not much computation) to set up your computations on the simple ones (eg lots of number crunching on your arrays).


Yes, it's easier to reason about correctness in immutability land and add mutability in after the fact as a compiler optimization than to remove mutability for safety as a compiler pass.


Haskell sort-of does this. Laziness can be seen as a very disciplined form of mutability.

(Haskell also allows mutability that is visible to the semantics of the program, that's where the famous monads come in.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: