functional programming - Pros. / Cons. of Immutability vs. Mutability -
Well, I think this direction is clear, about which I am trying to reason on this. Whenever possible, there are many things about Constantes in these days, concurrent programming in the Java book says a lot about it.
However, all this is what I have read. I am not personally coded in functional languages, personally. And it seems very surprising to me that it is possible to work comfortably with irreversible things. Theoretically, this is definitely possible. But, from a practical perspective, there is a very comfortable experience. Or what should I develop for a new type of argument (FP) so that I do not need such a change?
I appreciate that when you are unchanging objects.
- Already it is making a community wiki ... for all those who are interested in closing this question or marking it as subjective etc. Etc ... *
Many functional languages are pure (mutation and side effects allowed Please).
For example, F # is for example, and if you look at the low level constructions in the collection, then you will know that use several repetitions under the hood and use some very unstable state (If you want to take N elements first
this is usually something like this:
- Use very little
- when you do Then note
- Notice how you will say something to make the hoang unstable
< / Ol> -
I find it unfortunate that C # copy the concept of Java with local variables Even being able to emphasize strongly that no one has There is no change, it clarifies whether the value is on the stack or in any object / structure.
-
If you have NDF, then you should call them
if calculate & gt; 0 Select the field where the ultimate and the right! Only hint
That is is possibly proof of a large amount of functional code to avoid the mutated state. For people brought to compulsory languages, the round of your head It is difficult to obtain, especially in the loop as a recursive task, writing the code in the loop is even tricky, then writing it where possible, recursive in the form of tail. To know how to do it, It is worthwhile and can lead to more expressive solutions, which focuses on logic rather than implementation. Good examples are those who deal with the collection, where there is no 'base matters', one or more elements Is explicitly expressed instead of being part of the loop logic.
This is actually 2, though it is better. And it is best done through an example:
Take your code base and change the every example variable to read [1] [2] Only those people Change back where you need to make your code incompatible to work (if you set them once outside the constructor, try to argue the constructor instead of being volatile through some form of property On doing Four.
Some codes are bases, for example, the Gwi / Widget will not work well with heavy code and some libraries (especially mutual collections), but I would say that the most appropriate The code will be created to read more than 50% of the instance fields.
At this point you should ask yourself, "Why the default is unstable?" The variable field is actually a Complex aspects They are in the form of interaction, even single threaded world, there is more scope for different behaviors, as they are highlighted best and pay attention to the transmitter, rather the destruction of the world. Instead of 'naked' left for It is noteworthy that in most functional languages there is no concept of zero or it is very difficult to use because they work, not with variables, but with the name value The name is the one whose value is defined at the same time (well)
Comments
Post a Comment