Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Hey, guys, in this lesson we're going to be learning all about Node JS what it is and why we're choosing
to use it.
So we know that we can use lots of different languages to write the back end of our web application.
And we've also seen that depending on the language we want to choose, we can also find a compatible
framework to go along with it.
Now why would you need a framework anyways?
Why can't you just write all the code from scratch using the chosen programming language and create
your web server that way?
Well, in some ways, a framework is a bit like mayonnaise.
You know me.
I love my food analogies.
So let's say you're a chef and you wanted to make some sort of recipe and a great recipe Using mayonnaise,
by the way, is chocolate cake.
It sounds really weird, but Google it and try it.
It actually tastes really, really delicious.
Anyways, now let's say you're hungry at lunch and you wanted to make a tuna mayo sandwich.
You could, of course, make your own mayonnaise, but alternatively, you could also just use store
bought mayonnaise.
And in that way the mayonnaise is kind of like a framework.
You need all those components, the egg and the vinegar in order to create the end product, which is
your web app, or in this case our tuna mayo sandwich.
And you could write all of your own code or because this is such a commonly used functionality or in
this case a commonly used condiment, you could also just get the mayonnaise framework.
And in that way, a web framework provides pre-built components and structures that can be used to build
an application without the need for us to write every single line of code from scratch.
But when we think about Node, it's actually not quite a framework.
It's an asynchronous event driven JavaScript runtime.
NodeJS is designed to build scalable network applications and this is according to Node.js themselves,
so pretty much straight from the horse's mouth.
So it can't get more accurate than that.
Now what does it mean?
Let's break it down.
It's a JavaScript runtime.
Now what is a runtime environment?
Now the important thing to remember here is that when JavaScript was first created, it was designed
to run in the browser.
This means that it was impossible to use JavaScript to write any kind of program that's not a website,
but Node uses the V8 engine, not this eight cylinder V8 engine, but this V8 engine which comes from
chromium.
It's written in C and C plus plus.
It's blazingly fast and it powers the Chrome browser.
So we know that we can write JavaScript code to run in the browser and to provide functionality to our
websites.
But in many ways the JavaScript code that we have is locked in the browser jail.
And when Node came along it effectively liberated the JavaScript out of browser land and gave it the
freedom to allow us to use it to write any sort of application, desktop or server side.
Now that Node provides us with this JavaScript runtime so that we can run JavaScript on a machine such
as your own local computer.
Then it means that we can use JavaScript to accomplish pretty much anything that other popular server
side languages like Ruby, PHP, C-sharp, Python can do, but maintaining our full JavaScript stack
from front end to back end.
Now what about the other part of this sentence?
It's asynchronous and event driven.
What does this mean?
Well, essentially asynchronous means that your JavaScript code doesn't have to do everything sequentially.
If we think back to the scripts that we've written before, our code kind of runs from top to bottom
and we can have some functions, but essentially everything is going to happen from beginning to end
in a synchronous way.
Now what does asynchronous mean?
Well, let's say that you went on to Amazon, not that kind of Amazon, this Amazon, and you ordered
yourself something.
Now, if this process was synchronous, then it means that you would have to sit there and wait until
your parcel gets delivered and you can't do anything else in the meantime.
That's what it means to run synchronous code such as our previous scripts written in JavaScript.
It's effectively tying up the resources until some sort of event resolves, which in this case is the
delivery of your Amazon parcel.
Can you imagine a world where you had to wait for your Amazon?
Parcel and you just had to stand at the door and do nothing else after you've ordered it.
Now, I don't know what Amazon Prime is like where you live, but where I live, it takes a long time
to get one of these parcels and it would be terrible if this process was synchronous.
Now, Node, on the other hand, is asynchronous and it's event driven, so it means that you can initiate
this order and instead of having to wait for it, it can free up the resources.
And only when the event of the parcel being delivered does it then continue to run the next bits of
code.
So effectively we can parcel up these bits of code into an event so that we know that our code can be
triggered when this event happens.
In summary, the reason why we need Node is because it allows us to build an application often on a
computer using JavaScript.
And as we saw earlier, the application is a key aspect of our back end.
Now that application is going to be running on our server and that server, if you remember, is just
a computer, but it's not a browser and NodeJS is what allows us to happen.
Now, as we saw earlier, there are many, many different choices in terms of languages or technologies
that we could use for the back end.
So why are we choosing Node?
Well, the reason is because if we use Node, which is one of the most popular choices as of today,
then it means that our front end could be written in JavaScript plus HTML and CSS of course, but our
back end could also be written in JavaScript.
So effectively that allows us to use JavaScript everywhere inside our web application and this allows
us to use one language to rule them all.
So the key benefits of NodeJS are the fact that it allows us to use JavaScript across the entire stack,
which means that developers are using a language they're already familiar with, and it makes it easy
for them to transition from front end to back end developer.
And if you're writing a project yourself, then you only really need to be familiar with one language
and you can share your code between your client and server side.
In addition, Node.js allows for easy scaling of applications, making it really good for large scale
professional projects.
It's fast and it's non-blocking because of this asynchronous event driven nature of NodeJS, it can
be really fast and really efficient.
Instead of having to wait for things to happen or blocking the resources.
Finally, it's got a huge ecosystem.
It's got a really vibrant community and people have contributed thousands of open source modules and
packages to the Node package manager, which allows us to easily add functionality to our own applications.
But also it means that there's a lot of resources out there in terms of documentation.
Tutorials help people on StackOverflow who can answer your questions.
And plus we're not the only people choosing it.
Everything from LinkedIn to Twitter to Netflix is built on top of Node.js and even NASA uses Node.js.
I recently came across this report about how NASA started using NodeJS in order to keep their astronauts
safe and make their data accessible.
So if it's good enough for NASA, it's probably good enough for our project.
Now, I don't think you needed any more convincing why?
We are choosing the best possible path, but every single time I give a talk on Node.js, people always
ask me, Why don't we use a C-sharp?
Why don't we use Python or why don't we use PHP?
People are particularly obsessed with PHP for some reason and as we saw already in the last video,
node is just dominant.
It's the thing that you're going to need to know if you want to get a job.
And it's the thing that most people look for as a key skill in a web developer.
And we're trying to become web developers, right?
If you want to learn about Python and Python based backends, which are really great, if you're working
with machine learning projects or anything to do with machine learning and AI, then be sure to check
out my Python course where we cover the use of flask in the back end and using Python.
Now one final piece of interesting stat from GitHub which looks at the programming languages of code
that is committed across the entirety of GitHub.
And you can see that JavaScript is just still king.
Python is growing in popularity and for example, PHP.
For some reason I always get asked.
About this.
Why are you not teaching PHP?
Well, it's because it's not really a very good idea to teach PHP at this point.
And in fact, if you see any web development bootcamp that's teaching PHP or Ruby on Rails, then you
should probably be asking yourself if they have updated their curriculum within the last ten years.
There you have it.
You should now understand what NodeJS is, what it allows us to accomplish, and why we're choosing
it to build our backend.
In the next lesson, I'm going to be showing you how to install NodeJS on your local computer so we
can get started building applications using Node.
So for all of that and more, I'll see you there.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.