<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jeremiah Okon</title>
    <description>The latest articles on DEV Community by Jeremiah Okon (@jerncomania).</description>
    <link>https://dev.to/jerncomania</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F798924%2Fce122926-24d8-4b27-8eb0-718b4e57931d.jpg</url>
      <title>DEV Community: Jeremiah Okon</title>
      <link>https://dev.to/jerncomania</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jerncomania"/>
    <language>en</language>
    <item>
      <title>How Does Node Handle Asynchronous Tasks?</title>
      <dc:creator>Jeremiah Okon</dc:creator>
      <pubDate>Mon, 24 Oct 2022 14:30:40 +0000</pubDate>
      <link>https://dev.to/jerncomania/how-does-node-handle-asynchronous-tasks-5eal</link>
      <guid>https://dev.to/jerncomania/how-does-node-handle-asynchronous-tasks-5eal</guid>
      <description>&lt;p&gt;It is critical for developers to understand the internal workings of the languages, or in this case, runtimes, that we use for development processes.&lt;/p&gt;

&lt;p&gt;Some are familiar with the fact that we use NodeJS for backend development as opposed to other solid programming languages such as Python, Go, Ruby, etc. NodeJs runs on Javascript.&lt;/p&gt;

&lt;p&gt;Javascript is a single-threaded language that is synchronous but can perform asynchronous operations through its runtime environment. &lt;/p&gt;

&lt;p&gt;Node, like the browser, is a runtime environment that allows us to write JavaScript outside of the browser. When you run JavaScript outside of your browser, you are most likely running Node.&lt;/p&gt;

&lt;p&gt;There are several engines that aid in the translation of Javascript into Machine Language, the most popular of which is the V8 Engine, on which NodeJS was built.&lt;br&gt;
The diagram below depicts the process that every JavaScript code must go through for your hardware to understand the instructions it is given.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dVXcFm6N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2v27ebu8nawspfvomm6g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dVXcFm6N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2v27ebu8nawspfvomm6g.png" alt="Javascript Execution Diagram" width="880" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This applies to any place where Javascript code exists, including the browser, Node, and other runtimes such as Dino.&lt;/p&gt;

&lt;p&gt;The purpose of this article is to inform us how JavaScript performs asynchronous tasks in Node. As we all know, running Javascript outside of the browser removes all inbuilt *&lt;em&gt;window *&lt;/em&gt; object methods that account for Javascript's asynchronicity.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yB0_fs1m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/evskxoy600j1i0s40xrk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yB0_fs1m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/evskxoy600j1i0s40xrk.png" alt="Asynchronous process in Node" width="880" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some of our Javascript code may now require additional features that are not present in Javascript, such as network requests (HTTP/HTTPS), file systems, and so on. The engine uses the Runtime APIs (Node APIs), and even though some of these features are written in Javascript, they must call their equivalent functions in a low-level language like C++, specifically via &lt;strong&gt;NODE BINDINGS&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Node bindings&lt;/strong&gt; are what allow your Javascript code to call functions written in C and C++.&lt;/p&gt;

&lt;p&gt;C and C++ codes are tested and well-optimized codes for encrypting your data or accessing your file system regardless of your operating system. Actual implementations of these can be found in the &lt;strong&gt;libuv&lt;/strong&gt; library.&lt;/p&gt;

&lt;p&gt;The two most important components in &lt;strong&gt;Node.js&lt;/strong&gt; are &lt;strong&gt;libuv&lt;/strong&gt; and the &lt;strong&gt;v8&lt;/strong&gt; Engine. When an input task is delegated by Node, &lt;strong&gt;libuv&lt;/strong&gt; accepts it and returns an output response.&lt;/p&gt;

&lt;p&gt;Node, like a request and response tree, makes a Javascript request to obtain a webpage. &lt;/p&gt;

&lt;p&gt;Because Javascript cannot make network requests natively, it uses the HTTP module provided by the Node APIs to call the equivalent functions for making network requests in low-level languages such as C and C++, using Node Bindings to perform this action. &lt;/p&gt;

&lt;p&gt;The code execution is then triggered in the Libuv library after Node has delegated that task to parts of the operating system. &lt;/p&gt;

&lt;p&gt;It moves on to perform other tasks without waiting for the request to be completed. &lt;br&gt;
This whole process above is referred to as &lt;strong&gt;asynchronous I/O&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nodejs excels at dealing with tasks asynchronously.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>Is JavaScript a Synchronous or Asynchronous Language?</title>
      <dc:creator>Jeremiah Okon</dc:creator>
      <pubDate>Sun, 23 Oct 2022 19:11:31 +0000</pubDate>
      <link>https://dev.to/jerncomania/is-javascript-a-synchronous-or-asynchronous-language-226b</link>
      <guid>https://dev.to/jerncomania/is-javascript-a-synchronous-or-asynchronous-language-226b</guid>
      <description>&lt;p&gt;As obvious as the answer might seem to some, explaining why it is synchronous might be difficult. To others, it might be confusing, as it is evident that you can perform both synchronous and asynchronous calls with JavaScript.&lt;/p&gt;

&lt;p&gt;Here is a simple explanation that might come in handy when trying to explain the difference.&lt;/p&gt;

&lt;p&gt;Pondering on this, I figure the answer to this question lies in the question below.&lt;/p&gt;

&lt;p&gt;What is the Difference Between a Javascript Engine and a Javascript Runtime Environment?&lt;/p&gt;

&lt;p&gt;A Javascript engine is simply a program or software that interprets and executes Javascript code. There are different engines for different browsers. Chrome uses the v8 engine , Firefox uses SpiderMonkey, etc.&lt;/p&gt;

&lt;p&gt;A Javascript runtime environment executes Javascript code as well as other tasks such as call stacks, heaps, and event loops.&lt;/p&gt;

&lt;p&gt;As some may be aware, the browser acts as a runtime environment for JavaScript, allowing it to perform asynchronous tasks. Functions such as setTimeOut, alert, and prompt are not native to Javascript; they are contained in the browser window object, and because the Javascript engine cannot interpret these functions , they are related to the browser API ( window object).&lt;/p&gt;

&lt;p&gt;I should mention that Node is also a Javascript runtime environment because it uses Node bindings to libuv to call functions that are not executable by the Javascript Engine outside the browser.&lt;/p&gt;

&lt;p&gt;So, to return to the original question, is JavaScript a synchronous language? Javascript is, indeed, a synchronous language.&lt;br&gt;
So, how are asynchronous operations carried out? It makes use of the Runtime Environment Libraries to perform asynchronous operations.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>runtime</category>
      <category>v8</category>
    </item>
  </channel>
</rss>
