Coding

Node.js – Tutorial – Introduction

  • 00:00:00 hey welcome everyone and welcome to a
  • 00:00:03 brand new project where we have a look
  • 00:00:05 at noches now I could imagine that many
  • 00:00:08 of you already know what no chairs is
  • 00:00:11 but I find it very important to explain
  • 00:00:13 it at the very beginning of a project
  • 00:00:15 what we're actually doing so that
  • 00:00:18 everyone is able to follow along as this
  • 00:00:20 is an introductory serious and not
  • 00:00:22 anything for the pro is doing it since
  • 00:00:24 five years so what is no chiz no js' is
  • 00:00:28 a runtime which allows us to run
  • 00:00:30 JavaScript code on the server now you
  • 00:00:33 might think okay that's new because we
  • 00:00:37 mostly use JavaScript here in the client
  • 00:00:40 in a browser we use it to enhance user
  • 00:00:42 experience by opening up modal's by
  • 00:00:45 providing live validation and so on so
  • 00:00:48 to make our applications very reactive
  • 00:00:51 that is where we mostly use javascript
  • 00:00:54 and where it is very powerful we use it
  • 00:00:56 either plain and plain JavaScript form
  • 00:00:59 or we use frameworks like jQuery or
  • 00:01:02 angular when you create single page
  • 00:01:04 applications or react or many more of
  • 00:01:06 course so this is how we use JavaScript
  • 00:01:09 in most of the cases now to understand
  • 00:01:12 how JavaScript code can run on a server
  • 00:01:15 obviously we have to think about how
  • 00:01:17 does it run in a client in a browser now
  • 00:01:21 the developers of browser applications
  • 00:01:23 they need to provide certain engines
  • 00:01:26 which interpret the chava script code
  • 00:01:28 they encounter when loading a web page
  • 00:01:30 and then I need to run this code and run
  • 00:01:34 it correctly and render the web page
  • 00:01:35 react to user experience and so on so we
  • 00:01:39 need an engine to execute that code such
  • 00:01:42 an engine is Chrome's
  • 00:01:43 v8 engine that is basically just the
  • 00:01:46 JavaScript engine developed by the guys
  • 00:01:47 at Google who set up the scrum browser
  • 00:01:49 and they well recognize the JavaScript
  • 00:01:54 used to be very slow and therefore what
  • 00:01:56 they could speed it up if you would
  • 00:01:58 transpile javascript code into machine
  • 00:02:01 code and execute it there so in a
  • 00:02:04 nutshell this is one of the reasons why
  • 00:02:06 or why v8 their JavaScript engine is
  • 00:02:09 very fast and it is this engine to this
  • 00:02:11 built into Chrome browser it
  • 00:02:14 is also open source and it's the same
  • 00:02:16 engine which powers noche ass because if
  • 00:02:19 you have the engine you can run
  • 00:02:21 JavaScript everywhere it doesn't have to
  • 00:02:23 be a browser right of course no chess
  • 00:02:26 has made some adjustments because we
  • 00:02:27 need certain functionalities when
  • 00:02:29 running it on a server when creating a
  • 00:02:31 server which you don't need an app
  • 00:02:33 rouser and so on but in general noche
  • 00:02:36 ass is using this v8 engine to run
  • 00:02:39 javascript files you give it to it and
  • 00:02:41 this is how we use it on the server side
  • 00:02:44 we create our logic in JavaScript and we
  • 00:02:49 execute it with noche ass which is able
  • 00:02:51 to interpret it and well provide us with
  • 00:02:54 a server functionality indeed it's very
  • 00:02:59 simple and very quickly done and we will
  • 00:03:01 see this in the next video to set up a
  • 00:03:03 server with nodejs
  • 00:03:05 and that's also a lot of fun so we will
  • 00:03:08 see this in a future videos this is how
  • 00:03:11 we run nodejs applications or this is
  • 00:03:15 what noches is in a nutshell of course
  • 00:03:18 now I don't want to read too many
  • 00:03:19 comments when you forget that and at
  • 00:03:21 yeah of course it's more complex than
  • 00:03:23 that but you got a minute make a point
  • 00:03:24 somewhere so this is how nodejs
  • 00:03:27 functions now one important question is
  • 00:03:30 why would we use no cheers is it better
  • 00:03:33 than let's say Ruby PHP asp.net anything
  • 00:03:38 like this is it worse it depends on what
  • 00:03:42 does it depend while there are certain
  • 00:03:44 advantages and disadvantages a huge
  • 00:03:47 advantage of node.js is well it's
  • 00:03:51 JavaScript code therefore if you're used
  • 00:03:54 to JavaScript from let's say front-end
  • 00:03:56 development you don't have to learn a
  • 00:03:58 completely different new language you
  • 00:04:01 can use the same language and if you
  • 00:04:03 switch frequently between front and back
  • 00:04:06 and tasks you don't lose your context
  • 00:04:08 each time you don't have to get back
  • 00:04:10 into PHP and then back into JavaScript
  • 00:04:12 but you say in the same context so that
  • 00:04:15 is a not to forgotten advantage that you
  • 00:04:19 can stay in one language and that you
  • 00:04:22 can really excel in one language instead
  • 00:04:24 of learning
  • 00:04:25 and different ones so this really is an
  • 00:04:29 advantage and now red Vantage is is that
  • 00:04:33 it is a non-blocking which means it uses
  • 00:04:36 one thread but it's asynchronous by
  • 00:04:40 nature so it is very fast – it's very
  • 00:04:44 good at handling multiple multiple
  • 00:04:46 thousands of requests at the same time
  • 00:04:49 what it's not that good at though is
  • 00:04:51 handling a single data intensive
  • 00:04:54 requests there are better languages for
  • 00:04:58 stuff like that it can be slow it's not
  • 00:05:00 fast in every situation but it's
  • 00:05:02 generally fast when yeah when serving
  • 00:05:06 multiple clients at the same time
  • 00:05:09 multiple requests at the same time and
  • 00:05:11 now we're disadvantages even though no
  • 00:05:14 Chiu's now has a couple of years on its
  • 00:05:16 back it's still not even close
  • 00:05:19 as mature as let's say Ruby or PHP or
  • 00:05:24 dotnet is it is still very new even
  • 00:05:29 though it has matured a bit and
  • 00:05:30 therefore well getting into it can be a
  • 00:05:34 bit hard it's in development constantly
  • 00:05:38 so there it's a very dynamic language
  • 00:05:40 and you won't find that that many
  • 00:05:44 resources that you might find on more
  • 00:05:46 mature ease or languages so that are the
  • 00:05:50 disadvantages and advantages you might
  • 00:05:51 think about but overall I have to say
  • 00:05:54 it's a lot of fun it fits this channel
  • 00:05:57 obviously well as we now came from
  • 00:06:00 angular war 2 and dive directly into no
  • 00:06:04 chairs and yeah I like working with it I
  • 00:06:08 hope you will like it too
  • 00:06:11 after having seen this complete serious
  • 00:06:14 in the next video we're going to start
  • 00:06:17 with setting up our noche ass and wire
  • 00:06:20 loom and which is very easy and writing
  • 00:06:23 our first application see you there
  • 00:06:25 bye