1
00:00:00,480 --> 00:00:05,130
Welcome back in this lesson I'm going to introduce Express which is the framework that we're going to

2
00:00:05,130 --> 00:00:07,110
use throughout the rest of this course.

3
00:00:07,140 --> 00:00:09,450
There are three main questions that I want to answer here.

4
00:00:09,750 --> 00:00:11,790
The first one is what is a framework.

5
00:00:12,000 --> 00:00:13,960
How is it different from a library.

6
00:00:14,010 --> 00:00:16,130
The next is what is express.

7
00:00:16,170 --> 00:00:20,270
And then the last one is Why are we using EXPRESS Why are we teaching express in particular.

8
00:00:20,430 --> 00:00:24,240
Let's get going and we'll start by talking about what a framework is.

9
00:00:24,270 --> 00:00:30,450
Up until this point we've used a few libraries including Jay equerry and bootstrap but also some people

10
00:00:30,450 --> 00:00:37,260
would refer to the Cat me and knock knock jokes packages as libraries are definitions so far of a library

11
00:00:37,560 --> 00:00:42,410
is that it's code that someone else wrote that we can include in our application and use.

12
00:00:42,450 --> 00:00:46,290
So that's also what frameworks our frameworks are code that someone else wrote.

13
00:00:46,350 --> 00:00:51,000
Usually a lot of people wrote because it's a lot more code that we can use instead of our application

14
00:00:51,000 --> 00:00:51,240
.

15
00:00:51,240 --> 00:00:53,530
But the way that we use them is very different.

16
00:00:53,700 --> 00:00:58,140
So I have a great stack overflow post I'm going to pull up and it talks about the difference between

17
00:00:58,140 --> 00:00:59,870
a framework and a library.

18
00:01:00,090 --> 00:01:05,100
And this first answer really nails it on the head so I'll just read a few of the more important lines

19
00:01:05,400 --> 00:01:06,870
including this first one.

20
00:01:07,080 --> 00:01:12,090
The most important difference and in fact the defining difference between a library and a framework

21
00:01:12,480 --> 00:01:15,360
is something called inversion of control.

22
00:01:15,390 --> 00:01:16,480
What does this mean.

23
00:01:16,800 --> 00:01:21,950
Well it means that when you call a library you're in control but with a framework that control is inverted

24
00:01:21,940 --> 00:01:22,230
.

25
00:01:22,260 --> 00:01:26,250
The framework calls you and then I'll skip down to this section here.

26
00:01:26,250 --> 00:01:31,020
Basically all the control flow is already in the framework and there's just a bunch of predefined white

27
00:01:31,020 --> 00:01:36,690
spots that you can fill out with your own code a library on the other hand is a collection of functionality

28
00:01:36,900 --> 00:01:42,720
that you can call those two excerpts do a great job of summarizing the differences both frameworks and

29
00:01:42,720 --> 00:01:47,700
libraries are external code that you're including in your own application but a library is something

30
00:01:47,700 --> 00:01:53,610
that you're in control of if you want to use a library you can use one method 10 methods just like if

31
00:01:53,610 --> 00:01:54,810
we include a query.

32
00:01:54,810 --> 00:01:56,790
It's up to us which parts of it we use.

33
00:01:56,790 --> 00:02:02,760
We might only use a few of the methods for animations or we might use 100 different methods with a framework

34
00:02:02,760 --> 00:02:03,560
on the other hand.

35
00:02:03,690 --> 00:02:08,220
We give up a little bit of control where if we use a framework like the one we're going to use which

36
00:02:08,220 --> 00:02:14,490
is express We have some decisions that have been made for us that we have to abide by in order to use

37
00:02:14,490 --> 00:02:19,500
the framework I like to think of it a little bit like Mad Libs where a framework gives us the basic

38
00:02:19,500 --> 00:02:22,890
scaffolding and then we fill in the blanks with the important parts.

39
00:02:23,130 --> 00:02:28,470
But I want to make it really clear the point of a framework is not to replace any sort of creativity

40
00:02:28,500 --> 00:02:31,440
or homogenize the way that all applications work.

41
00:02:31,710 --> 00:02:36,750
What frameworks really do is they take all of the common stuff that we do in every application all the

42
00:02:36,750 --> 00:02:42,330
setup work all the basic things that every app needs and it just prepackage it all up so that we can

43
00:02:42,330 --> 00:02:47,250
use it and get started on new apps without having to do all the basic ground work every single time

44
00:02:47,250 --> 00:02:47,680
.

45
00:02:47,700 --> 00:02:52,490
So when we read an application we just focus on the important content of the application.

46
00:02:52,650 --> 00:02:53,940
What makes it unique.

47
00:02:54,030 --> 00:02:58,860
Rather than spending time working on the very very basic stuff every single time we make a new application

48
00:02:58,880 --> 00:02:59,160
.

49
00:02:59,430 --> 00:03:03,800
So as I mentioned Express's what were going to use Express is a framework.

50
00:03:03,960 --> 00:03:06,810
And in particular its a web development framework.

51
00:03:07,050 --> 00:03:09,250
There are all sorts of different frameworks out there.

52
00:03:09,270 --> 00:03:14,550
There are frameworks that help you make videogames or frameworks that how we make mobile apps and there

53
00:03:14,550 --> 00:03:17,280
are tons and tons of frameworks to make web applications.

54
00:03:17,280 --> 00:03:21,880
Express is one of those other frameworks that exist across all languages.

55
00:03:22,020 --> 00:03:28,500
Include things like flask for Python Django for Python rails for Ruby Sinatra for Ruby and there are

56
00:03:28,530 --> 00:03:31,800
even other Noad web development frameworks like sales.

57
00:03:31,810 --> 00:03:32,310
J.S..

58
00:03:32,310 --> 00:03:38,220
Which is another relatively popular one but Express is the one that we're going to use.

59
00:03:38,220 --> 00:03:41,020
And let me just show you before we talk about why we're using it.

60
00:03:41,040 --> 00:03:43,980
Let me go over to an application they have created.

61
00:03:43,980 --> 00:03:49,220
This is another cloud nine instance I have running and this is an express app.

62
00:03:49,560 --> 00:03:56,310
So all of this right here all of these files and directories are all part of an express application

63
00:03:57,000 --> 00:04:02,190
and by using Express I was able to focus on just writing the application code not having to focus on

64
00:04:02,190 --> 00:04:07,260
all the basic legwork of creating a server and dealing with routes and connecting to a database and

65
00:04:07,260 --> 00:04:12,840
all the basic steps that every app requires instead of just focused on the application content.

66
00:04:12,960 --> 00:04:18,390
Shortly we'll be creating our own apps that look like this where we have 20 30 different files in 10

67
00:04:18,390 --> 00:04:23,460
or 15 different directories all sorts of different packages that were installing and including There

68
00:04:23,460 --> 00:04:28,320
will be tons of moving pieces but Express is the glue that keeps everything together.

69
00:04:28,320 --> 00:04:32,730
What I'm saying will make a lot more sense once you actually start writing apps and the next video and

70
00:04:32,730 --> 00:04:35,120
you see what Express actually does for you.

71
00:04:35,130 --> 00:04:39,340
So the one other thing that I want to talk about is why are we using Express.

72
00:04:39,380 --> 00:04:41,190
I said there are a lot of different frameworks.

73
00:04:41,190 --> 00:04:42,810
Why are we going with Express.

74
00:04:42,810 --> 00:04:48,390
My answer is very similar to the answer I gave as far as why were learning node why were using javascript

75
00:04:48,390 --> 00:04:53,370
on the backend instead of Ruby or Python or ph P in that theres a few reasons.

76
00:04:53,370 --> 00:04:56,000
The first reason is that express is by far.

77
00:04:56,040 --> 00:04:59,510
Without a doubt the most popular node web development framework.

78
00:04:59,580 --> 00:05:04,100
It has the most downloads on NPM it has and most people contributing to it on get habbe.

79
00:05:04,170 --> 00:05:09,210
Its just the most widely used node framework which is always a great reason for us to use it not just

80
00:05:09,210 --> 00:05:14,100
because its trendy not just because people say that its good but more so because theres lots of tutorials

81
00:05:14,160 --> 00:05:18,930
and theres a big community of people who know express who are writing about and talking about it which

82
00:05:18,930 --> 00:05:22,130
is always something you want to look for when you're learning a new technology.

83
00:05:22,290 --> 00:05:26,610
And the second reason that we're using Express is a little more complex to explain a need to give you

84
00:05:26,610 --> 00:05:30,120
a little bit of backstory on the different types of frameworks that we can have.

85
00:05:30,180 --> 00:05:33,630
There are two terms that people will use to describe frameworks.

86
00:05:33,630 --> 00:05:37,840
Those are heavy and light or heavy weight and light weight heavy weight and light weight.

87
00:05:37,850 --> 00:05:42,880
Referred to how much your framework does for you versus how much you have to do yourself.

88
00:05:42,900 --> 00:05:48,750
So think of it if were talking about Mad Libs again a framework thats heavyweight really has a lot of

89
00:05:48,750 --> 00:05:54,180
text in there and just a few blanks that you feel in a framework thats lightweight has a lot more blanks

90
00:05:54,270 --> 00:05:59,040
a lot more frequently across the page where you're expected to go in and fill in your own code more

91
00:05:59,040 --> 00:05:59,840
often.

92
00:05:59,880 --> 00:06:05,340
So where express fits into all of this is that it's a very lightweight framework so it doesn't hide

93
00:06:05,340 --> 00:06:08,850
things from you it doesn't do things you don't expect it to do.

94
00:06:08,880 --> 00:06:14,610
You use Express and you know exactly what you're getting versus a framework like rails which I love

95
00:06:14,610 --> 00:06:19,320
rails by the way I'm not trashing it but when you teach people rails it's really problematic because

96
00:06:19,320 --> 00:06:22,290
it does so much for them and you can make apps fast.

97
00:06:22,290 --> 00:06:27,150
But students don't understand what it's doing because they've never seen a framework that doesn't do

98
00:06:27,150 --> 00:06:27,880
that for them.

99
00:06:28,050 --> 00:06:32,530
So I've noticed that students who learn with a framework like Rails as their very first framework a

100
00:06:32,550 --> 00:06:37,950
very heavyweight framework where they only fill in a few blanks they end up being very reliant on rails

101
00:06:38,400 --> 00:06:42,840
and they don't understand the underlying concepts and they can't work with a framework that isn't Rail's

102
00:06:43,500 --> 00:06:47,400
or at least it takes more effort for them to learn the rails way of doing things.

103
00:06:47,490 --> 00:06:52,350
So Express on the other hand is much lighter weight and that doesn't mean that it's less powerful or

104
00:06:52,350 --> 00:06:55,380
that you can't use Express to do things that you can do in Rails.

105
00:06:55,380 --> 00:06:59,850
It just means that you need to understand how things work in order to get things done in Rails.

106
00:06:59,850 --> 00:07:03,280
You can make an awesome web app without really knowing what the heck you're doing.

107
00:07:03,540 --> 00:07:08,250
So in my mind that's really the main reason that I'm teaching express Yes it's popular and there's a

108
00:07:08,250 --> 00:07:12,900
large community behind it but more importantly it's just a great tool to learn how to make web apps

109
00:07:12,900 --> 00:07:18,840
with blessing I'll do here is show you the official express home page first thing that you might notice

110
00:07:19,020 --> 00:07:20,270
is this little blurb here.

111
00:07:20,340 --> 00:07:25,620
That express is a fast and opinionated minimalist web framework for Noj Yes.

112
00:07:25,860 --> 00:07:29,730
And this word unin piñon it'd when it's referring to a framework.

113
00:07:29,760 --> 00:07:32,100
What that means is that it's flexible.

114
00:07:32,100 --> 00:07:38,340
It lets you do things in the way that you want versus rails if you use Rails Rail's it's extremely opinionated

115
00:07:38,340 --> 00:07:38,650
.

116
00:07:38,700 --> 00:07:43,950
You have to make files named a very particular way they have to go in a very particular place with Express

117
00:07:43,950 --> 00:07:43,970
.

118
00:07:43,980 --> 00:07:47,340
We have more freedom to decide how we're going to structure things.

119
00:07:47,340 --> 00:07:52,960
You can also see that we install it just like any other package and PM install Express will learn what

120
00:07:52,960 --> 00:07:55,180
the dash dash save means in the next video.

121
00:07:55,430 --> 00:07:59,300
And to finish up on here I highly recommend you check out the Getting Started Guide.

122
00:07:59,340 --> 00:08:03,930
If you have any questions and there are some other great resources on here as well including their official

123
00:08:03,930 --> 00:08:08,900
guide API reference some advanced topics that we'll talk about at the end of the course.

124
00:08:09,000 --> 00:08:14,820
The great list of resources including books and blogs some great tutorials and a glossary that will

125
00:08:14,820 --> 00:08:16,710
come back to you later in the course as well.

126
00:08:16,710 --> 00:08:18,330
All right so let's wrap this up.

127
00:08:18,390 --> 00:08:19,160
What is a framework.

128
00:08:19,170 --> 00:08:23,580
How is it different from a library framework it's just a bunch of code that someone else has written

129
00:08:23,610 --> 00:08:26,320
just like a library is except when we use a framework.

130
00:08:26,340 --> 00:08:27,620
We have less control.

131
00:08:27,900 --> 00:08:34,050
And the goal of using one is to make our development of whatever it is a game a web app a mobile application

132
00:08:34,050 --> 00:08:34,430
.

133
00:08:34,650 --> 00:08:37,340
We want to make things faster so we use a framework.

134
00:08:37,590 --> 00:08:43,330
Express is one framework for web development and it happens to be a node framework.

135
00:08:43,440 --> 00:08:48,480
There are other web development frameworks out there but we're using Express and we're using it because

136
00:08:48,480 --> 00:08:49,290
it's popular.

137
00:08:49,350 --> 00:08:50,550
Lots and lots people use it.

138
00:08:50,550 --> 00:08:52,870
There's great documentation and tutorials.

139
00:08:53,010 --> 00:08:58,890
It's widely used and supported but also and even more importantly it's a great first framework for someone

140
00:08:58,890 --> 00:09:05,110
to learn all right in the next video we're going to install Express and make our first simple application
