Hey, guys. 1
In this lesson, we're going to be learning all about the Express Framework, the framework that's built 2
on top of Node that's going to help us create our backends with ease. 3
Now, even when we're looking at the entire world of frameworks, Express comes ranking pretty high 4
amongst the professional developers. 5
And so we're going to see what exactly this framework is and why it's loved and used by so many developers. 6
Previously, I mentioned that there are many languages that you can use on the back end, and these 7
are the programming languages, 8
but in addition to languages, there are also a bunch of frameworks that you can choose. 9
Now, I mentioned that the framework that uses JavaScript is Node, but strictly speaking, Node is actually 10
not a framework, 11
instead it's a runtime environment. 12
Now we mentioned previously that what a runtime environment means is it allows us to run JavaScript 13
on the computer. 14
So Node is what enables us to use JavaScript on a computer and not just limited to within the browser. 15
Now Express, on the other hand, is actually a JavaScript framework that allows us to create backends 16
for our websites and with the powers of Node and Express combined is how most professional developers 17
build their website backends. 18
Why do we need Express anyways? 19
Because Node is too powerful and all encompassing. 20
You can use Node to do a lot of things because all it is is it allows us to run JavaScript on any computer 21
and this means that it can be used to do many things. 22
And indeed, yes, it is mostly used for web development to create the back-end for our websites, 23
but in addition, you can also use Node to maybe program your IoT device, your Internet of Things device. 24
Maybe you want a smart toaster that tweets at you and the toast is done, 25
because these days it seems like that's what IoT is all about. 26
But you can also use Node to maybe make desktop apps and in fact VS Code, which you've been using all 27
this time is created using Node.js, and it's the Node that allows this desktop application to run on your 28
computer as you've been using it right now. As we mentioned that you can use Node to do a lot of 29
things 30
and when we have a tool or a language that allows us to do many things, it generally is not very specialized 31
for one thing. 32
And right now the one thing and the one thing only that we're interested in is creating a website 33
back-end. 34
If you imagine Node as a Phillips screwdriver, it's the tool that allows us to use JavaScript on any 35
computer, not just within the browser, 36
then this tool is pretty great and it's pretty universal. 37
It allows us to do many, many tasks using JavaScript. 38
But I don't know if you've ever built anything with IKEA, but lately, I'm moving house and I'm building 39
a lot of IKEA furniture and I sort of started giving myself repetitive strain injury by trying to use 40
the Allen Key and the screwdriver to build, you know, like a Pax wardrobe or like a BILLY bookcase. 41
And then I finally gave up and I bought an electric screwdriver 42
and then my entire life changed. 43
In fact, if you are building IKEA furniture, that is a level three difficulty or above, 44
you should probably buy an electric screwdriver. 45
I know this is a programming course, but you know, this is a really important life lesson. 46
So in our case, Express is kind of like that electric screwdriver. 47
It allows us to use JavaScript and Node to create our website back end, but it is souped up and it 48
makes the whole thing so much quicker and so much easier. 49
Don't take my word for it. 50
Let's take a look at the code written using just Node to create a very simple website. 51
It's got a homepage, it's got an About Us page, and that's basically all our website has. In order to 52
do this using just Node, this is all of the code that you have to write yourself and it's a little 53
bit cumbersome and it's a little bit complicated and it's really hard for somebody to look at this code 54
straight away and know exactly what is going on. 55
Now let's compare this exact same website, but this time we're building it using Express and Node. 56
In this case, we are importing, Express and Express will interface with all the Node parts for us. 57
And look at this code. 58
Look at 59
how beautifully laid out it is and look at how modular each part is and how easy it is to understand 60
what's going on in all the different parts. 61
Now, in the last module, I could have of course, made you write out all of this in order to create 62
our first website using Node, 63
but this is almost on a level of torture and entirely unnecessary because no web developer will create 64
a website using just Node. 65
In almost all the cases, when we're creating a backend using node, we're going to be using Express. 66
Because of all these advantages; we get better readability, 67
we have to write less code, 68
we have the ability to add middleware, which I'll explain to you very soon what it is and how it acts 69
almost like Lego to enable us to choose which features we want to add to our website backend. 70
With all of these advantages plus more, it's no wonder that it's so popular amongst JavaScript backend 71
developers, even though if you've ever heard of a JavaScript framework, you'll know that there is 72
a massive amount of debate all the time, which is the best frontend framework, which is the best 73
backend framework, which is the best authentication framework, etcetera, etcetera. 74
But this is the one time where it's actually really easy to pick a JavaScript framework. When you're 75
working with Node and you're creating a website back end, a professional developer will choose the 76
Express framework because as you'll soon see, it is the best choice and it makes our lives a lot easier. 77
And also it might even spark joy. 78
And this is backed up with data. 79
So if you look at the state of JavaScript statistics, there is 100% no doubt which framework you should 80
be using when you're working with Node to generate your backend. 81
So now that we've seen what Express.js is and why it's chosen by professional developers the world over. 82
The next thing to do is to actually use it and create our very first website backend. 83
So for all of that and more, I'll see you in the next lesson.