Recs.
Updated
Side effects usually make programming harder by decreasing maintainability. Side effects mean that executing a particular block of code changes the environment where the code is executed. Side effects are usually introduced by Mutation, which enables the program to change the contents of memory in the code.
Unfortunately this is not widely seen as a bad practice because most mainstream programming languages allow mutation and encourage programming with side effects.
For instance, suppose we have two methods A() and B() and, for some reason, we would like to call them on a different order.
If methods A and B have no side effects we can have confidence that changing the order in which they are called won't break the code. Otherwise, the change in ordering can completely alter the outcome of the program.
x = 0
A()
{
return x += 2;
}
B()
{
return x * 3;
}
// Calling A() + B() yields 8
// Calling B() + A() yields 2
Things get even uglier when we add multiple threads into the picture. It is very easy to make mistakes when doing multi-thread programming with side effects, since race conditions and deadlocks are very hard to visualize, reproduce and sometimes could be practically impossible to debug.