<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Abderrahim Ajakka's Blog]]></title><description><![CDATA[Abderrahim Ajakka's Blog]]></description><link>https://blog.ajakka.net</link><generator>RSS for Node</generator><lastBuildDate>Fri, 01 May 2026 16:30:17 GMT</lastBuildDate><atom:link href="https://blog.ajakka.net/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[What is React Native Architecture anyways?]]></title><description><![CDATA[Are you a person like me who keeps hearing the term “React Native Architecture” but never quite gets it?
Are you a react native developer who never touched the /ios and /android folders unless some library requires you add some lines there?
What are ...]]></description><link>https://blog.ajakka.net/what-is-react-native-architecture-anyways</link><guid isPermaLink="true">https://blog.ajakka.net/what-is-react-native-architecture-anyways</guid><category><![CDATA[React Native Bridge]]></category><category><![CDATA[Turbo Modules]]></category><category><![CDATA[Fabric Components]]></category><category><![CDATA[JSI]]></category><category><![CDATA[React Native]]></category><dc:creator><![CDATA[Abderrahim Ajakka]]></dc:creator><pubDate>Wed, 13 Mar 2024 22:49:15 GMT</pubDate><content:encoded><![CDATA[<p>Are you a person like me who keeps hearing the term “React Native Architecture” but never quite gets it?</p>
<p>Are you a react native developer who never touched the /ios and /android folders unless some library requires you add some lines there?</p>
<p>What are they talking about anyways, is it something like MVC or MVVM? is it some new folder structure used to organize your code-base?</p>
<p>If your like me and had these questions, I'd like to report that it is non of the above. In fact you shouldn’t worry about it unless you have an edge case and need to access native code to solve it, or you want to develop a react native library.</p>
<p>That being said, let’s dive into what is the react native architecture.</p>
<h2 id="heading-the-problem-the-bridge">The problem ( The bridge)</h2>
<p>React Native has traditionally operated on a bridge-based architecture, serving as the communication layer between the JavaScript code and native platform.</p>
<p>This bridge is asynchronous, meaning that every call from JavaScript to native or vice versa must pass through this bridge asynchronously.</p>
<p>This setup, while effective for a wide range of applications, introduced performance bottlenecks, particularly in complex and high-performance apps. Operations requiring high-frequency interaction between JavaScript and the native side would incur a performance penalty due to the overhead of passing messages across the bridge.</p>
<p>This could lead to less smooth animations, delays in executing touch events, and overall less responsive UIs. The need for a more efficient way to handle these interactions prompted the exploration of a new architecture.</p>
<h2 id="heading-the-solution">The Solution</h2>
<p>The React Native team responded to these challenges with two key innovations: Fabric and TurboModules. Both are designed to improve React Native's performance and efficiency by reimagining the architecture's core.</p>
<p><strong>Fabric</strong> is a new UI layer that replaces the traditional bridge with a more direct connection between JavaScript and native views. It utilizes a concept known as JSI (JavaScript Interface), allowing JavaScript code to directly call native functions synchronously. This means there's no longer a need for the asynchronous bridge for every interaction, which drastically reduces the communication overhead, leading to smoother animations and a more responsive interface.</p>
<p><strong>TurboModules</strong> also leverage JSI to provide a more efficient way to load and interact with native modules. Unlike the old architecture, where all modules were initialized at app startup, TurboModules adopts a lazy initialization approach. Modules are loaded only when they are needed, reducing startup time and memory usage. This approach not only speeds up the app's performance but also provides a more modular and efficient system for managing native code.</p>
]]></content:encoded></item><item><title><![CDATA[How much do you know JavaScript?]]></title><description><![CDATA[Like most developers I came to JavaScript after learning and using other languages like C, Java and C#. I did not "formally" learn JavaScript as I should because It looked pretty basic and easy to understand for someone with previous experience in ot...]]></description><link>https://blog.ajakka.net/how-much-do-you-know-javascript</link><guid isPermaLink="true">https://blog.ajakka.net/how-much-do-you-know-javascript</guid><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Abderrahim Ajakka]]></dc:creator><pubDate>Thu, 15 Feb 2024 18:26:53 GMT</pubDate><content:encoded><![CDATA[<p>Like most developers I came to JavaScript after learning and using other languages like C, Java and C#. I did not "formally" learn JavaScript as I should because It looked pretty basic and easy to understand for someone with previous experience in other languages. But I eventually came to the realization that It's not the case and that JavaScript had more to it. So I compiled this Article of the most fundamental and advanced features of JavaScript that I learned. Let's go...</p>
<h3 id="heading-basic-syntax">Basic Syntax</h3>
<ul>
<li><p><strong>Optional Chaining (</strong><code>?.</code><strong>)</strong> allows you to read the value of a property located deep within a chain of connected objects without having to check that each reference in the chain is valid.</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">const</span> person = { <span class="hljs-attr">name</span>: <span class="hljs-string">'John'</span>, <span class="hljs-attr">address</span>: { <span class="hljs-attr">street</span>: <span class="hljs-string">'123 Main St'</span> } };
  <span class="hljs-built_in">console</span>.log(person.address?.city); <span class="hljs-comment">// undefined, without causing an error</span>
</code></pre>
</li>
<li><p><strong>Nullish Coalescing Operator (</strong><code>??</code><strong>)</strong> provides a default value for a variable that is <code>null</code> or <code>undefined</code>.</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">const</span> input = <span class="hljs-literal">null</span>;
  <span class="hljs-keyword">const</span> output = input ?? <span class="hljs-string">'default value'</span>;
  <span class="hljs-built_in">console</span>.log(output); <span class="hljs-comment">// 'default value'</span>
</code></pre>
</li>
</ul>
<h3 id="heading-this-prototype-coercion">This, Prototype, Coercion</h3>
<ul>
<li><p><strong>This keyword (</strong><code>this</code><strong>)</strong> refers to the context in which the current function is executed. The value of <code>this</code> changes based on how the function is called.</p>
<pre><code class="lang-javascript">  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">show</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">this</span>.name);
  }
  <span class="hljs-keyword">const</span> obj = { <span class="hljs-attr">name</span>: <span class="hljs-string">'JavaScript'</span>, show };
  obj.show(); <span class="hljs-comment">// 'JavaScript'</span>
</code></pre>
</li>
<li><p><strong>Prototype</strong> is a mechanism by which JavaScript objects inherit features from one another.</p>
<pre><code class="lang-javascript">  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Person</span>(<span class="hljs-params">name</span>) </span>{
    <span class="hljs-built_in">this</span>.name = name;
  }
  Person.prototype.greet = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Hello, '</span> + <span class="hljs-built_in">this</span>.name);
  };
  <span class="hljs-keyword">const</span> person1 = <span class="hljs-keyword">new</span> Person(<span class="hljs-string">'Alice'</span>);
  person1.greet(); <span class="hljs-comment">// 'Hello, Alice'</span>
</code></pre>
</li>
<li><p><strong>Coercion</strong> is the automatic or implicit conversion of values from one data type to another (e.g., from string to number).</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">const</span> result = <span class="hljs-string">'5'</span> + <span class="hljs-number">1</span>; <span class="hljs-comment">// '51', string coercion</span>
  <span class="hljs-keyword">const</span> result2 = <span class="hljs-string">'5'</span> * <span class="hljs-number">1</span>; <span class="hljs-comment">// 5, numeric coercion</span>
</code></pre>
</li>
</ul>
<h3 id="heading-de-structuring-spread-rest-default-properties">De-structuring, Spread, Rest, Default Properties</h3>
<ul>
<li><p><strong>De-structuring</strong> allows unpacking values from arrays or properties from objects into distinct variables.</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">const</span> { name, age } = { <span class="hljs-attr">name</span>: <span class="hljs-string">'John'</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">30</span> };
  <span class="hljs-built_in">console</span>.log(name, age); <span class="hljs-comment">// 'John', 30</span>
</code></pre>
</li>
<li><p><strong>Spread Operator (</strong><code>...</code><strong>)</strong> is used to spread the elements of an array or object properties.</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">const</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
  <span class="hljs-keyword">const</span> newNumbers = [...numbers, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>]; <span class="hljs-comment">// [1, 2, 3, 4, 5]</span>
</code></pre>
</li>
<li><p><strong>Rest Parameter (</strong><code>...</code><strong>)</strong> collects all remaining elements into an array.</p>
<pre><code class="lang-javascript">  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sum</span>(<span class="hljs-params">...args</span>) </span>{
    <span class="hljs-keyword">return</span> args.reduce(<span class="hljs-function">(<span class="hljs-params">total, current</span>) =&gt;</span> total + current, <span class="hljs-number">0</span>);
  }
  <span class="hljs-built_in">console</span>.log(sum(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)); <span class="hljs-comment">// 6</span>
</code></pre>
</li>
<li><p><strong>Default Parameters</strong> allow named parameters to be initialized with default values if no value or <code>undefined</code> is passed.</p>
<pre><code class="lang-javascript">  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">greet</span>(<span class="hljs-params">name = <span class="hljs-string">'Guest'</span></span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Hello, <span class="hljs-subst">${name}</span>!`</span>);
  }
  greet(); <span class="hljs-comment">// 'Hello, Guest!'</span>
</code></pre>
</li>
</ul>
<h3 id="heading-scoping-closures">Scoping, Closures</h3>
<ul>
<li><p><strong>Scoping</strong> determines the visibility or lifetime of variables and parameters. JavaScript has function scope and block scope (with <code>let</code> and <code>const</code>).</p>
</li>
<li><pre><code class="lang-javascript">      <span class="hljs-keyword">if</span> (<span class="hljs-literal">true</span>) {
        <span class="hljs-keyword">var</span> varScoped = <span class="hljs-string">'var'</span>;
        <span class="hljs-keyword">let</span> blockScoped = <span class="hljs-string">'block'</span>;
      }
      <span class="hljs-built_in">console</span>.log(varScoped); <span class="hljs-comment">// 'var'</span>
      <span class="hljs-built_in">console</span>.log(blockScoped); <span class="hljs-comment">// ReferenceError: blockScoped is not defined</span>
</code></pre>
</li>
<li><p><strong>Closures</strong> are functions that remember their lexical scope, even when the function is executed outside that lexical scope.</p>
<pre><code class="lang-javascript">  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">makeCounter</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">let</span> count = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
      <span class="hljs-keyword">return</span> ++count;
    };
  }
  <span class="hljs-keyword">const</span> counter = makeCounter();
  <span class="hljs-built_in">console</span>.log(counter()); <span class="hljs-comment">// 1</span>
  <span class="hljs-built_in">console</span>.log(counter()); <span class="hljs-comment">// 2</span>
</code></pre>
</li>
</ul>
<h3 id="heading-array-and-object-functions-set-map-weakset-weakmap">Array and Object Functions, Set, Map, WeakSet, WeakMap</h3>
<ul>
<li><p><strong>Array and Object Functions</strong> like <code>map</code>, <code>filter</code>, <code>reduce</code> for arrays and <code>Object.keys</code>, <code>Object.values</code> for objects are essential for handling collections.</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">const</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>];
  <span class="hljs-keyword">const</span> doubled = numbers.map(<span class="hljs-function"><span class="hljs-params">x</span> =&gt;</span> x * <span class="hljs-number">2</span>); <span class="hljs-comment">// [2, 4, 6, 8]</span>
</code></pre>
</li>
<li><p><strong>Set</strong> is a collection of unique values.</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">const</span> mySet = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Set</span>([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">2</span>]);
  <span class="hljs-built_in">console</span>.log(mySet.size); <span class="hljs-comment">// 3</span>
</code></pre>
</li>
<li><p><strong>Map</strong> is a collection of keyed data items, similar to an Object but with any value as the key.</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">const</span> myMap = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Map</span>([[<span class="hljs-string">'a'</span>, <span class="hljs-number">1</span>], [<span class="hljs-string">'b'</span>, <span class="hljs-number">2</span>]]);
  <span class="hljs-built_in">console</span>.log(myMap.get(<span class="hljs-string">'a'</span>)); <span class="hljs-comment">// 1</span>
</code></pre>
</li>
<li><p><strong>WeakSet</strong> and <strong>WeakMap</strong> are similar to <code>Set</code> and <code>Map</code> but their elements/keys are only weakly held, allowing for garbage collection if there is no other reference to the object.</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">let</span> obj = {};
  <span class="hljs-keyword">const</span> weakSet = <span class="hljs-keyword">new</span> <span class="hljs-built_in">WeakSet</span>([obj]);
  obj = <span class="hljs-literal">null</span>; <span class="hljs-comment">// Now the object can be garbage collected</span>
</code></pre>
</li>
</ul>
<h3 id="heading-classes-currying-higher-order-functions">Classes, Currying, Higher Order Functions</h3>
<ul>
<li><p><strong>Classes</strong> provide a syntactic sugar over JavaScript's existing prototype-based inheritance.</p>
<pre><code class="lang-javascript">  <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Person</span> </span>{
    <span class="hljs-keyword">constructor</span>(name) {
      <span class="hljs-built_in">this</span>.name = name;
    }
    greet() {
      <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Hello, <span class="hljs-subst">${<span class="hljs-built_in">this</span>.name}</span>`</span>);
    }
  }
  <span class="hljs-keyword">const</span> person1 = <span class="hljs-keyword">new</span> Person(<span class="hljs-string">'Alice'</span>);
  person1.greet(); <span class="hljs-comment">// 'Hello, Alice'</span>
</code></pre>
</li>
<li><p><strong>Currying</strong> is the process of transforming a function with multiple arguments into a sequence of functions each with a single argument.</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">const</span> add = <span class="hljs-function"><span class="hljs-params">a</span> =&gt;</span> <span class="hljs-function"><span class="hljs-params">b</span> =&gt;</span> a + b;
  <span class="hljs-keyword">const</span> addFive = add(<span class="hljs-number">5</span>);
  <span class="hljs-built_in">console</span>.log(addFive(<span class="hljs-number">3</span>)); <span class="hljs-comment">// 8</span>
</code></pre>
</li>
<li><p><strong>Higher Order Functions</strong> are functions that take another function as an argument or return a function as a result.</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">const</span> withLogging = <span class="hljs-function"><span class="hljs-params">fn</span> =&gt;</span> <span class="hljs-function">(<span class="hljs-params">...args</span>) =&gt;</span> {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Calling function with arguments: <span class="hljs-subst">${args}</span>`</span>);
    <span class="hljs-keyword">const</span> result = fn(...args);
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Result: <span class="hljs-subst">${result}</span>`</span>);
    <span class="hljs-keyword">return</span> result;
  };
  <span class="hljs-keyword">const</span> sum = withLogging(<span class="hljs-function">(<span class="hljs-params">a, b</span>) =&gt;</span> a + b);
  sum(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>); <span class="hljs-comment">// Logs calling and result</span>
</code></pre>
</li>
</ul>
<h3 id="heading-promises-asyncawait-event-loop">Promises, Async/Await, Event Loop</h3>
<ul>
<li><p><strong>Promises</strong> are used for asynchronous computation. They represent a value that may be available now, later, or never.</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">const</span> promise = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function">(<span class="hljs-params">resolve, reject</span>) =&gt;</span> {
    <span class="hljs-built_in">setTimeout</span>(<span class="hljs-function">() =&gt;</span> resolve(<span class="hljs-string">'Result'</span>), <span class="hljs-number">1000</span>);
  });
  promise.then(<span class="hljs-function"><span class="hljs-params">result</span> =&gt;</span> <span class="hljs-built_in">console</span>.log(result));
  <span class="hljs-comment">// prints 'Result' after 1 second</span>
</code></pre>
</li>
<li><p><strong>Async/Await</strong> simplifies working with promises, allowing for asynchronous code to be written in a synchronous manner.</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">fetchData</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">const</span> data = <span class="hljs-keyword">await</span> fetch(<span class="hljs-string">'url'</span>);
    <span class="hljs-keyword">return</span> data.json();
  }
</code></pre>
</li>
<li><p><strong>Event Loop</strong> is a JavaScript runtime model that ensures execution of code, collecting and processing events, and executing queued sub-tasks</p>
<pre><code class="lang-javascript">  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Start'</span>);
  <span class="hljs-built_in">setTimeout</span>(<span class="hljs-function">() =&gt;</span> <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Timeout'</span>), <span class="hljs-number">0</span>);
  <span class="hljs-built_in">Promise</span>.resolve().then(<span class="hljs-function">() =&gt;</span> <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Promise'</span>));
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'End'</span>);
  <span class="hljs-comment">// Output: Start, End, Promise, Timeout</span>
</code></pre>
</li>
</ul>
<h3 id="heading-iterators-generators">Iterators, Generators</h3>
<ul>
<li><p><strong>Iterators</strong> are objects that enable custom iteration like <code>for...of</code> loops over a collection.</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">const</span> iterable = {
    *[<span class="hljs-built_in">Symbol</span>.iterator]() {
      <span class="hljs-keyword">yield</span> <span class="hljs-number">1</span>;
      <span class="hljs-keyword">yield</span> <span class="hljs-number">2</span>;
      <span class="hljs-keyword">yield</span> <span class="hljs-number">3</span>;
    }
  };

  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">const</span> value <span class="hljs-keyword">of</span> iterable) {
    <span class="hljs-built_in">console</span>.log(value); <span class="hljs-comment">// 1, 2, 3</span>
  }
</code></pre>
</li>
<li><p><strong>Generators</strong> are functions that can be exited and later re-entered, maintaining their context across re-entrances.</p>
<pre><code class="lang-javascript">  <span class="hljs-function"><span class="hljs-keyword">function</span>* <span class="hljs-title">generatorFunction</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">yield</span> <span class="hljs-string">'Hello'</span>;
    <span class="hljs-keyword">yield</span> <span class="hljs-string">'World'</span>;
  }
  <span class="hljs-keyword">const</span> generator = generatorFunction();
  <span class="hljs-built_in">console</span>.log(generator.next().value); <span class="hljs-comment">// 'Hello'</span>
  <span class="hljs-built_in">console</span>.log(generator.next().value); <span class="hljs-comment">// 'World'</span>
</code></pre>
</li>
</ul>
<h3 id="heading-debugging">Debugging</h3>
<p>Debugging involves identifying and removing errors from software. In JavaScript, this can be done using tools like the Chrome Developer Tools, which allow setting breakpoints, stepping through code, inspecting variables, and viewing call stacks.</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Debugging example'</span>);
<span class="hljs-comment">// Use debugger; statement to pause execution in DevTools</span>
<span class="hljs-keyword">debugger</span>;
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'This line only executes after the debugger has resumed'</span>);
</code></pre>
<h3 id="heading-finally-done">Finally done 😁</h3>
<p>Each of these features contributes to the versatility and power of JavaScript as a language, catering to both simple scripting and complex application development.</p>
]]></content:encoded></item></channel></rss>