Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,500 --> 00:00:01,340
Hey, guys.
2
00:00:01,340 --> 00:00:02,060
Well done.
3
00:00:02,060 --> 00:00:05,270
You've made it through the first half of the course.
4
00:00:05,300 --> 00:00:11,720
In this second half, we're going to be talking about the backend side of web development and learning
5
00:00:11,720 --> 00:00:12,560
and writing.
6
00:00:12,560 --> 00:00:17,240
All the code that takes care of all the behind the scenes functionality.
7
00:00:17,450 --> 00:00:24,050
So recently, I came across a tweet by Paul Graham, who's the founder of Y Combinator, and something
8
00:00:24,050 --> 00:00:26,540
he said really stuck out to me.
9
00:00:26,750 --> 00:00:32,450
If you think about it like this, the amount of equity you get in a startup decreases exponentially
10
00:00:32,450 --> 00:00:34,750
as your employee number increases.
11
00:00:34,760 --> 00:00:39,230
So if you wanted to get rich from a startup, you have to be there early.
12
00:00:39,380 --> 00:00:45,890
And in a typical tech startup, the thing that matters early on is programming.
13
00:00:45,890 --> 00:00:53,600
So if you're a lawyer or an MBA or biz dev, you're probably not going to be one of the first 20 employees.
14
00:00:53,780 --> 00:00:59,690
Instead, you're probably going to be a programmer who's really good at building stuff.
15
00:00:59,940 --> 00:01:03,060
So what does that mean, somebody who's really good at building stuff?
16
00:01:03,090 --> 00:01:11,790
Well, I took a look at the Y Combinator job board, which advertises jobs for the Y Combinator startups.
17
00:01:11,790 --> 00:01:13,980
And this is just the list that came up.
18
00:01:13,980 --> 00:01:18,000
And if you look at it, all of them pretty much want full stack.
19
00:01:18,030 --> 00:01:19,140
Full stack.
20
00:01:19,170 --> 00:01:20,190
Full stack.
21
00:01:20,190 --> 00:01:21,630
Web developers.
22
00:01:22,170 --> 00:01:25,440
What exactly is a full stack web developer?
23
00:01:25,470 --> 00:01:30,450
Well, it's the combination of knowing about how to work with the front end.
24
00:01:30,450 --> 00:01:37,500
So the client facing side and also how to work with the back end, which is the side that's invisible
25
00:01:37,500 --> 00:01:43,580
to the user, but contains all the logic that makes a web application work.
26
00:01:43,590 --> 00:01:48,630
And this is the part that we're going to be learning about in the coming lessons.
27
00:01:48,660 --> 00:01:54,870
Now, I love this cartoon that describes exactly what is the difference between the front end and the
28
00:01:54,870 --> 00:01:55,680
back end.
29
00:01:55,830 --> 00:02:03,030
Notice that here is our user and he's looking at this beautiful mermaid, and everything the user can
30
00:02:03,030 --> 00:02:06,480
see is a part of the front end.
31
00:02:06,510 --> 00:02:13,230
It's the font, it's the colors, it's the typography, it's the buttons, the forms, Everything that
32
00:02:13,230 --> 00:02:20,220
the user can see or hear or interact with is a part of the front end of the website.
33
00:02:20,460 --> 00:02:24,480
Now, what about this dragon at the back?
34
00:02:24,600 --> 00:02:29,120
Well, because the back end is the part the user will never see and never interact with.
35
00:02:29,130 --> 00:02:34,710
Sometimes it can get a little bit monster like, but it doesn't have to.
36
00:02:34,710 --> 00:02:40,110
And we're going to learn all the things that's going to make our front end as great as our back end.
37
00:02:40,140 --> 00:02:48,510
But essentially the back end is the part the user never gets to interact with and never gets to touch
38
00:02:48,510 --> 00:02:49,410
or see.
39
00:02:49,530 --> 00:02:52,710
So what exactly is the back end?
40
00:02:52,740 --> 00:02:55,330
Don't worry, it's not anything rude.
41
00:02:55,350 --> 00:02:58,670
It consists of three main components.
42
00:02:58,680 --> 00:03:08,580
It's the server which is basically just a computer, the application, which is all the logic that enables
43
00:03:08,580 --> 00:03:10,320
the web app to function.
44
00:03:10,320 --> 00:03:16,500
And finally a database where you can store and retrieve user data.
45
00:03:16,710 --> 00:03:21,210
Now let's look at each of these in a little bit more detail.
46
00:03:21,240 --> 00:03:31,420
As I mentioned before, a server is just a computer, and a server for a live website should be on 24
47
00:03:31,420 --> 00:03:38,340
over seven so that it can listen for incoming requests from browsers from all over the world.
48
00:03:38,550 --> 00:03:45,840
Traditionally, servers are made and optimized for this particular purpose, but at the end of the day,
49
00:03:45,840 --> 00:03:51,690
any computer that is connected to the network can act as a server.
50
00:03:51,720 --> 00:03:57,600
And in fact, when we're going to be building our websites locally, we're going to be using something
51
00:03:57,600 --> 00:04:04,530
called localhost, which means we're going to be using our own computer as the server in order to serve
52
00:04:04,530 --> 00:04:06,540
up the websites that we create.
53
00:04:06,540 --> 00:04:12,060
And even though it's not on 24 over seven, or maybe you keep your computer on 24 over seven, it doesn't
54
00:04:12,060 --> 00:04:16,440
matter because we only need it to be on and connected when we're testing it.
55
00:04:17,220 --> 00:04:25,380
The second aspect of the back end is the application, and the application is basically logic that runs
56
00:04:25,380 --> 00:04:27,630
on that computer, the server.
57
00:04:27,840 --> 00:04:35,970
And this logic determines how you want to respond to the requests from the browser.
58
00:04:36,210 --> 00:04:43,530
Depending on what that request is, let's say a user clicked on a button and that request came through
59
00:04:43,530 --> 00:04:45,600
the server to the application.
60
00:04:45,600 --> 00:04:53,220
Well, the application knows that that particular button should then return a particular HTML page.
61
00:04:53,220 --> 00:04:59,280
So then it sends that HTML page back to the browser and the user gets a look at a new web page.
62
00:04:59,800 --> 00:05:05,080
Sometimes an application can also respond with different things other than HTML.
63
00:05:05,080 --> 00:05:11,140
So it could send back data or it could send back just a status code.
64
00:05:11,140 --> 00:05:17,860
And you've probably all been on websites where you've seen the status code that is a 404.
65
00:05:17,890 --> 00:05:24,940
And this is a code that the application on a server sent back because it's trying to tell the browser
66
00:05:24,940 --> 00:05:29,500
that that particular request you sent is invalid.
67
00:05:29,500 --> 00:05:35,620
And what that means is the application does not know how to respond to that particular request, the
68
00:05:35,620 --> 00:05:36,520
browser made.
69
00:05:36,520 --> 00:05:42,550
So maybe you try to go to a weird URL that doesn't exist, or you try to click on something that's broken.
70
00:05:42,550 --> 00:05:47,110
But either way, when the application doesn't know what to do with the request the browser is sending
71
00:05:47,110 --> 00:05:55,810
over, it will send back an invalid, which is a 404 status code and then usually your website will
72
00:05:55,810 --> 00:05:59,660
just show the user Oops, I think you did something wrong.
73
00:05:59,930 --> 00:06:03,440
The final aspect of the back end is the database.
74
00:06:03,440 --> 00:06:11,030
And this is not a requirement of web applications, but usually as your web app gets more complex and
75
00:06:11,030 --> 00:06:20,120
larger, then it's going to need to start to store user data and that is what databases are for.
76
00:06:20,480 --> 00:06:28,320
So when we store the data onto a hard drive, it's kind of like saving your word document, right?
77
00:06:28,340 --> 00:06:34,430
If suddenly the power went out and you didn't save your work, then you will probably lose it.
78
00:06:34,430 --> 00:06:40,220
But if you hit save, even if the power goes out the next time you log on, you'll still be able to
79
00:06:40,220 --> 00:06:42,110
see your work.
80
00:06:42,110 --> 00:06:45,290
And this happens exactly the same way on a server.
81
00:06:45,290 --> 00:06:53,390
If that computer lost power and you didn't have any sort of database, then all of that data will get
82
00:06:53,390 --> 00:06:58,250
completely wiped Unless we have a way to persist.
83
00:06:58,280 --> 00:07:00,400
The information.
84
00:07:00,400 --> 00:07:05,710
So you can view the database as a form of permanent storage for your web application.
85
00:07:06,220 --> 00:07:13,450
Now, I keep talking about this idea of a web application, and the reason for that is because so far
86
00:07:13,450 --> 00:07:21,040
what we've been building websites that only have a front end, they are essentially web pages, they
87
00:07:21,040 --> 00:07:32,650
are bits of HTML that gets requested from the browser to our server, and the server then returns that
88
00:07:32,830 --> 00:07:36,160
HTML file which gets rendered on the browser.
89
00:07:36,160 --> 00:07:40,720
So it could include the HTML, the CSS and the JavaScript.
90
00:07:40,900 --> 00:07:50,200
And this is why we've been able to use GitHub pages to serve these static web pages because all we needed
91
00:07:50,200 --> 00:07:59,620
to do was to store these files somewhere and when the user requests it by going to a particular URL,
92
00:07:59,650 --> 00:08:07,820
then the server, which in our case was GitHub pages, then returns these files back to the browser
93
00:08:07,820 --> 00:08:10,970
and gets rendered for the user to see.
94
00:08:11,000 --> 00:08:13,840
Nothing very complex there.
95
00:08:13,850 --> 00:08:21,320
But when we're talking about a web application or a web app, then in this case it should be able to
96
00:08:21,320 --> 00:08:25,970
do something beyond just allowing users to view web pages.
97
00:08:26,270 --> 00:08:34,460
Let's think about a really, really simple type of web application functionality, and that is simply
98
00:08:34,460 --> 00:08:37,460
just allowing users to log in.
99
00:08:37,700 --> 00:08:47,000
Let's say the user goes to our website, our web app, and enters their email and their password because
100
00:08:47,000 --> 00:08:49,100
they're trying to log in to our website.
101
00:08:49,190 --> 00:08:57,860
Now, these two pieces of information are passed to our server in a request because our server is on
102
00:08:57,860 --> 00:09:07,720
and is listening for requests, it's able to find the application that knows how to handle the login.
103
00:09:07,720 --> 00:09:11,980
So maybe it'll be like a login dot JS file.
104
00:09:12,280 --> 00:09:18,880
In this file there will be some logic that knows how to log a user in and that logic is usually pretty
105
00:09:18,880 --> 00:09:19,600
simple.
106
00:09:19,600 --> 00:09:29,530
We could look inside our database, look for a particular email and get hold of the password for that
107
00:09:29,530 --> 00:09:37,030
email, and then we can compare that password that's in the database for the user's email against the
108
00:09:37,030 --> 00:09:40,420
password that they sent us from the front end.
109
00:09:40,420 --> 00:09:49,150
And if those two pieces of data match, then we can send back via the server a response.
110
00:09:50,370 --> 00:09:54,000
In the form of, say, the home page.
111
00:09:54,000 --> 00:09:54,330
Right.
112
00:09:54,330 --> 00:09:56,660
So home dot HTML maybe.
113
00:09:56,670 --> 00:10:04,680
And if for some reason it didn't match, then maybe our response would be to send them back to the login
114
00:10:04,680 --> 00:10:08,370
page and get them to try again with an error code.
115
00:10:08,640 --> 00:10:15,570
If you think about this whole flow of our web application, things are a little bit more complex.
116
00:10:15,570 --> 00:10:25,560
And the reason why it is more complex is because we now have a web application with logic and a front
117
00:10:25,560 --> 00:10:26,820
and a back end.
118
00:10:27,030 --> 00:10:30,060
The front end is everything the user sees.
119
00:10:30,090 --> 00:10:38,730
The back end is all of the things that the server, the application and the database does in order for
120
00:10:38,730 --> 00:10:42,550
our website to have more complex functionality.
121
00:10:42,570 --> 00:10:49,800
If that's all a little bit abstract and difficult to imagine, then you can think of a restaurant as
122
00:10:49,900 --> 00:10:55,210
a really good analogy for this process of front end and back end.
123
00:10:55,330 --> 00:11:04,780
If we divide up a restaurant into a front end, which is the actual restaurant that the user or the
124
00:11:04,780 --> 00:11:13,090
client gets to see, and then we have all of the rest over here as the back end.
125
00:11:13,510 --> 00:11:18,640
Then we can start thinking about what happens when we order at a restaurant.
126
00:11:18,880 --> 00:11:21,240
Firstly, you enter the restaurant.
127
00:11:21,250 --> 00:11:28,210
Here you are a little stick figure, looking beautiful as always, and you say to the waiter, Hey,
128
00:11:28,210 --> 00:11:30,000
I want something.
129
00:11:30,010 --> 00:11:36,520
So you take a look at the menu, which essentially is all of the functionality that this particular
130
00:11:36,520 --> 00:11:37,870
web app has.
131
00:11:37,870 --> 00:11:45,730
And you can also think of this as just all the different interactions on the website, buttons or forms,
132
00:11:45,730 --> 00:11:50,200
and you decide to click on a particular button, let's say, right?
133
00:11:50,380 --> 00:11:57,940
So you click on this button on a website or in the case of our restaurant, you tell the waiter your
134
00:11:57,940 --> 00:12:04,390
order from the menu, and then what the waiter is going to do is he's going to traverse from the front
135
00:12:04,390 --> 00:12:06,580
end to the back end.
136
00:12:06,700 --> 00:12:13,930
And this is what happens when your browser sends that request to your server.
137
00:12:15,250 --> 00:12:20,440
The server is effectively the same as the kitchen in the restaurant.
138
00:12:20,470 --> 00:12:23,350
It's open 24 over seven.
139
00:12:23,350 --> 00:12:29,560
Well, certain restaurants are anyways, but in this case it's listening for the requests.
140
00:12:29,560 --> 00:12:36,460
That's coming from our waiter, from the front end, from the restaurant and in the server there are
141
00:12:36,460 --> 00:12:40,570
applications, which is basically our chefs.
142
00:12:40,720 --> 00:12:46,570
And what our chefs are able to do is they have lots of recipes.
143
00:12:46,570 --> 00:12:51,670
They know exactly how to respond to different requests from the client.
144
00:12:51,670 --> 00:12:55,560
AT So let's say in this case, the client wanted some pancakes.
145
00:12:55,570 --> 00:12:59,890
Well, the application our chef knows how to make a pancake.
146
00:12:59,920 --> 00:13:02,740
It has the pancake recipe.
147
00:13:02,740 --> 00:13:04,930
It checks the recipe it sees.
148
00:13:04,930 --> 00:13:08,350
Oh, we need some data from our database.
149
00:13:08,500 --> 00:13:16,300
If we imagine the pantry as the database of the restaurant, then what the chef or the application is
150
00:13:16,300 --> 00:13:25,870
going to do is going to request those ingredients or those pieces of data to process it or work with
151
00:13:25,870 --> 00:13:26,920
it somehow.
152
00:13:26,920 --> 00:13:33,060
And then at the end, it's going to send back a response to the front end.
153
00:13:33,070 --> 00:13:38,620
So in this case, we got some pancakes that were made in the kitchen and sent into the front of house,
154
00:13:38,620 --> 00:13:47,500
which is the restaurant, and in our server that could be some HTML, CSS and JavaScript files that
155
00:13:47,500 --> 00:13:52,390
got created or retrieved and sent over to the front end.
156
00:13:52,780 --> 00:14:01,600
Now, if you wanted more food or a different item, then you can again ask the waiter to make another
157
00:14:01,600 --> 00:14:05,140
request to your server.
158
00:14:05,170 --> 00:14:14,320
And this cycle of response and request between the front end and the back end is essentially how most
159
00:14:14,320 --> 00:14:15,940
web apps work.
160
00:14:16,240 --> 00:14:22,660
So the next time when you're thinking about how a full stack web application works, you can think about
161
00:14:22,660 --> 00:14:32,440
the client who's a person at a restaurant who is ordering food, and that request gets relayed to the
162
00:14:32,440 --> 00:14:35,590
kitchen, which is the server side.
163
00:14:35,590 --> 00:14:42,280
And in the server there's an application which is similar to the kitchen that prepares the order and
164
00:14:42,280 --> 00:14:45,580
working with the data in the pantry of the kitchen.
165
00:14:45,580 --> 00:14:49,420
And once all of that logic is processed, the.
166
00:14:49,630 --> 00:14:50,140
Food.
167
00:14:50,170 --> 00:14:57,070
The actual thing that the user should see is then sent back to the client side where the response is
168
00:14:57,070 --> 00:14:58,930
the food on the actual plate.
169
00:14:59,580 --> 00:15:06,540
In the next lesson, let's learn more about the actual tools and technologies that are used to build
170
00:15:06,540 --> 00:15:09,140
the back end of web applications.
171
00:15:09,150 --> 00:15:12,540
So for all of that and more, I'll see you on the next lesson.
18317
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.