All language subtitles for 003 Declarative vs Imperative_en

af Afrikaans
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,960 --> 00:00:05,400 Now the success of React comes down to four key things. 2 00:00:05,400 --> 00:00:09,820 And these React concepts are we going to go over in the next four videos. 3 00:00:09,930 --> 00:00:15,420 But in this one let's talk about the first one and the first one React says: hey don't touch the DOM 4 00:00:15,780 --> 00:00:17,040 I'll do it. 5 00:00:17,040 --> 00:00:18,840 What do I mean by this? 6 00:00:18,870 --> 00:00:28,600 You see, many existing frameworks and libraries before React where directly manipulating this Dom on 7 00:00:28,600 --> 00:00:29,760 every page. 8 00:00:29,890 --> 00:00:38,280 First let's just go over what a Dom is. If you remember Dom is our Document Object Model. 9 00:00:38,280 --> 00:00:47,940 It's what the browser uses to display a Web Site or a web app, and Javascript is simply manipulating 10 00:00:47,970 --> 00:00:48,560 this Dom. 11 00:00:48,570 --> 00:00:50,360 That's all javascript is doing. 12 00:00:50,370 --> 00:01:00,790 For example if I right click over here and select Inspect and you'll see that here if I click on 13 00:01:00,790 --> 00:01:06,500 un vote we'll get a little flash saying that hey javascript just updated this. 14 00:01:06,550 --> 00:01:15,030 If I click again, again I get a little flash. The DOM is just the tree representation of the page. 15 00:01:15,230 --> 00:01:21,740 We start all the way up from the HTML tag all the way down to the body through each individual elements 16 00:01:22,460 --> 00:01:30,950 and Web sites were built using things like this all these ways that browsers allowed us to manipulate 17 00:01:31,070 --> 00:01:31,960 the DOM. 18 00:01:32,030 --> 00:01:38,690 They gave us the DOM API that we could access using something like innerHTML or get element by I.D. 19 00:01:38,840 --> 00:01:48,260 get elements by tag name this API allowed us to traverse the DOM access any node we wanted to maybe 20 00:01:48,320 --> 00:01:51,850 remove them add new nodes and before React. 21 00:01:51,860 --> 00:02:00,590 This is what libraries did you either did this manually or you used jQuery or you use some sort of 22 00:02:00,590 --> 00:02:07,310 a library that allows you to use this in a simple fashion you see this way of programming was called 23 00:02:07,340 --> 00:02:18,950 imperative: that is in an imperative paradigm you directly change individual parts of your app in response 24 00:02:18,950 --> 00:02:29,390 to various user events. so you had let's say your javascript file you'd say: hey if user is logged in. 25 00:02:29,420 --> 00:02:34,810 Well then go change that little icon over here to the user's profile. 26 00:02:34,970 --> 00:02:38,750 And now that the user is logged in, well, also show profile page. 27 00:02:38,840 --> 00:02:44,540 OK so javascript goes changes the Dom and updates the profile page and then OK. 28 00:02:44,570 --> 00:02:46,370 Now that we have we're also logged in. 29 00:02:46,370 --> 00:02:47,930 We also need to display friends. 30 00:02:47,990 --> 00:02:48,240 OK. 31 00:02:48,260 --> 00:02:50,880 Let's do that as well modify the Dom and. 32 00:02:50,980 --> 00:02:51,240 All right. 33 00:02:51,260 --> 00:02:52,070 That's good we're good. 34 00:02:52,070 --> 00:02:56,250 Oh by the way it's been five seconds and we need to display a chat over here. 35 00:02:56,300 --> 00:02:56,670 OK. 36 00:02:56,690 --> 00:02:59,180 I'm going to go and do that now. 37 00:02:59,180 --> 00:03:06,280 This sounds intuitive but the problem with this imperative approach is that it becomes difficult to 38 00:03:06,280 --> 00:03:11,180 see the relationships between events and all these edge cases. 39 00:03:11,200 --> 00:03:18,370 Remember this diagram over here where we had AngularJS that all of a sudden had all these relationships 40 00:03:18,760 --> 00:03:25,340 affecting each other and all these errors pointing to different things. Well, instead of this imperative 41 00:03:25,430 --> 00:03:33,500 approach React came up with a novel concept a more declarative approach and this is what React says to 42 00:03:33,500 --> 00:03:34,180 you. 43 00:03:34,400 --> 00:03:39,300 Hey Dom manipulation is one of the biggest performance bottlenecks. 44 00:03:39,380 --> 00:03:42,530 It takes a long time for Dom changes to happen. 45 00:03:42,530 --> 00:03:46,040 The browser has to do two really intensive operations. 46 00:03:46,070 --> 00:03:47,490 One is to repaint. 47 00:03:47,570 --> 00:03:55,370 That is change an element and added onto a page and then refloat which is to recalculate the layout 48 00:03:55,580 --> 00:03:58,640 of the page and move things around if need be. 49 00:03:58,640 --> 00:04:02,810 So changing the Dom was a really expensive operation. 50 00:04:03,020 --> 00:04:04,760 So React says: hey you know what. 51 00:04:05,000 --> 00:04:12,560 Let me take care that I'll find the best way for me to change the Dom and just declare to me what your 52 00:04:12,830 --> 00:04:14,550 app looks like. 53 00:04:14,570 --> 00:04:23,660 So all we need to do is say hey this is a javascript object of how I want the app to look and React 54 00:04:23,690 --> 00:04:32,240 is going to hold this javascript object this massive massive blueprint of how things should look. 55 00:04:32,330 --> 00:04:40,220 And based on this blueprint that we give it React just says hey just tell me what the page should 56 00:04:40,220 --> 00:04:42,330 look like and I'll take care of it. 57 00:04:42,380 --> 00:04:44,000 I'll do everything for you. 58 00:04:44,090 --> 00:04:46,770 I'll find the best way to use the DOM. 59 00:04:46,850 --> 00:04:48,440 You're never going to touch the DOM. 60 00:04:48,440 --> 00:04:51,660 Just tell me what the page should look like. 61 00:04:51,740 --> 00:05:00,200 This declarative paradigm is called that because we declare that hey this is what the state or data 62 00:05:00,410 --> 00:05:01,880 of our app should be like. 63 00:05:01,940 --> 00:05:04,150 And based on this date. 64 00:05:04,400 --> 00:05:06,480 Well then just make those changes. 65 00:05:06,530 --> 00:05:13,470 So if a user is logged in then React already knows exactly what to update and what to do. 66 00:05:13,580 --> 00:05:20,840 Now this idea of a declarative style meant that we didn't have to directly say do this and if this happens 67 00:05:20,870 --> 00:05:25,440 then do that where we just say one by one exactly what should happen. 68 00:05:25,520 --> 00:05:34,210 Instead we tell it this is the state of our app and React automatically just does it for us. 69 00:05:34,220 --> 00:05:40,310 The difference is that all the different states are accounted for in one place. 70 00:05:40,310 --> 00:05:46,210 That is one big javascript object that describes how our app should look. 71 00:05:46,310 --> 00:05:53,800 And this resulted in less complexity better code quality and faster developer times. 72 00:05:53,870 --> 00:06:00,080 So it created this whole idea of: hey you can build web interfaces without touching the Dom and this 73 00:06:00,080 --> 00:06:08,840 is where the name React came from. The name React is simply saying hey based on whatever the state or 74 00:06:08,840 --> 00:06:15,200 data of the app is that describes our app, I'm just going to React to it and change everything for you 75 00:06:15,230 --> 00:06:17,090 so that you get the display that you want. 7421

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.