Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,230 --> 00:00:06,830
Hey, guys, in this lesson we're going to be learning all about Node JS what it is and why we're choosing
2
00:00:06,860 --> 00:00:07,670
to use it.
3
00:00:08,029 --> 00:00:14,510
So we know that we can use lots of different languages to write the back end of our web application.
4
00:00:14,510 --> 00:00:21,230
And we've also seen that depending on the language we want to choose, we can also find a compatible
5
00:00:21,230 --> 00:00:23,240
framework to go along with it.
6
00:00:23,630 --> 00:00:27,050
Now why would you need a framework anyways?
7
00:00:27,080 --> 00:00:33,170
Why can't you just write all the code from scratch using the chosen programming language and create
8
00:00:33,170 --> 00:00:34,670
your web server that way?
9
00:00:34,880 --> 00:00:39,320
Well, in some ways, a framework is a bit like mayonnaise.
10
00:00:39,350 --> 00:00:40,310
You know me.
11
00:00:40,310 --> 00:00:42,110
I love my food analogies.
12
00:00:42,110 --> 00:00:49,640
So let's say you're a chef and you wanted to make some sort of recipe and a great recipe Using mayonnaise,
13
00:00:49,640 --> 00:00:52,550
by the way, is chocolate cake.
14
00:00:52,580 --> 00:00:55,190
It sounds really weird, but Google it and try it.
15
00:00:55,190 --> 00:00:58,050
It actually tastes really, really delicious.
16
00:00:58,070 --> 00:01:03,900
Anyways, now let's say you're hungry at lunch and you wanted to make a tuna mayo sandwich.
17
00:01:03,930 --> 00:01:10,830
You could, of course, make your own mayonnaise, but alternatively, you could also just use store
18
00:01:10,830 --> 00:01:12,120
bought mayonnaise.
19
00:01:12,120 --> 00:01:15,540
And in that way the mayonnaise is kind of like a framework.
20
00:01:15,570 --> 00:01:22,110
You need all those components, the egg and the vinegar in order to create the end product, which is
21
00:01:22,110 --> 00:01:25,110
your web app, or in this case our tuna mayo sandwich.
22
00:01:25,110 --> 00:01:31,410
And you could write all of your own code or because this is such a commonly used functionality or in
23
00:01:31,410 --> 00:01:36,450
this case a commonly used condiment, you could also just get the mayonnaise framework.
24
00:01:36,570 --> 00:01:42,690
And in that way, a web framework provides pre-built components and structures that can be used to build
25
00:01:42,690 --> 00:01:48,240
an application without the need for us to write every single line of code from scratch.
26
00:01:48,330 --> 00:01:53,670
But when we think about Node, it's actually not quite a framework.
27
00:01:53,680 --> 00:01:58,320
It's an asynchronous event driven JavaScript runtime.
28
00:01:58,650 --> 00:02:05,910
NodeJS is designed to build scalable network applications and this is according to Node.js themselves,
29
00:02:05,910 --> 00:02:09,389
so pretty much straight from the horse's mouth.
30
00:02:09,419 --> 00:02:11,580
So it can't get more accurate than that.
31
00:02:11,700 --> 00:02:13,360
Now what does it mean?
32
00:02:13,380 --> 00:02:14,970
Let's break it down.
33
00:02:15,000 --> 00:02:18,310
It's a JavaScript runtime.
34
00:02:18,330 --> 00:02:21,900
Now what is a runtime environment?
35
00:02:22,200 --> 00:02:28,230
Now the important thing to remember here is that when JavaScript was first created, it was designed
36
00:02:28,230 --> 00:02:29,520
to run in the browser.
37
00:02:29,550 --> 00:02:35,730
This means that it was impossible to use JavaScript to write any kind of program that's not a website,
38
00:02:35,730 --> 00:02:44,850
but Node uses the V8 engine, not this eight cylinder V8 engine, but this V8 engine which comes from
39
00:02:44,850 --> 00:02:45,480
chromium.
40
00:02:45,480 --> 00:02:47,640
It's written in C and C plus plus.
41
00:02:47,670 --> 00:02:51,420
It's blazingly fast and it powers the Chrome browser.
42
00:02:51,690 --> 00:02:58,560
So we know that we can write JavaScript code to run in the browser and to provide functionality to our
43
00:02:58,560 --> 00:02:59,490
websites.
44
00:02:59,490 --> 00:03:05,700
But in many ways the JavaScript code that we have is locked in the browser jail.
45
00:03:05,700 --> 00:03:13,110
And when Node came along it effectively liberated the JavaScript out of browser land and gave it the
46
00:03:13,110 --> 00:03:19,890
freedom to allow us to use it to write any sort of application, desktop or server side.
47
00:03:20,100 --> 00:03:27,870
Now that Node provides us with this JavaScript runtime so that we can run JavaScript on a machine such
48
00:03:27,870 --> 00:03:30,750
as your own local computer.
49
00:03:30,780 --> 00:03:36,450
Then it means that we can use JavaScript to accomplish pretty much anything that other popular server
50
00:03:36,450 --> 00:03:44,910
side languages like Ruby, PHP, C-sharp, Python can do, but maintaining our full JavaScript stack
51
00:03:44,910 --> 00:03:46,530
from front end to back end.
52
00:03:46,860 --> 00:03:49,650
Now what about the other part of this sentence?
53
00:03:49,680 --> 00:03:52,740
It's asynchronous and event driven.
54
00:03:52,740 --> 00:03:54,360
What does this mean?
55
00:03:54,390 --> 00:04:02,550
Well, essentially asynchronous means that your JavaScript code doesn't have to do everything sequentially.
56
00:04:02,580 --> 00:04:08,580
If we think back to the scripts that we've written before, our code kind of runs from top to bottom
57
00:04:08,580 --> 00:04:14,730
and we can have some functions, but essentially everything is going to happen from beginning to end
58
00:04:14,760 --> 00:04:17,040
in a synchronous way.
59
00:04:17,250 --> 00:04:19,500
Now what does asynchronous mean?
60
00:04:19,500 --> 00:04:25,980
Well, let's say that you went on to Amazon, not that kind of Amazon, this Amazon, and you ordered
61
00:04:25,980 --> 00:04:27,090
yourself something.
62
00:04:27,120 --> 00:04:34,980
Now, if this process was synchronous, then it means that you would have to sit there and wait until
63
00:04:34,980 --> 00:04:39,000
your parcel gets delivered and you can't do anything else in the meantime.
64
00:04:39,000 --> 00:04:45,060
That's what it means to run synchronous code such as our previous scripts written in JavaScript.
65
00:04:45,250 --> 00:04:53,070
It's effectively tying up the resources until some sort of event resolves, which in this case is the
66
00:04:53,070 --> 00:04:55,620
delivery of your Amazon parcel.
67
00:04:56,310 --> 00:04:59,940
Can you imagine a world where you had to wait for your Amazon?
68
00:04:59,990 --> 00:05:05,660
Parcel and you just had to stand at the door and do nothing else after you've ordered it.
69
00:05:05,690 --> 00:05:10,910
Now, I don't know what Amazon Prime is like where you live, but where I live, it takes a long time
70
00:05:10,910 --> 00:05:15,950
to get one of these parcels and it would be terrible if this process was synchronous.
71
00:05:15,980 --> 00:05:23,900
Now, Node, on the other hand, is asynchronous and it's event driven, so it means that you can initiate
72
00:05:23,900 --> 00:05:31,100
this order and instead of having to wait for it, it can free up the resources.
73
00:05:31,100 --> 00:05:41,750
And only when the event of the parcel being delivered does it then continue to run the next bits of
74
00:05:41,750 --> 00:05:42,360
code.
75
00:05:42,380 --> 00:05:50,900
So effectively we can parcel up these bits of code into an event so that we know that our code can be
76
00:05:50,900 --> 00:05:53,180
triggered when this event happens.
77
00:05:53,450 --> 00:06:01,830
In summary, the reason why we need Node is because it allows us to build an application often on a
78
00:06:01,830 --> 00:06:04,700
computer using JavaScript.
79
00:06:04,710 --> 00:06:10,590
And as we saw earlier, the application is a key aspect of our back end.
80
00:06:10,800 --> 00:06:18,540
Now that application is going to be running on our server and that server, if you remember, is just
81
00:06:18,540 --> 00:06:24,720
a computer, but it's not a browser and NodeJS is what allows us to happen.
82
00:06:25,140 --> 00:06:31,200
Now, as we saw earlier, there are many, many different choices in terms of languages or technologies
83
00:06:31,200 --> 00:06:33,510
that we could use for the back end.
84
00:06:33,510 --> 00:06:36,120
So why are we choosing Node?
85
00:06:36,150 --> 00:06:42,270
Well, the reason is because if we use Node, which is one of the most popular choices as of today,
86
00:06:42,300 --> 00:06:49,680
then it means that our front end could be written in JavaScript plus HTML and CSS of course, but our
87
00:06:49,680 --> 00:06:53,250
back end could also be written in JavaScript.
88
00:06:53,250 --> 00:07:00,750
So effectively that allows us to use JavaScript everywhere inside our web application and this allows
89
00:07:00,810 --> 00:07:04,380
us to use one language to rule them all.
90
00:07:04,890 --> 00:07:11,490
So the key benefits of NodeJS are the fact that it allows us to use JavaScript across the entire stack,
91
00:07:11,490 --> 00:07:17,430
which means that developers are using a language they're already familiar with, and it makes it easy
92
00:07:17,430 --> 00:07:21,240
for them to transition from front end to back end developer.
93
00:07:21,240 --> 00:07:28,050
And if you're writing a project yourself, then you only really need to be familiar with one language
94
00:07:28,050 --> 00:07:31,710
and you can share your code between your client and server side.
95
00:07:31,980 --> 00:07:39,180
In addition, Node.js allows for easy scaling of applications, making it really good for large scale
96
00:07:39,180 --> 00:07:40,650
professional projects.
97
00:07:40,680 --> 00:07:48,900
It's fast and it's non-blocking because of this asynchronous event driven nature of NodeJS, it can
98
00:07:48,900 --> 00:07:50,970
be really fast and really efficient.
99
00:07:50,970 --> 00:07:55,800
Instead of having to wait for things to happen or blocking the resources.
100
00:07:56,160 --> 00:07:59,040
Finally, it's got a huge ecosystem.
101
00:07:59,190 --> 00:08:05,550
It's got a really vibrant community and people have contributed thousands of open source modules and
102
00:08:05,550 --> 00:08:12,510
packages to the Node package manager, which allows us to easily add functionality to our own applications.
103
00:08:12,510 --> 00:08:17,790
But also it means that there's a lot of resources out there in terms of documentation.
104
00:08:17,790 --> 00:08:21,870
Tutorials help people on StackOverflow who can answer your questions.
105
00:08:21,870 --> 00:08:24,840
And plus we're not the only people choosing it.
106
00:08:24,990 --> 00:08:32,700
Everything from LinkedIn to Twitter to Netflix is built on top of Node.js and even NASA uses Node.js.
107
00:08:32,730 --> 00:08:38,190
I recently came across this report about how NASA started using NodeJS in order to keep their astronauts
108
00:08:38,190 --> 00:08:40,770
safe and make their data accessible.
109
00:08:40,770 --> 00:08:45,660
So if it's good enough for NASA, it's probably good enough for our project.
110
00:08:46,080 --> 00:08:49,350
Now, I don't think you needed any more convincing why?
111
00:08:49,350 --> 00:08:55,320
We are choosing the best possible path, but every single time I give a talk on Node.js, people always
112
00:08:55,350 --> 00:08:58,350
ask me, Why don't we use a C-sharp?
113
00:08:58,350 --> 00:09:01,320
Why don't we use Python or why don't we use PHP?
114
00:09:01,410 --> 00:09:07,830
People are particularly obsessed with PHP for some reason and as we saw already in the last video,
115
00:09:07,860 --> 00:09:10,290
node is just dominant.
116
00:09:10,290 --> 00:09:13,770
It's the thing that you're going to need to know if you want to get a job.
117
00:09:13,770 --> 00:09:19,560
And it's the thing that most people look for as a key skill in a web developer.
118
00:09:19,740 --> 00:09:22,150
And we're trying to become web developers, right?
119
00:09:22,170 --> 00:09:27,270
If you want to learn about Python and Python based backends, which are really great, if you're working
120
00:09:27,270 --> 00:09:32,430
with machine learning projects or anything to do with machine learning and AI, then be sure to check
121
00:09:32,430 --> 00:09:38,100
out my Python course where we cover the use of flask in the back end and using Python.
122
00:09:38,730 --> 00:09:45,600
Now one final piece of interesting stat from GitHub which looks at the programming languages of code
123
00:09:45,600 --> 00:09:48,480
that is committed across the entirety of GitHub.
124
00:09:48,480 --> 00:09:52,800
And you can see that JavaScript is just still king.
125
00:09:52,830 --> 00:09:57,990
Python is growing in popularity and for example, PHP.
126
00:09:58,320 --> 00:09:59,860
For some reason I always get asked.
127
00:09:59,880 --> 00:10:00,310
About this.
128
00:10:00,330 --> 00:10:01,620
Why are you not teaching PHP?
129
00:10:01,890 --> 00:10:07,230
Well, it's because it's not really a very good idea to teach PHP at this point.
130
00:10:07,230 --> 00:10:13,260
And in fact, if you see any web development bootcamp that's teaching PHP or Ruby on Rails, then you
131
00:10:13,260 --> 00:10:18,720
should probably be asking yourself if they have updated their curriculum within the last ten years.
132
00:10:19,170 --> 00:10:20,230
There you have it.
133
00:10:20,250 --> 00:10:25,590
You should now understand what NodeJS is, what it allows us to accomplish, and why we're choosing
134
00:10:25,590 --> 00:10:27,270
it to build our backend.
135
00:10:27,510 --> 00:10:32,670
In the next lesson, I'm going to be showing you how to install NodeJS on your local computer so we
136
00:10:32,670 --> 00:10:36,360
can get started building applications using Node.
137
00:10:36,750 --> 00:10:39,270
So for all of that and more, I'll see you there.
14497
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.