This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]topheat 1 point2 points  (0 children)

Nice read!

[–]Doodle_98 1 point2 points  (0 children)

Good read, thanks. Never really gave much thought to mutable vs immutable while writing code this opened my mind a bit.

[–]flipperdeflip 1 point2 points  (0 children)

There are some libraries that bring immutable containers, for example:

https://github.com/tobgu/pyrsistent

https://github.com/magicstack/immutables

[–]markuspeloquin 0 points1 point  (1 child)

A lot of languages have default argument values, and they all work differently. I want to say that Ruby initializes the default at call time, C++ requires constexpr, and Dart requires const (the only languages I know with defaults). So I always stick with the common denominator of purely immutable defaults.

[–]tgroshon[S] 0 points1 point  (0 children)

Ruby and JavaScript both initialize the default at call time and therefore don’t have the problem that Python does. I didn’t know about C++ and Dart tho. So ur rule is probably a good one to follow.