What is functional programming?
What is functional programming?
a programming paradigm (worldview, mindset)
it's kind of a way of looking at a world in terms of what the world is composed of.
Imperative
follow my commands
do this, then that
Object-Oriented
keep state to yourself
send/receive messages
Declarative
this is what I want
I don't care how you do it e.g. SQL
Functional
sort of a sub-paradigm of Declarative
What is functional programming?
one simple idea. pure functions (only input in, only output out)
Not pure:
var name = "Saint Petersburg";
function greet() {
console.log("Hello, " + name + "!");
}
greet();
// Hello, Saint Petersburg!
Pure:
function greet(name) {
return "Hello, " + name + "!";
}
greet("Saint Petersburg");
// Hello, Saint Petersburg!
Why functional programming?
- more predictable, safer
- easier to test/debug
all you need to do to test pure functions is to pass in the input and check if it gives the right thing
makes you look/feel smart
is THE BEST paradigm
Why functional JavaScript?
- object-oriented JS gets tricky
(prototypes? this?!?)
- established community/tools
- reuse functions like Lego blocks between different projects
https://codewords.recurse.com/issues/one/an-introduction-to-functional-programming
a programming paradigm (worldview, mindset)
it's kind of a way of looking at a world in terms of what the world is composed of.
Imperative
follow my commands
do this, then that
Object-Oriented
keep state to yourself
send/receive messages
Declarative
this is what I want
I don't care how you do it e.g. SQL
Functional
sort of a sub-paradigm of Declarative
What is functional programming?
one simple idea. pure functions (only input in, only output out)
Not pure:
var name = "Saint Petersburg";
function greet() {
console.log("Hello, " + name + "!");
}
greet();
// Hello, Saint Petersburg!
Pure:
function greet(name) {
return "Hello, " + name + "!";
}
greet("Saint Petersburg");
// Hello, Saint Petersburg!
Why functional programming?
- more predictable, safer
- easier to test/debug
all you need to do to test pure functions is to pass in the input and check if it gives the right thing
is THE BEST paradigm
Why functional JavaScript?
- object-oriented JS gets tricky
(prototypes? this?!?)
- established community/tools
- reuse functions like Lego blocks between different projects
https://codewords.recurse.com/issues/one/an-introduction-to-functional-programming
Vampires in the Enchanted Castle casino - FilmFileEurope
ReplyDeleteVampires in the find air jordan 18 retro varsity red Enchanted Castle Casino. Vampires in the Enchanted Castle Casino. replica air jordan 18 retro red suede Vampires in the Enchanted Castle air jordan 18 retro red order Casino. Vampires in the Enchanted Castle how to buy air jordan 18 retro red suede Casino. 7m스코어 벳무브 Vampires in the Enchanted