I heard that programs written in a functional language tend to scale better. Is this true and if so then what are the differences from non functional languages that cause this?
Whoever you heard this from was most likely referring to the fact that "Disallowing side effects provides for referential transparency, which makes it easier to verify, optimize, and parallelize programs, and easier to write automated tools to perform those tasks."
In other words, functional programs tend to not have side effects (modifying global state) so running many instances of a functional program in parallel should produce the same output. For example, consider the difference between
int a;
void increment_a() {
a++;
}
and
int increment(int a) {
return a+1;
}
The second has no side-effects and can be run in parallel, provided you structure your code so that you provide all the necessary inputs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With