4 ms·
With regard to web apps, you ask a big question, which I, for one, am unprepared to address in a brief comment. In general, however, functional programming aims
by gcv 18y ago
With regard to web apps, you ask a big question, which I, for one, am unprepared to address in a brief comment. In general, however, functional programming aims to make it easier to think about what a program does as it runs.
In imperative programming, you create variables and you change their values (or the values they reference). This is called mutable state. Functional programming claims that mutable state makes it difficult to reason about the value of a variable, because anything and anyone might have changed it. I happen to agree with this claim. Functional languages discourage, or outright forbid, changing variable values or referenced values. Instead, functional programs call functions in which the desired new value of the variable is an argument.
Initially, for people weaned on imperative languages, this is a mind-bender. It turns out, however, that with a little practice (I'd say less than two days of reading through SICP), that functional programs can be shorter and easier to understand than imperative programs. It turns out that modifying state becomes even trickier to think about once you introduce multiple threads of control. Variables clobbered by different threads leads to subtle and difficult bugs. A purely functional approach aims to eliminate this source of bugs at its root.