Functional JavaScript Tutorial - #3 Side Effects & Pure Functions

  Рет қаралды 5,437

Zaiste Programming

Zaiste Programming

Күн бұрын

A side effect is a change of system state or observable interaction with the outside world that occurs during the calculation of a result. A common side effect is to generate output beyond the return value. IO (input/output) operations such as file reading, database access or HTTP requests are another example of side effects.
Side Effects are the primary source of complexity in software. They are hidden inside the function's body and not captured by its signature. On top of that, side Effects may break compositional nature of functions.
Pure functions produce the same output for the same inputs and there are no side-effects. It's a computation that is only influenced by its input and that only influences its output.
Pure Functions are easier to reason about. They don't have side effects. This way, pure functions can only influence the behavior of a program through their output. As the output is deterministic (it can reliably be calculated using only the input values), pure functions will always preserve referential transparency. Additionally, using pure functions may increase program's performance.
Functional programming is a programming paradigm in which you build programs by
composing functions. The computation is then the evaluation of those functions.
Functional programming focuses on the usage of pure functions and on avoiding
shared, mutable state. This programming paradigm is declarative. Functional code
is usually more concise and easier to test.
In this mini series, we will embark on an exciting journey to learn a bit about
functional programming by using JavaScript. Presented concepts will be mostly
universal and applicable to other programming languages. This series is created with beginners and non-programmers in mind; don't worry, we will take it slowly!
Zaiste Weekly Newsletter: bit.ly/zaiste-weekly
#functional #javascript #tutorial

Пікірлер: 7
@subratopatnaik6361
@subratopatnaik6361 Жыл бұрын
That's very good explanation of side effects and pure function. Greetings from India!
@abdelrahmanmagdy8946
@abdelrahmanmagdy8946 3 жыл бұрын
great ❤👌👍
@MrDoby1989
@MrDoby1989 3 жыл бұрын
ya da7e7 :)
@voidnoire7256
@voidnoire7256 3 жыл бұрын
Will you be talking about how to handle side effects in a future video? E.g., use Effect functors or with dependency injection? Or if you've already covered the topic, please could you share the relevant link(s)? Thanks!
@nc581
@nc581 4 жыл бұрын
Hey can u share this file
@igors9895
@igors9895 Жыл бұрын
But date takes input the elapsed time since 1970 and the same input produces the same output, and doesnt have side effects so its a pure function.
@LanguageSkillz
@LanguageSkillz 3 жыл бұрын
= new Date() does not produce side effects and is a built-in function. Output changes when input does not, because it's the time, and the computer is otherwise calibrating for it. If that makes it impure for Functional Programming usage, does that reveal a dysfunctional rigidity about morbid adherence to vs organizational modularity of a paradigm concept? Might we consider, for the instance, it is deterministic outside the control of the programmer, because that is time?
Functional JavaScript Tutorial - #4 Memoization
9:09
Zaiste Programming
Рет қаралды 5 М.
Functional JavaScript Tutorial - #1: Functions
21:37
Zaiste Programming
Рет қаралды 10 М.
Я обещал подарить ему самокат!
01:00
Vlad Samokatchik
Рет қаралды 9 МЛН
Inside Out Babies (Inside Out Animation)
00:21
FASH
Рет қаралды 22 МЛН
What are "Pure Functions" and "Side Effects"?
4:49
Academind
Рет қаралды 53 М.
Functional Programming in 40 Minutes • Russ Olsen • GOTO 2018
41:35
GOTO Conferences
Рет қаралды 808 М.
Water powered timers hidden in public restrooms
13:12
Steve Mould
Рет қаралды 733 М.
An Introduction to Higher-Order Functions in JavaScript
16:45
Zaiste Programming
Рет қаралды 4,5 М.
Pure Functions Javascript - A Way to Avoid Side Effects in Javascript
6:03
Monsterlessons Academy
Рет қаралды 3,5 М.
C++ vs Rust: which is faster?
21:15
fasterthanlime
Рет қаралды 385 М.
5 JavaScript Concepts You HAVE TO KNOW
9:38
James Q Quick
Рет қаралды 1,4 МЛН
Async JavaScript & Callback Functions -- Tutorial for Beginners
24:21
Rate This Smartphone Cooler Set-up ⭐
0:10
Shakeuptech
Рет қаралды 6 МЛН
Частая ошибка геймеров? 😐 Dareu A710X
1:00
Вэйми
Рет қаралды 4,6 МЛН
iPhone 15 Pro в реальной жизни
24:07
HUDAKOV
Рет қаралды 484 М.