<?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: ikbal arslan</title>
    <description>The latest articles on DEV Community by ikbal arslan (@ikbalarslan).</description>
    <link>https://dev.to/ikbalarslan</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%2F1526137%2F8d730079-59dd-4c6e-9199-2ea65c216943.jpeg</url>
      <title>DEV Community: ikbal arslan</title>
      <link>https://dev.to/ikbalarslan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ikbalarslan"/>
    <language>en</language>
    <item>
      <title>Javascript Equality Check</title>
      <dc:creator>ikbal arslan</dc:creator>
      <pubDate>Mon, 27 May 2024 18:58:19 +0000</pubDate>
      <link>https://dev.to/ikbalarslan/javascript-equality-check-37m6</link>
      <guid>https://dev.to/ikbalarslan/javascript-equality-check-37m6</guid>
      <description>&lt;p&gt;In javascript equality sign&lt;code&gt;=&lt;/code&gt; is used for assigning variables so we use something different to check equality.&lt;/p&gt;

&lt;p&gt;In javascript, we have three ways to check equality:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;double equals &lt;code&gt;==&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;triple equals &lt;code&gt;===&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Object.is()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  == (double equals)
&lt;/h3&gt;

&lt;p&gt;Double equals will allow coercion&lt;br&gt;
this is the algorithm for double equals:&lt;br&gt;
1 - if types are the same do the rest of the calculations with triple equals&lt;br&gt;
2 - null and undefined are equal to each other.&lt;br&gt;
3 - if any side is reference type call ToPrimitive()&lt;br&gt;
4 - if we have two different primitive types convert both of them to numbers then do the equality check.&lt;/p&gt;

&lt;p&gt;Since double equals allow coercion it allows some corner cases as well &lt;/p&gt;

&lt;p&gt;for example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[] == ![] // true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For not dealing with corner cases we shouldn't use these with double equals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;don't use 0,"", " " &lt;/li&gt;
&lt;li&gt;don't use reference types&lt;/li&gt;
&lt;li&gt;don't compare with a boolean&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;If the types are equal it will send it to triple equals anyway&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  === (triple equals)
&lt;/h3&gt;

&lt;p&gt;It doesn't allow coercion. first, it checks the types if the types are equal it will check values then it will check equality.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 === "1" //Since the types are not equal its false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Object.is()
&lt;/h3&gt;

&lt;p&gt;It behaves the same as the triple-equals operator except &lt;code&gt;NaN&lt;/code&gt; and &lt;code&gt;+0&lt;/code&gt; and &lt;code&gt;-0&lt;/code&gt;.&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

1 === 1; // true
Object.is(1, 1); // true

+0 === -0; // true
Object.is(+0, -0); // false

NaN === NaN; // false
Object.is(NaN, NaN); // true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
    </item>
    <item>
      <title>Javascript Coercion Corner Cases</title>
      <dc:creator>ikbal arslan</dc:creator>
      <pubDate>Mon, 27 May 2024 18:22:39 +0000</pubDate>
      <link>https://dev.to/ikbalarslan/javascript-coercion-corner-cases-4i68</link>
      <guid>https://dev.to/ikbalarslan/javascript-coercion-corner-cases-4i68</guid>
      <description>&lt;p&gt;Like any other language, JavaScript also has some corner cases, so it is a good idea to learn them. today I want to show you a corner case about auto coercion.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 &amp;lt; 2 &amp;lt; 3 // true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this code the answer is true. but how let's check it step by step.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;step 1 -&amp;gt; (1 &amp;lt; 2) &amp;lt; 3  
step 2 -&amp;gt; (true) &amp;lt; 3
step 3 -&amp;gt; 1 &amp;lt; 3 // true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, the answer becomes true by chance.&lt;br&gt;
let's check another one&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3 &amp;gt; 2 &amp;gt; 1; // false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mathematically this should be true but the execution says it is false lets check the code step by step&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;step 1 -&amp;gt; (3 &amp;gt; 2) &amp;gt; 1
step 2 -&amp;gt; (true) &amp;gt; 1
step 3 -&amp;gt; 1 &amp;gt; 1 // one is not bigger than one so should be false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whenever you do any calculation please keep in mind the auto coercion. because math and code do not always say the same thing&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Javascript Boxing and Unboxing</title>
      <dc:creator>ikbal arslan</dc:creator>
      <pubDate>Mon, 27 May 2024 18:03:59 +0000</pubDate>
      <link>https://dev.to/ikbalarslan/javascript-boxing-and-unboxing-4o9g</link>
      <guid>https://dev.to/ikbalarslan/javascript-boxing-and-unboxing-4o9g</guid>
      <description>&lt;h2&gt;
  
  
  Boxing
&lt;/h2&gt;

&lt;p&gt;Javascript primitive data types are not an object so it shouldn't have methods and properties right?&lt;/p&gt;

&lt;p&gt;Did you know that number and string primitive values can act like reference types so we can use methods and properties with them?&lt;/p&gt;

&lt;p&gt;By default when we run the javascript objects inside of the &lt;code&gt;__proto__&lt;/code&gt; and we can use them in our code.&lt;br&gt;
some of the objects inside are &lt;code&gt;String&lt;/code&gt; and &lt;code&gt;Number&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;Whenever we want to use methods or properties on primitive types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;if the type is a string  it will wrap it with the String object from proto&lt;/li&gt;
&lt;li&gt;if the type is a number  it will wrap it with the Number object from the proto&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is called auto-boxing, think of the objects as a big box and we put primitive types as small boxes inside of the objects so we can use all the methods and properties.&lt;/p&gt;

&lt;p&gt;For some reason, we can use methods and properties with primitive types. The reason is called boxing and it is automatically applied to primitive types.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

var car = "ford";

console.log(car);
car.length // 4


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F870ngfxwea8019d42ivw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F870ngfxwea8019d42ivw.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this case, the type of the car is a string which is a primitive type&lt;br&gt;
in the console.log(car) everything will be normal.&lt;br&gt;
but in the next line we are using a method that only reference types have so behind the scenes javascript will put this variable inside of the String object from proto so we can access to the methods.&lt;/p&gt;




&lt;h2&gt;
  
  
  UnBoxing
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

{a : 4} &amp;gt; {a : 5}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In this case, when we want to compare two objects we can't do that. we can only compare primitive types. &lt;/p&gt;

&lt;p&gt;To do this calculation we need to convert them to the primitive types. for this, we have a method which is ToPrimitive(). it will call this method default to convert them to primitive types.&lt;/p&gt;

&lt;p&gt;So behind the scenes, the calculation will be like this &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

ToPrimitive({a:4}) &amp;gt; ToPrimitive({a:5})  //false


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Since we are converting reference types to primitive types that called un-boxing.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Javascript Working Mechanism</title>
      <dc:creator>ikbal arslan</dc:creator>
      <pubDate>Mon, 27 May 2024 16:13:35 +0000</pubDate>
      <link>https://dev.to/ikbalarslan/javascript-working-mechanism-351n</link>
      <guid>https://dev.to/ikbalarslan/javascript-working-mechanism-351n</guid>
      <description>&lt;p&gt;when the javascript engine starts executing the code it does :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;executing code line by line&lt;/li&gt;
&lt;li&gt;store the data after executing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and it knows the order of executions via call stack. at the bottom of the call stack, there is always a global execution context that will stay.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Running the code is also known as Execution Context&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;as an example let's analyze this code&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpezh736jkwyvuk2z4py9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpezh736jkwyvuk2z4py9.png" alt="Image description" width="792" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;while executing this code by order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- in the memory create a variable and name it a after that set 12 as the value.
- in the memory create a variable and name it square after that set a function definition as a value
- in the memory create a variable and name it sum after that set a function definition as a value
- call the sum 
     - push sum on top of the call stack
     - get the function definition from the global memory
     - create a brand new execution context for sum.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo8dn6a9c1awxowpm9r4t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo8dn6a9c1awxowpm9r4t.png" alt="Image description" width="792" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; - create a local memory for the execution context
 - create a variable in the local memory and name it twoSquare until finding the value set null as a value
 - call the square function:
     - push the square function on top of the call stack
     - get the function definition from global memory
     - create a new execution context for square
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fecxwud2u40s6poa9o1wc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fecxwud2u40s6poa9o1wc.png" alt="Image description" width="792" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     - return the value 4 as a result of the function and set it to the twoSquare value 
     - remove(pop) the square function from the call stack
     - The square execution context will be destroyed by the garbage collector.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3l0md4xuorfigeiomvbu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3l0md4xuorfigeiomvbu.png" alt="Image description" width="792" height="395"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
- get the value of the variable a from the global variable 
- calculate the execution context and return the value 16 as a result of the function 
- remove the function sum from the call stack 
- garbage collector will destroy the execution context for function sum

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnb7ntbueo3b237xeyme0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnb7ntbueo3b237xeyme0.png" alt="Image description" width="792" height="398"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- then console log hello
- end the global execution context
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>core</category>
    </item>
    <item>
      <title>Javascript Memory Management</title>
      <dc:creator>ikbal arslan</dc:creator>
      <pubDate>Sun, 26 May 2024 22:07:42 +0000</pubDate>
      <link>https://dev.to/ikbalarslan/javascript-memory-management-188l</link>
      <guid>https://dev.to/ikbalarslan/javascript-memory-management-188l</guid>
      <description>&lt;p&gt;When the javascript engine starts executing the code it will store variables inside of the memory. for storing data, runtime uses two different memory:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stack memory&lt;/li&gt;
&lt;li&gt;Heap memory&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Javascript only can communicate with stack memory.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Before explaining the differences around these memories I should explain the data types in javascript. In javascript, we have two different data types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Primitive types: primitive types stored directly in the stack

&lt;ul&gt;
&lt;li&gt; String, Number, Boolean, Null, Undefined, Symbol, BigInt&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;Reference types: Stored in the heap and accessed by reference from Stack

&lt;ul&gt;
&lt;li&gt; Arrays, Functions, Objects&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6p86rf5cwvfsar05joyu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6p86rf5cwvfsar05joyu.png" alt="Image description" width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;For maximum optimization in the memory space javascript engine uses something called garbage collector. it will clean the value immediately when a value is not reachable via a variable(label).&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Javascript Engine</title>
      <dc:creator>ikbal arslan</dc:creator>
      <pubDate>Sun, 26 May 2024 21:08:52 +0000</pubDate>
      <link>https://dev.to/ikbalarslan/javascript-runtime-37i8</link>
      <guid>https://dev.to/ikbalarslan/javascript-runtime-37i8</guid>
      <description>&lt;p&gt;JavaScript is not directly understood by computers but the browsers have an inbuilt JavaScript engine which helps to convert our JavaScript program into computer-understandable language. So whenever someone talks about running code they are talking about a javascript engine.&lt;/p&gt;

&lt;p&gt;Javascript is a dynamic language so we expect it to be slow but it is pretty fast the reason is all the modern runtimes use something called JIT(just in time compile) because of that it is pretty fast.&lt;/p&gt;

&lt;p&gt;Here is a list of the javascript engines in some popular browsers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;V8 (Chrome)&lt;/li&gt;
&lt;li&gt;Chakra (Internet Explorer)&lt;/li&gt;
&lt;li&gt;Spider Monkey (Firefox)&lt;/li&gt;
&lt;li&gt;Javascript Core Webkit (Safari)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As an example, I will explain the workflow inside of the V8 engine:&lt;br&gt;
for optimizing they use two compilers   &lt;/p&gt;

&lt;p&gt;   - &lt;em&gt;baseline compiler ( V8 uses Ignition):&lt;/em&gt; it is regular compiler that generates machine code.&lt;/p&gt;

&lt;p&gt;   - &lt;em&gt;optimizing compiler (V8 uses turbofan):&lt;/em&gt; saves the type information for "hot" functions&lt;/p&gt;

&lt;p&gt;Since javascript is a dynamic typing language we don't know the types when a user enters. so the compiler needs to find the types each time. &lt;/p&gt;

&lt;p&gt;For optimization, we use an optimizing compiler which does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Re-compile: (if it is hot or used a lot) "hot" functions with type information from previous execution&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;De-optimize: since javascript dynamically typed language, when the type changes remove it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;If we don't change the types optimizing compiler can remember the types for the same functions so the code can be faster&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;so if we let the optimizing compiler do its job and don't change the types our code will be much faster.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Javascript's Single Threaded Nature</title>
      <dc:creator>ikbal arslan</dc:creator>
      <pubDate>Sun, 26 May 2024 14:56:09 +0000</pubDate>
      <link>https://dev.to/ikbalarslan/javascripts-single-threaded-nature-m33</link>
      <guid>https://dev.to/ikbalarslan/javascripts-single-threaded-nature-m33</guid>
      <description>&lt;p&gt;Javascript is a single-threaded language let's see what that means. &lt;/p&gt;

&lt;p&gt;When the javascript engine starts executing the code it does that synchronously. In this kind of execution, the program is executed line by line, one line at a time. doesn't move to the next line without finishing the execution of the current line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It can do only one thing at a time&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's say, you asked for burgers in the restaurant. while you are waiting for your burger you don't do anything else. You start doing other stuff after you get the burger.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var a = 5;
var b = 10;

function sum(a,b){
   return a + b
}

sum()

console.log("hello")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the code above when we call the function sum we can't move to the console log line until the execution of the sum is done.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;There is one way to make the javascript multi-threaded which is with setting up workers. But it doesn't come as default as a developer you should set it up to have multiple execution contexts at the same time.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Dynamic Typed Language v.s. Static Typed Language</title>
      <dc:creator>ikbal arslan</dc:creator>
      <pubDate>Sun, 26 May 2024 12:54:09 +0000</pubDate>
      <link>https://dev.to/ikbalarslan/dynamic-language-vs-static-language-942</link>
      <guid>https://dev.to/ikbalarslan/dynamic-language-vs-static-language-942</guid>
      <description>&lt;p&gt;The programming itself depends on one thing which is values.&lt;/p&gt;

&lt;p&gt;We use values by storing them in the memory, accessing it, and editing it. To access these values we need to put a label on it so whenever we need to use that value we can just basically call it by using the label.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
int number = 23

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example in this case we store the value which is 23 in the memory with a label which is a number. int is just saying to program create a new label.&lt;/p&gt;

&lt;p&gt;While we are storing values in the CPU's (the microchip) memory we need to know the type of the value so we can store the value in the correct place. the types can be whole numbers, even numbers, texts, or big objects which has other values stored inside.&lt;/p&gt;

&lt;p&gt;So now we want to store some data in the memory but how we will know where to store this? We need to know the type of the value.&lt;/p&gt;

&lt;p&gt;To know the type of data we have two options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;the label itself can store the type of data (static)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the value can store the type of data (dynamic)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Static Programming Languages 
&lt;/h4&gt;

&lt;p&gt;In static programming languages when we are creating a label we need to give it a type as well for example in C++ which is a static language. When you want to store some data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
int label1 = 3

string label2 = "hello world"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While we are creating label1 we put int keyword upfront which represents a type. it says label1 can only store integers(whole numbers) in it.&lt;/p&gt;

&lt;p&gt;In static languages the labels have type values in them because of that when the compiler converts the code to assembly it only checks the label to get type info to know where to store the values.&lt;/p&gt;

&lt;h4&gt;
  
  
  Dynamic Programming Languages
&lt;/h4&gt;

&lt;p&gt;In dynamic programming languages when we are creating a label we don't need to specify the type info the value itself will store the type info for example in Javascript which is a dynamic language. When we want to store some data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
var label1 = 3

var label2 = "hello world"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For creating a new variable we always used var keyword because var keyword doesn't store type info it is just responsible for creating a label in this case, label1 and label2 don't have a type.&lt;/p&gt;

&lt;p&gt;However, the compiler needs the type value to store data in the correct places. for that every time before storing data it will check the value get type info from it and then convert it to the assembly language.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In the Programming world labels are called variables&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  How about speed?
&lt;/h3&gt;

&lt;p&gt;Since we need to check the value every single time in the compiling, the compiler needs to work more compared to static languages.&lt;br&gt;
Because of that, we can say static languages are faster to compile. compared to dynamic languages right?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dynamic typing languages are pretty fast but how?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;as an example, I will explain the working mechanism of The &lt;a href="https://dev.to/ikbalarslan/javascript-runtime-37i8"&gt;V8 Javascript Engine&lt;/a&gt; &lt;br&gt;
when the engine starts the execution it will use two things to make it faster:&lt;br&gt;
-JIT(Just in Time Compilation)&lt;br&gt;
-using two compilers instead of one&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JIT&lt;/strong&gt;&lt;br&gt;
with using &lt;a href="https://en.wikipedia.org/wiki/Just-in-time_compilation"&gt;JIT&lt;/a&gt; the engine immediately will convert the javascript code to machine-understandable code. on the way line by line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Two Compiler&lt;/strong&gt;&lt;br&gt;
engine uses one normal compiler and one optimizing compiler. Optimizing the compiler will save the type data in the memory for most used functions. so if we call the same function again it won't waste time checking types every time(if the types are the same)&lt;/p&gt;

&lt;p&gt;I have explained more details about Javascript engines in &lt;a href="https://dev.to/ikbalarslan/javascript-runtime-37i8"&gt;this article&lt;/a&gt; &lt;/p&gt;




&lt;p&gt;here are some resources to dive deeper into this topic:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://stackoverflow.com/questions/761426/why-are-dynamically-typed-languages-slow"&gt;this&lt;/a&gt; StackOverflow discussion is pretty informative.&lt;/li&gt;
&lt;li&gt;Scala’s author has a good &lt;a href="https://stackoverflow.com/questions/3490383/java-compile-speed-vs-scala-compile-speed/3612212#3612212"&gt;StackOverflow answer&lt;/a&gt; on why the compiler is so slow.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://benhoyt.com/writings/language-speed/"&gt;benhoyt's blog post&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?v=p-iiEDtpy6I"&gt;this&lt;/a&gt; presentation from JSconf&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;In this article, I have explained the differences between dynamic and static languages. If you have any questions feel free to leave a comment. I will be happy to answer them.&lt;/p&gt;

</description>
      <category>programming</category>
    </item>
    <item>
      <title>Code is for Humans not for Computers</title>
      <dc:creator>ikbal arslan</dc:creator>
      <pubDate>Sat, 25 May 2024 21:11:34 +0000</pubDate>
      <link>https://dev.to/ikbalarslan/code-is-for-humans-not-for-computers-2ohd</link>
      <guid>https://dev.to/ikbalarslan/code-is-for-humans-not-for-computers-2ohd</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqodzh3uuwkuvc7j3osxb.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqodzh3uuwkuvc7j3osxb.jpeg" alt="if it works don't touch it" width="227" height="222"&gt;&lt;/a&gt;&lt;br&gt;
When I started learning programming the first rule I learned was "&lt;em&gt;if it works don't touch it&lt;/em&gt; "Then I just realized that %70 of our time spent coding is spent reading the code. That first rule looks like has some issues.&lt;/p&gt;

&lt;p&gt;A couple of days ago I watched a presentation related to this topic and the content in it was opposite what the first rule says. Here is a brief overview.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you don't know why your code works, you have no hope of fixing it when it breaks.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;When you don't understand how the code works and need to fix it.&lt;/p&gt;

&lt;p&gt;An idea will come which is &lt;em&gt;it'd be faster if I just rewrote it&lt;/em&gt;. This will fix the problem but if any more bug exists in the code base again since you don't understand the code base you need to rewrite it again and again.&lt;/p&gt;

&lt;p&gt;This slows down the development progress. because of that most of the code bases are rewritten hundreds of times. if your code has to be rewritten to be fixed. improved, or extended, you failed. the only way to ensure your code survives is to make sure it's readable.&lt;/p&gt;

&lt;p&gt;The problem is we are writing our code primarily for the computer. Not for humans but instead the code should communicate ideas with other people. Readability directly impacts your ability, and that of everyone else, to do their job.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Readability isn't just a good idea or nice to have. it's the whole point.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The one thing we will always be better at than the computer is empathetic communication with other people.&lt;/p&gt;

&lt;p&gt;I am leaving the link for the presentation &lt;a href="https://frontendmasters.com/teachers/kyle-simpson/code-is-for-humans/"&gt;here&lt;/a&gt; it is worth checking it out.&lt;/p&gt;

</description>
      <category>programming</category>
    </item>
  </channel>
</rss>
