<?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: Salem_Raouf</title>
    <description>The latest articles on DEV Community by Salem_Raouf (@salemabderaouf).</description>
    <link>https://dev.to/salemabderaouf</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%2F200516%2F0e109e3b-ca22-445f-b0d6-af0471572a30.png</url>
      <title>DEV Community: Salem_Raouf</title>
      <link>https://dev.to/salemabderaouf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/salemabderaouf"/>
    <language>en</language>
    <item>
      <title>React-native new Architecture, what to expect ?</title>
      <dc:creator>Salem_Raouf</dc:creator>
      <pubDate>Sat, 12 Mar 2022 22:05:04 +0000</pubDate>
      <link>https://dev.to/salemabderaouf/react-native-new-architecture-what-to-expect--ojf</link>
      <guid>https://dev.to/salemabderaouf/react-native-new-architecture-what-to-expect--ojf</guid>
      <description>&lt;p&gt;react-native team has announce that 2022 will be the new architecture release&lt;br&gt;
2022 is going to be the year of the New Architecture in open source.&lt;br&gt;
but why a new architecture? to understand why to take a look at the current react-native architecture&lt;br&gt;
let’s recap the current architecture components&lt;br&gt;
Bridge: handle the communication between JavaScript thread and native/UI thread&lt;br&gt;
JavaScriptCore: engine in android to run JavaScript code in your android and it bundled with your app&lt;br&gt;
Yoga: layout engine takes all flex-box based styles and converts them to native layout width, height, spacing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Welcome to the new react-native architecture
&lt;/h2&gt;

&lt;p&gt;react native new architecture&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hs9t-PP8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9wuwum4aydqjon7iplq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hs9t-PP8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9wuwum4aydqjon7iplq.png" alt="react native new architecture" width="880" height="461"&gt;&lt;/a&gt;&lt;br&gt;
as we can see the bridge will be replaced with a module called JSI (JavaScript Interface)&lt;/p&gt;

&lt;h2&gt;
  
  
  so what is JSI (JavaScript interface) ?
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;A lightweight API to embed a JavaScript engine in a C++ application. Fabric uses it to communicate between Fabric’s C++ core and React.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;since the JSI is written with C++ that allows JS to invoke the native methods directly which means Less serialization of data between JS and Native/UI thread, with the power of C++ react-native, will expand new systems like smartwatches, TVs.&lt;br&gt;
In another case bridge is only compatible with the JavaScriptCore engine which is not like the JSI, the JSI enables the use of other JavaScript Engines like Chakra, v8, Hermes, etc. that will reduce the app size in android.&lt;/p&gt;

&lt;h2&gt;
  
  
  Turbo Modules
&lt;/h2&gt;

&lt;p&gt;at the start-up, The current architecture need to initialize all native modules (e.g. File Storage, Bluetooth ..etc) even if they are not used that making the user stuck in the splash screen for a while, slow load time&lt;br&gt;
So what’s turbo module does is hold only the references for those native modules which mean to call them only when they are required, which will improve the start-up time&lt;/p&gt;

&lt;h2&gt;
  
  
  CodeGen
&lt;/h2&gt;

&lt;p&gt;CodeGen will be the type checker, JSI as we discuses above the JSI is written with C++, C++ is a Statically Typed Language, and the react-native apps written with JavaScript which is a Dynamically typed language, so CodeGen will ensure the communication between them&lt;br&gt;
NB: the difference between Statically Typed Language and Dynamically typed language is that in statically typed programming languages, type checking occurs at compile time Conversely, in dynamically typed languages, type checking takes place at runtime or execution time&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lWsO-k8g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/puvk4rpjbwrtzcwjxmym.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lWsO-k8g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/puvk4rpjbwrtzcwjxmym.png" alt="statically typed programming &amp;amp; dynamically typed languages" width="880" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Fabric
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;another big enhancement in the new architecture is Fabric&lt;br&gt;
Fabric is React Native’s new rendering system, a conceptual evolution of the legacy render system.&lt;br&gt;
we will discuss Fabric in the next article .&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>reactnative</category>
      <category>react</category>
      <category>javascript</category>
      <category>android</category>
    </item>
    <item>
      <title>React-native architecture - [part one]</title>
      <dc:creator>Salem_Raouf</dc:creator>
      <pubDate>Fri, 18 Feb 2022 17:52:09 +0000</pubDate>
      <link>https://dev.to/salemabderaouf/react-native-architecture-part-one-26fg</link>
      <guid>https://dev.to/salemabderaouf/react-native-architecture-part-one-26fg</guid>
      <description>&lt;h2&gt;
  
  
  What's react-native ?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://reactnative.dev/" rel="noopener noreferrer"&gt;React Native&lt;/a&gt; is a JavaScript framework for writing real, natively rendering mobile applications for iOS and Android. It’s based on React, Facebook’s JavaScript library for building user interfaces, but instead of targeting the browser, it targets mobile platforms. In other words: web developers can now write mobile applications that look and feel truly “native,” all from the comfort of a JavaScript library that we already know and love. Plus, because most of the code you write can be shared between platforms, React Native makes it easy to simultaneously develop for both Android and iOS.&lt;/p&gt;

&lt;h2&gt;
  
  
  React-native spark :
&lt;/h2&gt;

&lt;p&gt;Inside Facebook, Jordan Walke found a way to generate UI elements for iOS from a background JavaScript thread, which became the basis for the React web framework. They decided to organize an internal Hackathon to perfect this prototype to be able to build native apps with this technology.&lt;/p&gt;

&lt;h2&gt;
  
  
  React-native Born :
&lt;/h2&gt;

&lt;p&gt;In 2015, after months of development, Facebook released the first version for the React JavaScript Configuration. During a technical talk, Christopher Chedeau explained that Facebook was already using React Native in production for their Group App and their Ads Manager App.&lt;/p&gt;

&lt;h2&gt;
  
  
  React-native Architecture :
&lt;/h2&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%2Fx873od11gkvxotdcuz8g.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%2Fx873od11gkvxotdcuz8g.png" alt="React-native Architecture"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  1 - JS bundler thread :
&lt;/h2&gt;

&lt;p&gt;as we type &lt;br&gt;
&lt;code&gt;react-native ios-android&lt;/code&gt; or &lt;code&gt;react-native run-ios&lt;/code&gt;&lt;br&gt;
the packager takes all your JS code and puts it into a single file: &lt;code&gt;main.bundle.js&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Wait here, what's the packager?&lt;br&gt;
The official react-native packager is Metro&lt;br&gt;
&lt;a href="https://facebook.github.io" rel="noopener noreferrer"&gt;Metro&lt;/a&gt; is a JavaScript bundler. It takes in an entry file and various options and gives you back a single JavaScript file that includes all your code and its dependencies.&lt;/p&gt;

&lt;p&gt;the device will look for the native entry point in react native source code android or ios directory then starts the JavaScript virtual machine in a thread, In this thread, our &lt;code&gt;main.bundle.js&lt;/code&gt; will run.&lt;br&gt;
Wait here, But How to run JavaScript virtual machine on a Mobile?&lt;br&gt;
here we have a &lt;a href="https://github.com/WebKit/webkit/tree/main/Source/JavaScriptCore" rel="noopener noreferrer"&gt;JavaScriptCore&lt;/a&gt; library that allow to run the JavaScript code on IOS devices, In android this framework is not provided by the OS, so its bundled with the app that' make the app size a bit larger&lt;/p&gt;

&lt;h2&gt;
  
  
  2 - Native UI thread
&lt;/h2&gt;

&lt;p&gt;The native thread or (Main thread) this is the main application thread on which your Android or iOS app is running and it is responsible for native interactions and events like Scroll. The communication between the native UI thread and the JavaScript thread pass throw the bridge&lt;/p&gt;

&lt;h2&gt;
  
  
  The Bridge
&lt;/h2&gt;

&lt;p&gt;The bridge is responsible for data transmission in form of a JSON file between the native UI thread and JS bundle UI, the data is serialized and deserialized in the bridge to complete its way, this operation made react-native slower in time manner and performance&lt;/p&gt;

&lt;h2&gt;
  
  
  3 - Shadow thread :
&lt;/h2&gt;

&lt;p&gt;under the hood, the shadow tree uses to create UI tree and &lt;br&gt;
uses the Yoga layout engine to take all the current flexbox based styles and convert it to native layout width, height, spacing&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;React native is a great piece of tech that allows JavaScript developers to expand their abilities in the native environment, but it is still a little bit slower compared to some hybrid cross platforms like a flutter. for that reason, react-native needs a re-architecture.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>reactnative</category>
      <category>react</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
