M
M
msatersam112016-06-24 14:40:34
css
msatersam11, 2016-06-24 14:40:34

Why is Immutable good for js?

In present time, everywhere talks about the so-called immutability and how cool / cool / and how_we_lived_without_it_in general, arguments such as:
More scope for compiler optimization,
Simplification of life for tools for static code analysis,
Simplification of tracking changes in data structures ,
Avoiding many so-called side effects in functions,
(one of the main advantages) Non-blocking reading from different threads, etc.
But:
In JS, there is only one thread of execution.
Side effects!? Are they really fully solved by using .. immutable data?
A separate ambiguity arises about "optimization by the compiler": is it possible that some purely artificial idea, alien to the language in question, can contribute to some kind of optimization?
And all this would be more or less tolerable if the data were really immutable, but, albeit indirectly, they are subject to change (to the word about setIn in immutable).
Where does one big question come from: why come up with hemorrhoids unnatural for JS in the form of immutable data, drag a separate thick file into the project just for this, so that .. still change the data, but instead of economically changing one element, copy the entire array with .. every time. with a single changed element (or even one of its fields) and, it would seem, where does the saving of memory and computing power of the processor come from?
Why is immutability in JS so good that it justifies such a tangible overhead with rather vague positive features?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Michael, 2015-11-25
@scherbuk

habrahabr.ru/post/176591

L
Lenar Fattakhov, 2016-06-24
@fr_end

I thought the main plus is not in this, but in the fact that you can track the change in the object.
I liked the report on this topic https://www.youtube.com/watch?v=8BExyeds_c0

V
vsuhachev, 2016-06-24
@vsuhachev

You even listed all the reasons. That's what you need to do then. Or do you not trust compiler developers that their compilers will run faster with immutable data?
If you personally don't need it, don't use it, it's business :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question