February 2018
Beginner
200 pages
4h 37m
English
Imperative programming focuses on how to solve a problem, describing each step as actions. Functional programming, by contrast, is declarative. Declarative programming focuses on what is necessary to solve a problem, describing the data flow. Programming declaratively usually generates less code than programming imperatively. Less code means fewer things to write, more things done, and fewer bugs. Yay!
To see the difference between imperative and declarative, let’s look at a simple example that transforms a list of strings into uppercase. The example will be in JavaScript using the imperative mindset:
| | var list = ["dogs", "hot dogs", "bananas"]; |
| | |
| | function upcase(list) { |
| | var newList = []; |
| | for (var i = 0; i ... |
Read now
Unlock full access