‫Now, in order to set the stage
‫for the next couple of lectures,
‫let's start by learning a bit about Node architecture.
‫So let's represent that architecture here
‫in terms of Node's dependencies,
‫which are just a couple of libraries
‫that Node depends on in order to work properly.
‫So the Node run time has several dependencies,
‫and the most important ones are
‫the V8 (mumbles) engine and libuv.
‫Now we said before that Node is a JavaScript run time
‫based on Google's V8 engine, right?
‫And so, that is why it appears here as a dependency.
‫If it wasn't for V8, Node would have absolutely no
‫way of understanding the JavaScript code that we write.
‫And therefore, V8 is a fundamental part
‫in the Node architecture.
‫So again, the V8 engine is what converts JavaScript code
‫into machine code that a computer can actually understand.
‫Okay, but that alone is not enough to create a whole
‫server side framework like Node.
‫And so that is why we also have libuv in Node.
‫And libuv is an open source library with a
‫strong focus on asynchronous IO.
‫So, input output.
‫This layer is what gives Node access to the
‫underlying computer operating system,
‫file system, networking, and more.
‫Besides that, libuv also implements two extremely
‫important features of Node.JS
‫which are the event loop and also the thread pool.
‫And in simple terms, the event loop is responsible
‫for handling easy tasks like executing call backs
‫and network IO while the thread pool is for more heavy work
‫like file access or compression or something like that.
‫But you'll learn all about that,
‫so about the event loop and the thread pool,
‫in the next couple of videos.
‫One important thing to note here
‫is that libuv is actually completely written
‫in C++ and not in JavaScript.
‫And V8 itself, also uses C++ code besides JavaScript.
‫So therefore, Node itself is a program written
‫in C++ and JavaScript and not just in JavaScript
‫as you might expect, right?
‫Now the beauty of this is that Node.JS ties all
‫these libraries together, no matter if written
‫in C++ or JavaScript and then gives us
‫developers access to their functions in pure JavaScript.
‫So it really provides us with a very nice layer
‫of abstraction in order to make our lives a lot easier
‫instead of us like having to mess with C++ code.
‫That would be a terrible experience, right?
‫So again, this architecture allows us to write
‫100 percent pure JavaScript code,
‫running in Node.JS and still access functions like
‫for file reading, which behind the scenes are
‫actually implemented in libuv or
‫other libraries in the C++ language.
‫And speaking of other libraries,
‫Node does actually not only rely on V8 and libuv,
‫but also on http-parser for parsing http,
‫c-ares or something like that for some DNS request stuff,
‫OpenSSL for keptography, and also zlib for compression.
‫And these are not that important to understand, alright?
‫So in the end, when we have all these pieces nicely
‫fit together, we end up with Node.JS ready to be used
‫on the server side all four applications.
‫And next up, you will learn more about threads
‫in Node and the thread pool.
‫So stay tuned for that one.