if you're still using Express you might potentially be holding yourself back so nestjs has passed Express in terms of the number of GitHub Stars which makes it officially the most Lov backend framework in the entire world I have extensively used both Frameworks and in this video I'll show you the key differences between them and why njs seems to be taking over but don't feel sad for Express despite NES js's growing popularity I'll explain why Express is here to stay and and why in a way it might never lose the number one spot a picture njs
as a super smart young architect who very organized methodical and buil massive skyscrapers and on the other hand Express J is like an old minimalist who lives in the forest and can build anything he needs thanks to his extreme creativity and survival skills so if you choose to work with Nest you'll have a lot of rules to follow and the framework gives you clear guidance and strong recommendations on how to structure your application so the framework holds your hands as you build the application but on the other hand if you choose express you'll have less
guidance and fewer tools to work with but you have more freedom to express your creativity so DJs is described as opinionated and express as unopinionated so I don't entirely agree with that categorization but I'll explain it later so now let's talk about typescript nestjs fully Embraces typescript which means that you get all the benefits of static typing and reliability and Express on the other hand primarily gives you more flexibility and you can use JavaScript or typescript so which one should you choose so the boring answer would be it depends on your use case there is
no one siiz fits all but by Hest opinion just pick njs so you'll be able to do anything you can do with Express and more so yes Nest might come with features you don't need and you won't use and it's not as lightweight as Express but I feel like for many use cases it really doesn't matter and even if you new to backend development I would still recommend starting with Nest you will learn a lot more in my opinion it's a better investment long term but once you've mastered nestjs go back and learn express it
will take you no time and it will actually help you understand Nest even [Music] more that's because nestjs uses Express by default so remember the young architect and the old minimalist they are actually related which means that they share many of the same characteristics just like Express nestjs has the concept of middleware and it uses request and response objects as well and many library that are used for Express can be used in Nest or at at least they have some adapters equivalent for nest so in a way there is a big overlap between the Express
and the nest ecosystem so now here is where it gets interesting it's very easy to fall into that initial caricature of nestjs being opinionated and being a very rigid framework and I have found that njs gives you a lot of default behavior and strongly hints at how you should do things but at the same time you can actually customize a lot of things and deviate from the default Behavior so we've already mentioned middleware but you also have many other ways of hooking into the request La cycle you can customize the way you handle errors NJ
has built-in validation pipes but you can create your own custom validation and transformation logic njs has the concept of modules and decorators but once again you can create custom Factory functions to create those modules and create your custom decorators so while n chest might seem more restrictive at first glance it actually offers a lot more flexibility than you might expect it gives you the best of both worlds structure when you want it and freedom when you need it personally I've never been in a position where I felt like there was something I couldn't do because
of the framework constraints and [Music] rigidity that being said even if nestjs has more stars than Express there is a good reason why Nest itself uses Express so Express is a simple framework and I say this as a compliment so it's the perfect example of doing one thing well so Express's goal is to create a web server and it does it very well so some people says that it's failing because it doesn't have frequent releases well why change things if they are not broken so that's that's what I think then on the other hand njs
is a framework that tries to achieve a lot so it does web servers it also does microservices with different transport mechanism it has recommendations on how to do authentication graphql validation Etc so which makes it very appealing to development teams because they can do a lot in a very consistent way and by the way you have several other backend Frameworks that are built on top of Express so really the comparison between nest and express doesn't fully make sense because the two Frameworks have different goals so Express is a focused framework and people have been building
and sharing their middleware libraries and even built framework on top of it so this means that Express has a massive ecosystem of plugins and middleware and it's been around longer so there is a solution for pretty much everything and that's why I believe Express is here to stay and since it's here to stay you can watch this video and learn all about the fundamentals of Express Jaz and in that video I'll be building an API from scratch step by steps for you to follow along