<?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: Akash Joshi</title>
    <description>The latest articles on DEV Community by Akash Joshi (@thewritingdev).</description>
    <link>https://dev.to/thewritingdev</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%2F171453%2F089617fc-795f-4a42-ac99-0e9918c4d4bb.jpg</url>
      <title>DEV Community: Akash Joshi</title>
      <link>https://dev.to/thewritingdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thewritingdev"/>
    <language>en</language>
    <item>
      <title>Global Talent: The Employer-Independent UK Visa</title>
      <dc:creator>Akash Joshi</dc:creator>
      <pubDate>Fri, 15 Nov 2024 12:51:30 +0000</pubDate>
      <link>https://dev.to/thewritingdev/global-talent-the-employer-independent-uk-visa-2n37</link>
      <guid>https://dev.to/thewritingdev/global-talent-the-employer-independent-uk-visa-2n37</guid>
      <description>&lt;p&gt;As a software engineer who has navigated various visas in the UK, I've experienced firsthand the challenges and uncertainties that come with building a career abroad. After two years in the UK and multiple layoffs, I finally secured an unlimited visa known as the &lt;strong&gt;Global Talent Visa (GTV)&lt;/strong&gt;. In this article, I'll share my journey and insights into this game-changing visa option for skilled professionals.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/xyRvm273m2s"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  The Skilled Worker Visa Dilemma
&lt;/h2&gt;

&lt;p&gt;Like many international professionals, I initially came to the UK on a &lt;strong&gt;Skilled Worker Visa&lt;/strong&gt;. While this visa provides a pathway to work in the UK, it comes with significant drawbacks:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Job Dependency:&lt;/strong&gt; Your right to stay in the country is tied to your employment with a specific company.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stress During Job Transitions:&lt;/strong&gt; Changing jobs becomes a high-stakes process, as you need to secure a new sponsorship quickly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Limited Flexibility:&lt;/strong&gt; Your career options are restricted to companies willing and able to sponsor your visa.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These limitations can be particularly challenging in a volatile job market, as I experienced during several layoffs and job changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enter the Global Talent Visa
&lt;/h2&gt;

&lt;p&gt;Frustrated with the constraints of the Skilled Worker Visa, I decided to explore other options. That's when I discovered the &lt;strong&gt;Global Talent Visa (previously known as the Exceptional Talent Visa)&lt;/strong&gt;. This Tier 1 visa offers several significant advantages:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Unlimited Duration:&lt;/strong&gt; Unlike many other visas, there's no expiration date to worry about.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Career Flexibility:&lt;/strong&gt; You're not tied to a specific employer, allowing you to switch jobs, start a business, or work as a freelancer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Faster Route to Settlement:&lt;/strong&gt; It provides a quicker path to permanent residency in the UK.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  My Personal Experience
&lt;/h2&gt;

&lt;p&gt;I used various strategies to strengthen my application:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;External Contributions:&lt;/strong&gt; Engaged in meetup and conference activities, contributing to over six pieces of evidence.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Professional Recognitions:&lt;/strong&gt; Utilized salary comparisons and documented my work at all of previous companies which had outsized impact.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Community Involvement:&lt;/strong&gt; Highlighted my role in community organizing and open-source projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;References:&lt;/strong&gt; Secured references from seniors and well-known people in digital technology who could attest to my impact and contributions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Application Process
&lt;/h2&gt;

&lt;p&gt;Obtaining a &lt;strong&gt;Global Talent Visa&lt;/strong&gt; involves a two-stage process:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Endorsement:&lt;/strong&gt; You must first be endorsed by a designated body in your field. For tech professionals, this is usually &lt;strong&gt;Tech Nation&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Visa Application:&lt;/strong&gt; Once endorsed, you apply for the actual visa through the UK government.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Preparing for Endorsement
&lt;/h3&gt;

&lt;p&gt;The endorsement stage is crucial and requires demonstrating your exceptional talent or promise in your field. This typically involves showcasing your achievements, innovations, and impact on the tech industry. Here’s how I approached it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mandatory Criteria:&lt;/strong&gt; Ensure you meet the core criteria set by the endorsing body.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Optional Criteria:&lt;/strong&gt; Supplement your application with additional evidence of your expertise.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Statement of Purpose:&lt;/strong&gt; Clearly articulate your contributions and future plans in the UK.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In total, you need to submit around 10 documents as evidences. While all 10 aren’t mandatory, submitting the maximum number of evidences strengthens your application and makes it more likely to get endorsed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tips for a Successful Application
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Follow Guidelines:&lt;/strong&gt; Adhere strictly to the application guidelines provided by Tech Nation. For example, letters of recommendation should not exceed six pages and should talk about your potential contribution to the UK economy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quality Over Quantity:&lt;/strong&gt; Focus on the impact of your work rather than the number of achievements. Highlight how your contributions have positively affected your company or the industry.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comprehensive Evidence:&lt;/strong&gt; Use a mix of evidence such as conference participation, community organizing, open-source contributions, and media coverage of your work.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Is the Global Talent Visa Right for You?
&lt;/h2&gt;

&lt;p&gt;While the &lt;strong&gt;Global Talent Visa&lt;/strong&gt; offers tremendous benefits, it's not the right fit for everyone. Consider applying if:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Strong Track Record:&lt;/strong&gt; You have a significant history of achievements in your field.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Long-Term Stability:&lt;/strong&gt; You're seeking long-term stability and career flexibility in the UK.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Willingness to Invest:&lt;/strong&gt; You're prepared to invest time and effort into a more complex application process.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Who is Eligible for GTV?
&lt;/h2&gt;

&lt;p&gt;Anyone can apply for the GTV from within the UK, outside the UK, or even if you are on any existing UK visa. Here are the key eligibility criteria:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fields Covered:&lt;/strong&gt; Arts and culture, research and academia, digital technology.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Experience Levels:&lt;/strong&gt; 

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Promise:&lt;/strong&gt; For those showing potential leadership.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Talent:&lt;/strong&gt; For individuals with over five years of experience in their field.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Product-based experience is preferred over service-based companies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources and Costs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Visa Fees and Details:&lt;/strong&gt; &lt;a href="https://www.gov.uk/global-talent" rel="noopener noreferrer"&gt;UK Global Talent Visa&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Community Support:&lt;/strong&gt; &lt;a href="https://discourse.tnvisaforum.org/" rel="noopener noreferrer"&gt;Tech Nation Visa Forum&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;The &lt;strong&gt;Global Talent Visa&lt;/strong&gt; represents a significant opportunity for skilled professionals looking to build a career in the UK. It offers the freedom and stability that many of us crave when working internationally. If you're currently on a &lt;strong&gt;Skilled Worker Visa&lt;/strong&gt; and feeling constrained, or if you're considering a move to the UK, I encourage you to explore this option.&lt;/p&gt;

&lt;p&gt;Have you had experience with different types of work visas? Are you considering applying for the &lt;strong&gt;Global Talent Visa&lt;/strong&gt;? I'd love to hear your thoughts and experiences in the comments below. If you need help determining your eligibility or forming your application, feel free to &lt;a href="https://topmate.io/akash_joshi" rel="noopener noreferrer"&gt;schedule a call&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;All the best on your journey!&lt;/p&gt;

</description>
      <category>career</category>
      <category>programmers</category>
      <category>remote</category>
      <category>digitalworkplace</category>
    </item>
    <item>
      <title>How the Global Talent visa might make you layoff-proof in the UK 🇬🇧</title>
      <dc:creator>Akash Joshi</dc:creator>
      <pubDate>Fri, 13 Sep 2024 13:48:49 +0000</pubDate>
      <link>https://dev.to/thewritingdev/how-the-global-talent-visa-might-make-you-layoff-proof-in-the-uk-37om</link>
      <guid>https://dev.to/thewritingdev/how-the-global-talent-visa-might-make-you-layoff-proof-in-the-uk-37om</guid>
      <description>&lt;p&gt;As a software engineer who has navigated the complex world of international work visas, I've experienced firsthand the challenges and uncertainties that come with building a career abroad. After two years in the UK and multiple layoffs, I've finally secured an unlimited visa known as the Global Talent Visa. In this article, I'll share my journey and insights into this game-changing visa option for skilled professionals.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/xyRvm273m2s"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  The Skilled Worker Visa Dilemma
&lt;/h2&gt;

&lt;p&gt;Like many international professionals, I initially came to the UK on a Skilled Worker Visa. While this visa provides a pathway to work in the UK, it comes with significant drawbacks:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Job-dependency: Your right to stay in the country is tied to your employment with a specific company.&lt;/li&gt;
&lt;li&gt;Stress during job transitions: Changing jobs becomes a high-stakes process, as you need to secure a new sponsorship quickly.&lt;/li&gt;
&lt;li&gt;Limited flexibility: Your career options are restricted to companies willing and able to sponsor your visa.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These limitations can be particularly challenging in a volatile job market, as I experienced during several layoffs and job changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enter the Global Talent Visa
&lt;/h2&gt;

&lt;p&gt;Frustrated with the constraints of the Skilled Worker Visa, I decided to explore other options. That's when I discovered the Global Talent Visa (previously known as the Exceptional Talent Visa). This Tier 1 visa offers several significant advantages:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Unlimited duration: Unlike many other visas, there's no expiration date to worry about.&lt;/li&gt;
&lt;li&gt;Career flexibility: You're not tied to a specific employer, allowing you to switch jobs, start a business, or work as a freelancer.&lt;/li&gt;
&lt;li&gt;Faster route to settlement: It provides a quicker path to permanent residency in the UK.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Application Process
&lt;/h2&gt;

&lt;p&gt;Obtaining a Global Talent Visa involves a two-stage process:&lt;br&gt;
Endorsement: You must first be endorsed by a designated body in your field. For tech professionals, this is usually Tech Nation.&lt;br&gt;
Visa Application: Once endorsed, you apply for the actual visa through the UK government.&lt;/p&gt;

&lt;p&gt;The endorsement stage is crucial and requires demonstrating your exceptional talent or promise in your field. This typically involves showcasing your achievements, innovations, and impact on the tech industry.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is the Global Talent Visa Right for You?
&lt;/h2&gt;

&lt;p&gt;While the Global Talent Visa offers tremendous benefits, it's not the right fit for everyone. Consider applying if:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You have a strong track record of achievements in your field.&lt;/li&gt;
&lt;li&gt;You're looking for long-term stability and career flexibility in the UK.&lt;/li&gt;
&lt;li&gt;You're willing to invest time and effort into a more complex application process.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Remember, the application process can be challenging, but the rewards are significant. If you're considering this path, I'd be happy to share more details about my experience or offer guidance on preparing your application.&lt;/p&gt;

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

&lt;p&gt;The Global Talent Visa represents a significant opportunity for skilled professionals looking to build a career in the UK. It offers the freedom and stability that many of us crave when working internationally. If you're currently on a Skilled Worker Visa and feeling constrained, or if you're considering a move to the UK, I encourage you to explore this option.&lt;/p&gt;

&lt;p&gt;Have you had experience with different types of work visas? Are you considering applying for the Global Talent Visa? I'd love to hear your thoughts and experiences in the comments below. In case you need help knowing if you're eligible (most people are!) or want help forming your application, feel free to &lt;a href="https://topmate.io/akash_joshi" rel="noopener noreferrer"&gt;schedule a call&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>career</category>
      <category>digitalworkplace</category>
      <category>programmers</category>
      <category>uk</category>
    </item>
    <item>
      <title>Building AI apps using GPT, Claude and Cloudflare</title>
      <dc:creator>Akash Joshi</dc:creator>
      <pubDate>Wed, 03 Jan 2024 09:23:49 +0000</pubDate>
      <link>https://dev.to/thewritingdev/building-ai-apps-using-gpt-claude-and-cloudflare-ii2</link>
      <guid>https://dev.to/thewritingdev/building-ai-apps-using-gpt-claude-and-cloudflare-ii2</guid>
      <description>&lt;p&gt;Artificial Intelligence has transformed the way we interact with technology. One of the key innovations enabling this AI revolution is Large Language Models (LLMs). LLMs are powerful natural language processing systems that can understand text, generate human-like writing, and even converse in natural language.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore how we can leverage LLMs to quickly build intelligent applications through APIs offered by companies like OpenAI, Anthropic, and Cloudflare. These capabilities just take a few lines of code. The best way to understand a new technology is by building things on it. So let's get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Large Language Models
&lt;/h2&gt;

&lt;p&gt;This AI automations craze is possible, of course, because of Large Language Models or LLMs. LLMs are blackboxes which take in a series of tokens as an input, and try to predict what the next set of tokens should be. The major openly available models on the internet which you can pay for and use are -&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;OpenAI GPT APIs&lt;/li&gt;
&lt;li&gt;Claude&lt;/li&gt;
&lt;li&gt;Cloudflare AI&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By using these models, the flexibility you get in the number of AI-powered applications one can build is endless. I've been experimenting on these a lot myself! More on that in a bit.&lt;/p&gt;

&lt;h2&gt;
  
  
  OpenAI
&lt;/h2&gt;

&lt;p&gt;Firstly, let's look at the kinds of APIs they provide. Let's look at &lt;a href="https://platform.openai.com/docs/libraries/python-library"&gt;OpenAI&lt;/a&gt; first. They provide first-party SDKs for NodeJS and Python. I've used both, and unfortunately, because of the nature of the LLM landscape and how fast things move, it's always recommended to go with first-party SDKs. Things move too fast for third-party ones to catch up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U7fB5CTp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thewriting.dev/content/images/2023/11/Screenshot-2023-11-04-at-08.53.44.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U7fB5CTp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thewriting.dev/content/images/2023/11/Screenshot-2023-11-04-at-08.53.44.png" alt="Screenshot of OpenAI Documentation" width="800" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The 2 main APIs they provide are *&lt;strong&gt;&lt;em&gt;completions&lt;/em&gt;&lt;/strong&gt;* and *&lt;strong&gt;&lt;em&gt;function calling&lt;/em&gt;&lt;/strong&gt;*.&lt;/p&gt;

&lt;h3&gt;
  
  
  Completions
&lt;/h3&gt;

&lt;p&gt;Right from OpenAPI's docs, "Chat models take a list of messages as input and return a model-generated message as output.". To understand what this means, take a look at the example below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;openai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gpt-3.5-turbo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;role&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;system&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;content&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;You are a helpful assistant.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;role&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;content&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Who won the world series in 2020?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;role&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;assistant&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;content&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;The Los Angeles Dodgers won the World Series in 2020.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;role&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;content&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Where was it played?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}],&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As a dev, we have to pass all of the relevant messages of a conversation to GPT, which involves the following - *&lt;strong&gt;&lt;em&gt;system messages&lt;/em&gt;&lt;/strong&gt;* to define GPT behavior, *&lt;strong&gt;&lt;em&gt;user messages&lt;/em&gt;&lt;/strong&gt;* which define the queries users ask, and *&lt;strong&gt;&lt;em&gt;assistant messages&lt;/em&gt;&lt;/strong&gt;*, ie, responses from the API in the history.&lt;/p&gt;

&lt;p&gt;This context is what allows GPT to maintain a history of the conversation and predict the next output with better accuracy. Try it on your own using the docs!&lt;/p&gt;

&lt;h3&gt;
  
  
  Function Calling
&lt;/h3&gt;

&lt;p&gt;The other API one can use for building AI apps is function calling. This one allows you to define functions accessible by GPT in the JSON format described by OpenAI. Once you pass in the data and also write some glue code, GPT can then "call" functions in your codebase to get data as needed (it just tells you what you need to do, you still need to call the functions programmatically).&lt;/p&gt;

&lt;p&gt;There's an example of a weather calling API on the docs pages, but I'm going to create a better one soon!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;functions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;get_current_weather&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;description&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Get the current weather in a given location&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;parameters&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;object&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;properties&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;location&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;description&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;The city and state, e.g. San Francisco, CA&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="p"&gt;},&lt;/span&gt;
                &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;unit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;enum&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;celsius&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fahrenheit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]},&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;required&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;location&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Claude
&lt;/h2&gt;

&lt;p&gt;Anthropic has released its own competitor to OpenAI's GPT APIs - Claude. Claude is faster, cheaper, and more flexible in terms of data formats it accepts and the amount of tokens it supports (9,999!). This can make it a better alternative to GPT's APIs. However, it can struggle in terms of accuracy, and also lags behind in features when compared to GPT. Still, if you want something fast and cheap, Claude can get the job done!&lt;/p&gt;

&lt;p&gt;Claude also has first-party SDKs for Python and Typescript, which as I said previously, are recommended over third-party ones. Although, in this case, Claude's single API has remained quite stable over the past year, so feel free to choose any.&lt;/p&gt;

&lt;p&gt;Looking up their &lt;a href="https://docs.anthropic.com/claude/reference/prompt-validation"&gt;prompting technique&lt;/a&gt;, it's pretty obvious what they expect. A *&lt;strong&gt;&lt;em&gt;human-assistant&lt;/em&gt;&lt;/strong&gt;* loop where Claude's messages are tagged with assistant. This is unlike the GPT APIs where the system messages are tagged as *&lt;strong&gt;&lt;em&gt;system&lt;/em&gt;&lt;/strong&gt;* - which allows you to set context for how the assistant should reply to the user. Believe it or now, Claude's docs &lt;a href="https://docs.anthropic.com/claude/docs/configuring-gpt-prompts-for-claude"&gt;address this concern&lt;/a&gt; and many others as well, so be sure to give them a read!&lt;/p&gt;

&lt;p&gt;Finally, the data you send with the API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;completion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;anthropic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;claude-2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;max_tokens_to_sample&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;Anthropic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;HUMAN_PROMPT&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; how does a court case get to the Supreme Court?&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;Anthropic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AI_PROMPT&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Cloudflare AI
&lt;/h2&gt;

&lt;p&gt;Cloudflare have recently launched their own &lt;a href="https://developers.cloudflare.com/workers-ai/"&gt;AI services&lt;/a&gt; suite. For LLMs, they are using Llama 2 7B internally (update: they included Mistral 7B as well). With a limited context size of 2048, you'll be relying more on external embeddings stores for real-world usecases.&lt;/p&gt;

&lt;p&gt;The prompt structure matches that of OpenAI, with *&lt;strong&gt;&lt;em&gt;system&lt;/em&gt;&lt;/strong&gt;&lt;em&gt;, *&lt;/em&gt;&lt;strong&gt;user&lt;/strong&gt;** and *&lt;strong&gt;&lt;em&gt;assistant&lt;/em&gt;&lt;/strong&gt;* prompts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;messages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;system&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;You are a friendly assistant&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;What is the origin of the phrase Hello, World&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;ai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@cf/meta/llama-2-7b-chat-int8&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;messages&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's free for the introductory period as well. Check it out!&lt;/p&gt;

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

&lt;p&gt;Building web applications doesn't have to be scary, and should be easy to figure out. Hopefully, this article gives you the right footing to get started, and go out there and build your own thing!&lt;/p&gt;

&lt;p&gt;Btw, I've been experimenting with my own tool - &lt;a href="https://github.com/akash-joshi/howtf"&gt;how&lt;/a&gt;. It's an AI powered CLI tool which walks you through complex terminal interactions, holding your hand through all the steps. Check the demo out below.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1720715006054969774-577" src="https://platform.twitter.com/embed/Tweet.html?id=1720715006054969774"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1720715006054969774-577');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1720715006054969774&amp;amp;theme=dark"
  }



&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>ai</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Unleashing the Power of WebAssembly in Modern Web Development</title>
      <dc:creator>Akash Joshi</dc:creator>
      <pubDate>Tue, 16 May 2023 17:43:22 +0000</pubDate>
      <link>https://dev.to/thewritingdev/unleashing-the-power-of-webassembly-in-modern-web-development-1h8h</link>
      <guid>https://dev.to/thewritingdev/unleashing-the-power-of-webassembly-in-modern-web-development-1h8h</guid>
      <description>&lt;p&gt;WebAssembly has emerged as a game-changing technology in the world of web development. It allows developers to run high-performance code written in languages like C, C++, and Rust directly in the browser, unlocking new possibilities for web applications. In this article, we will explore the potential of WebAssembly and how it can revolutionise modern web development.&lt;/p&gt;

&lt;p&gt;Table of Contents:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is WebAssembly?&lt;/li&gt;
&lt;li&gt;Why Use WebAssembly?&lt;/li&gt;
&lt;li&gt;Getting Started with WebAssembly
3.1 Setting Up the Development Environment
3.2 Compiling WebAssembly Modules
3.3 Interacting with WebAssembly Modules in JavaScript&lt;/li&gt;
&lt;li&gt;Real-World Use Cases
4.1 Accelerating Performance with WebAssembly
4.2 Reusing Existing Codebases
4.3 Enhancing Web Applications with WebAssembly&lt;/li&gt;
&lt;li&gt;Best Practices for WebAssembly Development
5.1 Optimizing WebAssembly Performance
5.2 Ensuring Security in WebAssembly
5.3 Debugging and Testing WebAssembly Modules&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  1. What is WebAssembly?
&lt;/h2&gt;

&lt;p&gt;WebAssembly, often abbreviated as wasm, is a binary instruction format that allows for the efficient execution of code in modern web browsers. It provides a low-level virtual machine that enables running code at near-native speed, opening up opportunities for high-performance web applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Why Use WebAssembly?
&lt;/h2&gt;

&lt;p&gt;WebAssembly offers several benefits for web development:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Improved Performance: By running code closer to native speed, WebAssembly enables developers to build web applications that perform tasks faster and more efficiently.&lt;/li&gt;
&lt;li&gt;Code Reusability: WebAssembly allows developers to leverage existing code written in languages like C, C++, and Rust, making it easier to reuse and integrate code from other projects.&lt;/li&gt;
&lt;li&gt;Language Agnostic: WebAssembly is not tied to a specific programming language, giving developers the freedom to choose the most suitable language for their specific needs.&lt;/li&gt;
&lt;li&gt;Enhanced Security: WebAssembly provides a sandboxed execution environment, ensuring that code running in the browser is isolated and cannot interfere with other parts of the system.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Getting Started with WebAssembly
&lt;/h2&gt;

&lt;h3&gt;
  
  
  3.1 Setting Up the Development Environment
&lt;/h3&gt;

&lt;p&gt;To start developing with WebAssembly, you'll need a few tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A text editor or an integrated development environment (IDE) for coding.&lt;/li&gt;
&lt;li&gt;A WebAssembly-compatible compiler like Emscripten or Rust.&lt;/li&gt;
&lt;li&gt;A modern web browser that supports WebAssembly, such as Google Chrome or Mozilla Firefox.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3.2 Compiling WebAssembly Modules
&lt;/h3&gt;

&lt;p&gt;In this section, we'll explore how to compile a simple C program into a WebAssembly module using Emscripten. Here's an example code snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, WebAssembly!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To compile this code into a WebAssembly module, run the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;emcc hello.c -o hello.js -s WASM=1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.3 Interacting with WebAssembly Modules in JavaScript
&lt;/h3&gt;

&lt;p&gt;Once you have a WebAssembly module, you can interact with it using JavaScript. Here's an example of how to load and execute a WebAssembly module:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello.wasm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;arrayBuffer&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;buffer&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;WebAssembly&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instantiate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;buffer&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;module&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Output: 5&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Real-World Use Cases
&lt;/h2&gt;

&lt;p&gt;In this section, we'll explore some practical applications of WebAssembly.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.1 Accelerating Performance with WebAssembly
&lt;/h3&gt;

&lt;p&gt;WebAssembly can greatly enhance the performance of computationally intensive tasks in web applications. For example, image and video editing applications can benefit from using WebAssembly to run complex algorithms, achieving near-native performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.2 Reusing Existing Codebases
&lt;/h3&gt;

&lt;p&gt;One of the major advantages of WebAssembly is the ability to reuse code from existing projects written in languages like C, C++, or Rust. This opens up opportunities for code sharing between web and non-web applications, saving time and effort for developers.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.3 Enhancing Web Applications with WebAssembly
&lt;/h3&gt;

&lt;p&gt;WebAssembly can be used to bring powerful functionalities to web applications that were previously only possible in native applications. Examples include running physics simulations, 3D modeling, audio processing, and even emulating retro games.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Best Practices for WebAssembly Development
&lt;/h2&gt;

&lt;p&gt;To make the most out of WebAssembly, consider the following best practices.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.1 Optimizing WebAssembly Performance:
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Code Optimization
&lt;/h4&gt;

&lt;p&gt;When writing code for WebAssembly, it's important to optimize it for performance. This includes using efficient algorithms and avoiding unnecessary computations. For example, let's consider a simple factorial function implemented in C:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To optimize this code, we can introduce tail recursion, which eliminates the need for stack frames for each recursive call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By using tail recursion, we reduce the memory overhead and improve the overall performance of the factorial function.&lt;/p&gt;

&lt;h4&gt;
  
  
  Memory Usage Optimization
&lt;/h4&gt;

&lt;p&gt;WebAssembly has limited access to memory compared to native applications. Therefore, it's crucial to manage memory usage efficiently. Here's an example of optimizing memory usage in a WebAssembly module written in Rust:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nd"&gt;#[no_mangle]&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;extern&lt;/span&gt; &lt;span class="s"&gt;"C"&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;process_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data_ptr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="nb"&gt;u8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data_len&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;usize&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Do some processing on the data&lt;/span&gt;
    &lt;span class="c1"&gt;// ...&lt;/span&gt;

    &lt;span class="k"&gt;unsafe&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Free the memory used by the data&lt;/span&gt;
        &lt;span class="nn"&gt;std&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;alloc&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;dealloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data_ptr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nn"&gt;std&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;alloc&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;Layout&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from_size_align_unchecked&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data_len&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we explicitly deallocate the memory used by the data after processing it. By freeing memory when it's no longer needed, we optimize memory usage and avoid memory leaks.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.2 Ensuring Security in WebAssembly
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Input Validation
&lt;/h4&gt;

&lt;p&gt;WebAssembly modules should validate and sanitize inputs to prevent security vulnerabilities. Let's consider a simple WebAssembly module that calculates the square of an integer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Invalid input, return an error code&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we validate the input parameter &lt;code&gt;n&lt;/code&gt; to ensure it's a non-negative integer. If the input is invalid, we return an error code instead of performing the calculation.&lt;/p&gt;

&lt;h4&gt;
  
  
  Isolating Untrusted Code
&lt;/h4&gt;

&lt;p&gt;WebAssembly's sandboxed execution environment allows us to isolate untrusted code from accessing sensitive information or interfering with other parts of the application. Let's consider an example where we use WebAssembly to evaluate mathematical expressions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="nf"&gt;evaluate_expression&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;expression&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Evaluate the expression and return the result&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this scenario, we need to ensure that the WebAssembly module can only access the necessary functions and data, and doesn't have access to sensitive information or critical system resources. By properly isolating the WebAssembly module, we can mitigate security risks and protect the integrity of our application.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.3 Debugging and Testing WebAssembly Modules
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Utilizing Debugging Tools
&lt;/h4&gt;

&lt;p&gt;When working with WebAssembly, it's important to utilize debugging tools provided by browsers and extensions. For example, in Google Chrome, you can use the DevTools to debug and analyze your WebAssembly code. Here's an example of setting a breakpoint in a WebAssembly module:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;wasmModule&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;WebAssembly&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instantiateStreaming&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;module.wasm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="c1"&gt;// Debugging the WebAssembly module&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;debugFunc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;wasmModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;debugFunc&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;debugFunc&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Set a breakpoint on this line&lt;/span&gt;

&lt;span class="c1"&gt;// Use Chrome DevTools to inspect the WebAssembly execution&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By setting a breakpoint in the JavaScript code that interacts with the WebAssembly module, you can use the debugging tools in your browser to step through the WebAssembly code and analyze its execution.&lt;/p&gt;

&lt;h4&gt;
  
  
  Writing Unit Tests
&lt;/h4&gt;

&lt;p&gt;To ensure the correctness of your WebAssembly modules, it's essential to write comprehensive unit tests. Let's consider an example where we have a WebAssembly module that performs matrix multiplication:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;multiply_matrices&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;matrix1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;matrix2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;rows1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;cols1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;rows2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;cols2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Perform matrix multiplication and store the result in 'result'&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To write a unit test for this module, you can use a testing framework like &lt;code&gt;wasm-bindgen-test&lt;/code&gt; for Rust. Here's an example of a unit test that verifies the correctness of the matrix multiplication function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nd"&gt;#[cfg(test)]&lt;/span&gt;
&lt;span class="k"&gt;mod&lt;/span&gt; &lt;span class="n"&gt;tests&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nd"&gt;#[test]&lt;/span&gt;
    &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;test_multiply_matrices&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;matrix1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nd"&gt;vec!&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;matrix2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nd"&gt;vec!&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nd"&gt;vec!&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

        &lt;span class="nf"&gt;multiply_matrices&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;matrix1&lt;/span&gt;&lt;span class="nf"&gt;.as_ptr&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;matrix2&lt;/span&gt;&lt;span class="nf"&gt;.as_ptr&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="nf"&gt;.as_mut_ptr&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="nd"&gt;assert_eq!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;vec!&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;19&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;43&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By writing unit tests for your WebAssembly modules, you can verify their functionality, handle edge cases, and ensure they produce the expected results.&lt;/p&gt;

&lt;p&gt;Incorporating debugging tools and writing unit tests for your WebAssembly modules enables you to effectively debug and validate your code. This practice ensures the reliability and correctness of your WebAssembly-powered web applications, allowing you to identify and fix issues efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Conclusion
&lt;/h2&gt;

&lt;p&gt;WebAssembly is revolutionizing modern web development by enabling high-performance code execution in the browser. By harnessing its power, developers can unlock new possibilities and enhance the performance and functionality of web applications. Understanding the fundamentals of WebAssembly, exploring real-world use cases, and following best practices will empower developers to leverage this technology effectively.&lt;/p&gt;

&lt;p&gt;Incorporating WebAssembly into your web development toolkit can elevate your projects to new heights, bringing speed, reusability, and enhanced capabilities. Start experimenting with WebAssembly today and unleash its potential in your web applications.&lt;/p&gt;

&lt;p&gt;Remember, the web is evolving rapidly, and WebAssembly is at the forefront of this revolution. Embrace it, explore its possibilities, and stay ahead in the ever-changing world of web development.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Increasing Lucky Breaks: A FAANG story</title>
      <dc:creator>Akash Joshi</dc:creator>
      <pubDate>Mon, 27 Mar 2023 07:46:04 +0000</pubDate>
      <link>https://dev.to/thewritingdev/increasing-lucky-breaks-a-faang-story-52ek</link>
      <guid>https://dev.to/thewritingdev/increasing-lucky-breaks-a-faang-story-52ek</guid>
      <description>&lt;p&gt;In this journal entry, I'm going to share the story of how I could get an opportunity in London from India, and maybe help you do the same. Before diving in, I want to recommend a few things that have inspired me: &lt;a href="https://news.ycombinator.com/item?id=35024191&amp;amp;ref=thewriting.dev"&gt;"Here's the number I used to win the lottery"&lt;/a&gt;, &lt;a href="https://www.goodreads.com/book/show/242472.The_Black_Swan?ref=thewriting.dev"&gt;"The Black Swan"&lt;/a&gt; (the book), and &lt;a href="http://www.paulgraham.com/genius.html?ref=thewriting.dev"&gt;"The Bus Ticket Theory of Genius"&lt;/a&gt; (among others by Paul Graham).&lt;/p&gt;

&lt;p&gt;One of the most common questions I get asked online is, "How did you get into Meta?". And, "Were you asked DSA?". Unfortunately, there's no easy answer to these questions because what worked for me might not work for someone else. I had some privileges that I'm grateful for, such as being able to speak decent English, having access to a computer in high school, and receiving an undergraduate education. These set me up with a foundation that allowed me to pursue my passions and get good at them.&lt;/p&gt;

&lt;p&gt;I believe that one of the keys to relative-success is having a genuine passion for what you're doing. For me, that was programming. As I've learned from "The Black Swan", luck also plays a big role, especially in fields where outcomes are non-linear. For example, an actor might become famous overnight if their movie does well, or a startup might succeed because the market and economy are in their favor. There's a lot of randomness involved in these situations.&lt;/p&gt;

&lt;p&gt;However, that doesn't mean that hard work isn't important. An actor still needs to go to acting school and perform in smaller roles before they land a big one. An entrepreneur still needs to understand their market and build something that meets its needs. A writer still needs to write the first words of their book and see it through to completion.&lt;/p&gt;

&lt;p&gt;So, what did I do that might work for you? For starters, I had a passion for building things using code. I enjoyed sharing my work online, and contributing to open source projects - finding it fun to build things in my spare time. Additionally, during the pandemic, I started a podcast about tech and gave talks online. All of these activities helped increase my visibility when the 2021 hiring bubble was at its peak.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The theory of Black Swan events is a metaphor that describes an event that comes as a surprise, has a major effect, and is often inappropriately rationalized after the fact with the benefit of hindsight.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Speaking of the hiring bubble, that was a Black Swan event that had a major impact on my career. When the pandemic hit in 2020, everyone started working from home, and I found myself feeling micromanaged. To decompress, I started building side projects, which someone saw and then referred me to a hiring tweet. This led to my first contracting gig. The same scenario repeated a few more times, which helped me progress quickly over the next two years.&lt;/p&gt;

&lt;p&gt;In 2021, tech companies' stocks grew rapidly, and they bumped up hiring accordingly. They started sponsoring more people to move to their offices from all around the world. During this craze, a recruiter from Meta had been reading my blog for a while had reached out to me. That's how I am in London today. It was a combination of having enough work out there for people to notice it and being in the right place at the right time.&lt;/p&gt;

&lt;p&gt;Of course, as with any Black Swan event, things don't stay the same forever. In 2022, the pandemic was becoming a distant memory, and everyone was starting to venture out again. Tech stocks collapsed, and the hiring bubble burst. What worked for me in 2021 probably won't work in 2022 and for the next few years.&lt;/p&gt;

&lt;p&gt;But how can you increase your surface area for luck? The answer is simple: focus on what you love to do and share it with the world. When you do what you love, you're more likely to put in the effort and time needed to become really good at it. And when you share it with the world, you're giving luck more chances to strike.&lt;/p&gt;

&lt;p&gt;Of course, luck alone won't guarantee success. Hard work and constant learning are also crucial. But luck can be the deciding factor between success and failure, especially in fields with non-linear outcomes like entrepreneurship, investing, and even getting hired to move across countries.&lt;/p&gt;

&lt;p&gt;So, if you want to increase your chances of being successful in your field, start by doing what you love and sharing it with the world. Don't be afraid to put yourself out there and take advantage of any opportunities that come your way. And remember, you can increase your surface area for it and be ready when it strikes.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>productivity</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>GraphQL Interview Reference Sheet</title>
      <dc:creator>Akash Joshi</dc:creator>
      <pubDate>Sun, 05 Mar 2023 09:50:26 +0000</pubDate>
      <link>https://dev.to/thewritingdev/graphql-interview-reference-sheet-15ja</link>
      <guid>https://dev.to/thewritingdev/graphql-interview-reference-sheet-15ja</guid>
      <description>&lt;p&gt;Here's a quick reference sheet for everything GraphQL. I started building this while studying for interviews, and have kept it updated ever since. Enjoy!&lt;/p&gt;

&lt;h3&gt;
  
  
  Schema First Design
&lt;/h3&gt;

&lt;p&gt;Schema-first design typically involves three major steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Defining the schema&lt;/strong&gt;: We identify which data our feature requires, and then we structure our schema to provide that data as intuitively as possible.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Back-end implementation&lt;/strong&gt;: We build out our GraphQL API using Apollo Server and fetch the required data from whichever data sources contain it. In this first course, we will be using mocked data. In a following course, we'll connect our app to a live REST data source.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Front-end implementation&lt;/strong&gt;: Our client consumes data from our GraphQL API to render its views.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Graph
&lt;/h3&gt;

&lt;p&gt;The graph represents an app's data points and how they're connected as a collection of nodes and edges.&lt;/p&gt;

&lt;h3&gt;
  
  
  Type Definition
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type PascalCase {
    key1: String! (! means non-nullable)
    key2: Int
    key3: [OtherType] (array of OtherType)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Query Type
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;Query&lt;/code&gt; type's fields define which data clients can query from our schema. The &lt;code&gt;Query&lt;/code&gt; type contains the entry points to our schema. There are 2 other possible entry points: &lt;code&gt;Mutation&lt;/code&gt; and &lt;code&gt;Subscription&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Query Definition
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;query queryName {
    key1
    key2
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Best practices when creating client queries
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Assign each query string to a constant with an ALL_CAPS name.&lt;/li&gt;
&lt;li&gt;Export query definitions for use in unit tests.&lt;/li&gt;
&lt;li&gt;Test out queries in the Apollo Studio Explorer and copy them over.&lt;/li&gt;
&lt;li&gt;Wrap each query in the gql template literal.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Queries must use valid GraphQL syntax and must only include schema-defined fields.&lt;/p&gt;

&lt;h4&gt;
  
  
  GraphQL Mutations
&lt;/h4&gt;

&lt;p&gt;Mutation names should start with a verb, followed by whatever data you're modifying.&lt;/p&gt;

&lt;p&gt;Queries and mutations are both types of GraphQL operations. Queries are read operations that always retrieve data. Mutations are write operations that always modify data. Similar to &lt;code&gt;Query&lt;/code&gt; fields, fields of the &lt;code&gt;Mutation&lt;/code&gt; type are also entry points into a GraphQL API.&lt;/p&gt;

&lt;h4&gt;
  
  
  GraphQL Variables
&lt;/h4&gt;

&lt;p&gt;Variables are denoted by the $ symbol. They are used to provide dynamic values for  arguments to avoid including hardcoded values in a query. Each one's type must match the type specified in the schema.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  query getMission($isScheduled: Boolean) {
    mission(scheduled: $isScheduled) {
      id
      codename
    }
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  GraphQL Resolvers
&lt;/h3&gt;

&lt;p&gt;A resolver function is responsible for populating the data for a single field in your schema.&lt;/p&gt;

&lt;p&gt;When a query executes successfully, a data key containing a result object with the same shape as the query is returned.&lt;/p&gt;

&lt;h4&gt;
  
  
  Resolver Chains
&lt;/h4&gt;

&lt;p&gt;One should define a separate resolver for each field, including subfields which need to fetch more data.&lt;/p&gt;

&lt;p&gt;A resolver function populates the data for a field in your schema. The function has four parameters. The first, &lt;code&gt;parent&lt;/code&gt;, contains the returned data of the previous function in the  resolver chain. The second, &lt;code&gt;args&lt;/code&gt;, is an object that contains all the arguments provided to the field. We use the third parameter, &lt;code&gt;context&lt;/code&gt;, to access data sources such as a database or REST API. Finally, the fourth parameter, &lt;code&gt;info&lt;/code&gt;, contains informational properties about the operation state.&lt;/p&gt;

&lt;h4&gt;
  
  
  Apollo Data Sources
&lt;/h4&gt;

&lt;p&gt;They help avoid the N+1 problem of data-fetching, which is, making N calls to the exact same endpoint to fetch the exact same data.&lt;/p&gt;

&lt;h4&gt;
  
  
  Resolver Cache
&lt;/h4&gt;

&lt;p&gt;How might a resource cache be useful for our data source?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It helps resolve query fields that have already been fetched much faster.&lt;/li&gt;
&lt;li&gt;It helps manage the mix of different endpoints with different cache policies.&lt;/li&gt;
&lt;li&gt;It prevents unnecessary REST API calls for data that doesn't get updated frequently.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Apollo GraphQL
&lt;/h3&gt;

&lt;h4&gt;
  
  
  useQuery Hook
&lt;/h4&gt;

&lt;p&gt;The useQuery hook returns an object with 3 useful properties that we use in our app: &lt;code&gt;loading&lt;/code&gt; indicates whether the query has completed and results have been returned. &lt;code&gt;error&lt;/code&gt; is an object that contains any errors that the operation has thrown. &lt;code&gt;data&lt;/code&gt; contains the results of the query after it has completed. To set variables in our query, we declare them in the second parameter of the &lt;code&gt;useQuery&lt;/code&gt; hook, inside an options object.&lt;/p&gt;

&lt;h4&gt;
  
  
  useMutation Hook
&lt;/h4&gt;

&lt;p&gt;We use hooks to send requests to our GraphQL API from a React client. To send a mutation, we use the &lt;code&gt;useMutation&lt;/code&gt; hook. This returns an array, where the first element is the mutate function used to trigger the mutation. The second element is an object with more information about the mutation, such as &lt;code&gt;loading&lt;/code&gt;, &lt;code&gt;error&lt;/code&gt; and &lt;code&gt;data&lt;/code&gt; . This hook takes in a GraphQL operation as the first parameter. It also takes in an &lt;code&gt;options&lt;/code&gt; object as the second parameter, where properties like &lt;code&gt;variables&lt;/code&gt; are set.&lt;/p&gt;

&lt;h3&gt;
  
  
  Entities
&lt;/h3&gt;

&lt;p&gt;Entities are GraphQL Schemas can be resolved across multiple subgraphs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Anatomy of GraphQL Types
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type Query {
  getMission(isScheduled: Boolean): [Mission!]!
}

type Mutation {
    createMission(updatedMission: Mission!): Mission
}

type Mission {
    id: ID!
    name: String
    # ...etc
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Security
&lt;/h3&gt;

&lt;p&gt;Authentication is checking that a user is who they say they are. Authorization is checking that a user is allowed to do what they're trying to do.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Authentication&lt;/strong&gt; is determining whether a given user is logged in, and subsequently determining which user someone is.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Authorization&lt;/strong&gt; is determining what a given user has permission to do or see.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;code&gt;AuthenticationError&lt;/code&gt; and &lt;code&gt;ForbiddenError&lt;/code&gt; are both error subclasses defined by Apollo Server. For more information on these and other kinds of errors, check out the &lt;a href="https://www.apollographql.com/docs/apollo-server/data/errors/"&gt;Apollo Docs on error handling&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With field-level authorization, each resolver determines whether the logged-in user has permission to access a field, query, or mutation in the schema.&lt;/p&gt;

&lt;h2&gt;
  
  
  GraphQL Directives
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;directive&lt;/strong&gt; decorates part of a GraphQL schema or operation with additional configuration. GraphQL servers can read a GraphQL document's directives and perform custom logic as appropriate.&lt;/p&gt;

&lt;p&gt;Each directive can only appear in &lt;em&gt;certain&lt;/em&gt; locations within a GraphQL schema or operation. These locations are listed in the directive's definition.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight graphql"&gt;&lt;code&gt;&lt;span class="err"&gt;directive&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;@deprecated(&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;reason:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;String&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;"No&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;longer&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;supported"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;on&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;FIELD_DEFINITION&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;ARGUMENT_DEFINITION&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;INPUT_FIELD_DEFINITION&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;ENUM_VALUE&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Defaults
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Deprecated - Marks the schema definition of a field or enum value as deprecated with an optional reason.&lt;/li&gt;
&lt;li&gt;Skip - If &lt;code&gt;true&lt;/code&gt;, the decorated field or fragment in an operation is &lt;em&gt;not&lt;/em&gt; resolved by the GraphQL server.&lt;/li&gt;
&lt;li&gt;Include - If &lt;code&gt;false&lt;/code&gt;, the decorated field or fragment in an operation is &lt;em&gt;not&lt;/em&gt; resolved by the GraphQL server.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Federation
&lt;/h2&gt;

&lt;p&gt;In a federated architecture, your individual GraphQL APIs are called &lt;strong&gt;subgraphs&lt;/strong&gt;, and they're composed into a &lt;strong&gt;supergraph&lt;/strong&gt;. By querying your supergraph's router, clients can fetch data from all of your subgraphs with a single request:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--74ugLg01--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4xq7piiozbs8d16o6wgh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--74ugLg01--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4xq7piiozbs8d16o6wgh.png" alt="GraphQL Federation" width="880" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;router&lt;/strong&gt; serves as the public access point for your supergraph. It receives incoming GraphQL operations and intelligently routes them across your subgraphs. To clients, this looks exactly the same as querying any other GraphQL server—no client-side configuration is required.&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.apollographql.com/docs/apollo-server/data/data-sources/"&gt;https://www.apollographql.com/docs/apollo-server/data/data-sources/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>graphql</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>You MAY find success through your career</title>
      <dc:creator>Akash Joshi</dc:creator>
      <pubDate>Sat, 06 Aug 2022 08:30:29 +0000</pubDate>
      <link>https://dev.to/thewritingdev/you-may-find-success-through-your-career-2e2i</link>
      <guid>https://dev.to/thewritingdev/you-may-find-success-through-your-career-2e2i</guid>
      <description>&lt;p&gt;Disclaimer: This is a public &lt;strong&gt;journal entry&lt;/strong&gt;, so take the ideas here with a &lt;strong&gt;&lt;em&gt;pail of salt&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In popular media, one is generally told that one can find success only if they quit their job, and work on a startup, product, or an idea. This can lead to fleeting feelings of FOMO whenever one sees someone's successes or status updates on social media.&lt;/p&gt;

&lt;p&gt;To unconvince myself of this idea that one needs to be constantly in lookout for an idea to be happy or successful in what they're doing, I decided to try to reverse-engineer and see the growth stories of a few folks that I admire in the &lt;strong&gt;tech industry&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I'll be looking at:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Gergely Orosz&lt;/strong&gt; from &lt;strong&gt;The Pragmatic Engineer&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Colin McDonnel&lt;/strong&gt; of &lt;strong&gt;Zod&lt;/strong&gt; and &lt;strong&gt;tRPC&lt;/strong&gt; fame &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Theo Browne&lt;/strong&gt; from &lt;strong&gt;Ping&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Gergely Orosz
&lt;/h2&gt;

&lt;p&gt;Before being known for writing one of the most pragmatic and up-to-date newsletters on the tech industry, Gergely worked at Uber for 4 years, where he climbed the ladder to the Engineering Manager position.&lt;/p&gt;

&lt;p&gt;He used this experience to write &lt;a href="https://blog.pragmaticengineer.com/books/"&gt;several books&lt;/a&gt; on software engineering. The current iteration of his blog also started out based on an article on the &lt;a href="https://newsletter.pragmaticengineer.com/p/perfect-storm-causing-a-hot-tech-hiring-market"&gt;2021 hiring market&lt;/a&gt; that he was supposed to write for The New York Times.&lt;/p&gt;

&lt;h2&gt;
  
  
  Colin Mcdonnel
&lt;/h2&gt;

&lt;p&gt;Colin of &lt;a href="https://github.com/colinhacks/zod"&gt;Zod&lt;/a&gt; fame is currently working as a dev advocate for Edgedb. Colin originally graduated from MIT (which requires a lot of effort in itself), and eventually took a startup (Bagel Health) through YC. Although the startup wouldn't see the light of success, Colin used the experience to create open-source tools like our beloved run-time type validator Zod. &lt;/p&gt;

&lt;p&gt;As documented by Theo in his &lt;a href="https://www.youtube.com/watch?v=PYUqYcPMPeQ"&gt;video on tRPC&lt;/a&gt;, it originally started out as a POC by Colin trying to add automatic type inference and validation to a project called Obvious RPC, which tried to experiment with adding automatic type-inference to RPC API calls. This library finally became the &lt;a href="https://trpc.io/"&gt;tRPC&lt;/a&gt; that we all know and love, currently being maintained by &lt;a href="https://github.com/katt"&gt;Katt&lt;/a&gt; - a great programmer himself!&lt;/p&gt;

&lt;h2&gt;
  
  
  Theo Browne
&lt;/h2&gt;

&lt;p&gt;Theo Browne is most popularly known as the creator of &lt;a href="https://ping.gg/"&gt;Ping Labs&lt;/a&gt;, the founder of T3 stack (Typescript, Tailwind and tRPC), along with growing a popular YT channel. Theo originally started out as an employee working on significant features at &lt;a href="https://twitch.tv"&gt;Twitch&lt;/a&gt;. In my personal opinion, this may have played a significant part in him starting out streaming on the platform and creating content on YT.&lt;/p&gt;

&lt;p&gt;Eventually, he used this experience and the lack of focus of Twitch on creator tooling to found Ping, which you can read about on &lt;a href="https://t3.gg/blog/post/dream-job-revisited"&gt;his blog&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;p&gt;So, what do I personally take away from this experience? Don't quit your job or FOMO yourself out of fun at work just because you read about people's success online. Everyone has a different path to it, and one of them could be through your career as well :)&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
    <item>
      <title>The Pareto Hypothesis for Getting Hired</title>
      <dc:creator>Akash Joshi</dc:creator>
      <pubDate>Mon, 25 Jul 2022 13:33:00 +0000</pubDate>
      <link>https://dev.to/thewritingdev/the-pareto-hypothesis-for-getting-hired-5f</link>
      <guid>https://dev.to/thewritingdev/the-pareto-hypothesis-for-getting-hired-5f</guid>
      <description>&lt;p&gt;I have had discussions with friends and peers, where we try to discuss why some people have different career paths than others. While some join a great company after college, and then stagnate their for 5 years, others join companies which are okay after college, then move between companies/startups which might be "just alright", but see massive growth in terms of compensation and responsibilities.&lt;/p&gt;

&lt;p&gt;I think I've had one such journey. I've never worked at a company employing &amp;gt;20 employees yet, and yet have enjoyed deploying my technical skills to solve more and more complex problems. I like to take the career path I've taken so far, the &lt;strong&gt;Pareto Hiring Hypothesis&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It &lt;em&gt;may&lt;/em&gt; benefit you as well, so I'd like to details my thoughts on the same here. My theory goes,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"80% of developers apply to 20% of the available jobs, so apply to the rest of the 80%".&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Expanding upon this idea, 80% of developers apply to the jobs they see quite visibly. A company posting blogs in social media, a company making news for funding, or a company which people post a lot of "I just joined X" posts about.&lt;/p&gt;

&lt;p&gt;Ignore those. Do your own research across communities and job boards. Try to find the companies which aren't making noise in public, but hiring via Word of Mouth. These are the companies which will give you a 300% compensation hike, while not cooking your brains live during their 10-hour long interviews.&lt;/p&gt;

&lt;p&gt;Maybe this makes sense for you. Maybe I'll just get more hate for writing this. Idc this time though, I'll continue to write for the non-vocal 80% :)&lt;/p&gt;

&lt;p&gt;If you vibe with this idea, why not give me a follow here on dev.to?&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Playing with JSON in your browser</title>
      <dc:creator>Akash Joshi</dc:creator>
      <pubDate>Fri, 20 May 2022 05:43:18 +0000</pubDate>
      <link>https://dev.to/thewritingdev/playing-with-json-in-your-browser-427k</link>
      <guid>https://dev.to/thewritingdev/playing-with-json-in-your-browser-427k</guid>
      <description>&lt;p&gt;Hey folks, so I'm writing about a project which I've worked on a little while ago, but one which I still use quite regularly - &lt;a href="https://github.com/akash-joshi/json-transformer"&gt;JSON Live Editor&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This project allows you to quickly dump some JSON data in the left panel, write some JS code to transform the data in the middle panel, and see the output on the right one. Since all the data is just there, there's no need to fiddle between multiple apps. This vastly increases turnaround time for any JSON-data based projects you might be working with.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Need:&lt;/strong&gt; I've worked with a lot of programmatic page generation projects over my career. The first one being the famous programmatic &lt;a href="https://webflow.com/blog/programmatic-seo"&gt;webflow page generation&lt;/a&gt;, and the other one being a set of WP and GitBooks pages that I &lt;a href="https://thewriting.dev/migrating-wordpress-and-gitbooks-websites-to-nextjs/"&gt;converted to MDX&lt;/a&gt; over a week.&lt;/p&gt;

&lt;p&gt;Both of these projects involved a lot of transformations and data conversions with data, mostly stored in the JSON format. The data conversions were also time consuming. The typical steps involved were:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Managing an input JSON file where you put the data which you want to work on in.&lt;/li&gt;
&lt;li&gt;Managing a JS file which has the boilerplate to read &amp;amp; write the data, AND also has to perform transformations on it.&lt;/li&gt;
&lt;li&gt;Managing an output file. This might be the most difficult part because it's easy to corrupt an output file by incorrect writes or overwriting existing data quite easily.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As you can see, any data project in JS dealing with 500+ items gets unwieldly quite quickly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Solution:&lt;/strong&gt; I've dealt with this problem for over 2 years, and it kept coming up again and again whenever I had to make transformations on a JSON file. When the data was small, it was easy to do the transformations in the &lt;strong&gt;browser's console&lt;/strong&gt;, but it's just not feasible once you start dealing with items in the upper double-digits.&lt;/p&gt;

&lt;p&gt;After experimenting in the browser's console a little bit, and looking at the available JSON transformation systems online, I thought of building a web environment, where a user could see their input &amp;amp; output, and add transformation code to iterate over the data quickly.&lt;/p&gt;

&lt;p&gt;For rapid development, I could use a simple &lt;code&gt;textarea&lt;/code&gt; for the input, a &lt;code&gt;Monaco&lt;/code&gt;-like editor to write the code, and some kind of JSON viewer for the output. &lt;code&gt;ReactJS&lt;/code&gt; was also an obvious choice to hold this structure, because it would provide rapid reactivity.&lt;/p&gt;

&lt;p&gt;Hence, after experimenting with a few libraries and kinds of workflows, JSON Live Editor was born.&lt;/p&gt;

&lt;p&gt;It doesn't have the perfect UI, nor the best code-highlighting or linting (as I wanted to get started with bare-minimum Monaco setup), but it's finally here, and it does serve its purpose for me.&lt;/p&gt;

&lt;p&gt;It does have some decent features:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Having a Monaco-based editor for code editing. Writing code in a familiar environment.&lt;/li&gt;
&lt;li&gt;Storing state in local-storage. A tab closed by mistake won't cost you your data (and time!)&lt;/li&gt;
&lt;li&gt;Only calculate output when the user wants. This ties in to the previous point. If you keep seeing the output while you're typing the code, that would result in a bad User Experience as you keep seeing errors or the incorrect transformation on screen. Being able to specify when you wanna transform your code, however, means that you always have the correct output on screen.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Well, that's the article. I wanted to have a document online which explains why this project exists and what it does. I guess this one does an okay job of it. &lt;a href="//mailto:hey@thewriting.dev"&gt;Let me know of your thoughts&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To try this project, you can check out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The GitHub page - &lt;a href="https://github.com/akash-joshi/json-transformer"&gt;github.com/akash-joshi/json-transformer&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;The actual website - &lt;a href="https://json-live-editor.netlify.app/"&gt;json-live-editor.netlify.app/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks! And see you tomorrow for another article on a data project that I've built :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/thewritingdev/status/1523206072898826241"&gt;In case you want to hire a senior React developer ;)&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>React Interview Questions: Understanding Rendering</title>
      <dc:creator>Akash Joshi</dc:creator>
      <pubDate>Sun, 03 Apr 2022 15:43:52 +0000</pubDate>
      <link>https://dev.to/thewritingdev/react-interview-questions-understanding-rendering-547g</link>
      <guid>https://dev.to/thewritingdev/react-interview-questions-understanding-rendering-547g</guid>
      <description>&lt;p&gt;Hey folks, after preparing for frontend interviews/giving several interviews, a set of questions and discussions around React and React performance kept coming up. I decided to distill some of those concepts here for eveyone's benefit. In this article, let's talk about React Rendering: How it happens and what affects it.&lt;/p&gt;

&lt;p&gt;If you prefer learning these concepts in a video format, there's a link to a talk I gave on the same topic below.&lt;/p&gt;

&lt;p&gt;Link to code: &lt;a href="https://github.com/akash-joshi/react-native-blr"&gt;https://github.com/akash-joshi/react-native-blr&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Vo97_HfWKoA?start=3294"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Idea 1 - What are the Steps involved in a React Render?
&lt;/h2&gt;

&lt;p&gt;The steps involved in a React render are as follows -&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Code&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The user first writes their original code as JSX, or as &lt;code&gt;React.createElement&lt;/code&gt; calls (if they dare).&lt;/p&gt;

&lt;h3&gt;
  
  
  2. &lt;strong&gt;Bundling&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The bundling process involves transpilation, code conversion and other steps. If the code was written using JSX, it's transpiled to JS using &lt;code&gt;React.createElement&lt;/code&gt; calls, which the React library can then parse. Any imported &lt;code&gt;svg&lt;/code&gt; and &lt;code&gt;css&lt;/code&gt; files are also converted into a usable format and embedded into the final code.&lt;/p&gt;

&lt;p&gt;This bundling generally happens through a bundler like &lt;code&gt;[webpack](https://webpack.js.org/)&lt;/code&gt;, or any other bundler you or your React framework are using.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Virtual DOM Generation
&lt;/h3&gt;

&lt;p&gt;The Virtual DOM, or VDOM, as it's generally called, is an abstract tree representation of what the final DOM structure on the browser should look like. Creating a DOM node is a very expensive process, so React uses the VDOM and changes between VDOM structure across renders to determine which DOM node to update and how to update it.&lt;/p&gt;

&lt;p&gt;React is also, of course, also responsible for creating and destroying DOM nodes as it needs to.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Generating the real DOM
&lt;/h3&gt;

&lt;p&gt;React determines which DOM nodes to create, update or destroy by comparing the difference between 2 Virtual DOMs. This process is known as &lt;a href="https://reactjs.org/docs/reconciliation.html"&gt;reconciliation&lt;/a&gt; and it's constantly being updated and improved by the React team.&lt;/p&gt;

&lt;p&gt;In summary, the last 2 steps can be divided into 2 phases of the React renderer at a higher-level:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--41otXmau--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--2tIxxGef--/c_limit%252Cf_auto%252Cfl_progressive%252Cq_auto%252Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y57k9p5vg9bzw6qgo67d.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--41otXmau--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--2tIxxGef--/c_limit%252Cf_auto%252Cfl_progressive%252Cq_auto%252Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y57k9p5vg9bzw6qgo67d.JPG" alt="Phases of React Rendering" width="880" height="494"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Image by &lt;a href="https://dev.to/simranbirla/react-rendering-and-re-rendering-1l3m"&gt;Simran Birla&lt;/a&gt; &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  1. Render Phase
&lt;/h3&gt;

&lt;p&gt;The render phase involves generating a VDOM tree from the bundled React code. Each VDOM state is immutable. Hence, a new VDOM tree is generate for each React render.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Commit Phase
&lt;/h3&gt;

&lt;p&gt;As discussed in point 4 above, once React determines via reconciliation that a DOM node needs to be updated, it goes ahead and does so. The main job of React is in trying to minimize "commits" as much as possible, hence minimizing DOM node updates, and hence keeping your webapp performant.&lt;/p&gt;

&lt;p&gt;You can check this part out in my talk &lt;a href="https://youtu.be/Vo97_HfWKoA?t=3492"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/akash-joshi/react-native-blr/blob/main/pages/vdom.jsx"&gt;code&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Idea 2 - How does React identify DOM Nodes? How can one optimize lists?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iUBfiEG0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://s1.o7planning.com/en/12135/images/25398040.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iUBfiEG0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://s1.o7planning.com/en/12135/images/25398040.png" alt="Identifying DOM Nodes" width="766" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React holds a reference to the DOM Node structure in each element's &lt;a href="https://indepth.dev/posts/1008/inside-fiber-in-depth-overview-of-the-new-reconciliation-algorithm-in-react#from-react-elements-to-fiber-nodes"&gt;Fiber Node&lt;/a&gt;, Fiber being the current implementation of React's reconciliation algorithm. Because of this, a developer generally doesn't have to worry about providing unique references for each DOM Node to React.&lt;/p&gt;

&lt;p&gt;However, in structures like list, the order of React elements might change arbitrarily. To maintain a one-one mapping for the order of DOM Nodes inside of React and the browser, it's recommended to pass a &lt;code&gt;key&lt;/code&gt; prop which uniquely identifies a React element inside of a list.&lt;/p&gt;

&lt;p&gt;This &lt;code&gt;key&lt;/code&gt; prop helps React in reusing DOM Nodes as much as possible, and hence, reduces the number of DOM updates required between renders.&lt;/p&gt;

&lt;p&gt;If the &lt;code&gt;key&lt;/code&gt; being passed to DOM Nodes in a list is not unique, your app may start breaking in unexpected ways.&lt;/p&gt;

&lt;p&gt;To see me build a list and slowly start breaking it, watch the talk from &lt;a href="https://youtu.be/Vo97_HfWKoA?t=3969"&gt;this point&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/akash-joshi/react-native-blr/blob/main/pages/keys.jsx"&gt;code&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: An interesting topic to learn more about is Virtualization. Here's how one can render a very large list, while reusing the same DOM nodes in React - &lt;a href="https://blog.logrocket.com/rendering-large-lists-with-react-virtualized-82741907a6b3/"&gt;Virtualization in React&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Idea 3 - How to Remount Components in a simple way
&lt;/h2&gt;

&lt;p&gt;This topic builds upon the previous topic. So if you haven't read it yet, I recommend going through it once, and all the links within.&lt;/p&gt;

&lt;p&gt;Since the &lt;code&gt;key&lt;/code&gt; property of a React element is used to uniquely identify it, a change in the value of &lt;code&gt;key&lt;/code&gt; triggers a remount of the element and hence, the DOM node, since React expects that the element itself has changed.&lt;/p&gt;

&lt;p&gt;Since a remount is triggered, all of the element's and its child components' state are also reset, and any effects are run again.&lt;/p&gt;

&lt;p&gt;This can be used whenever you want to quickly force a remount on a component, either to rebuild a component, or just reset its state, in the case of &lt;code&gt;form&lt;/code&gt;s. Hence, you can quickly reset a form, and all its enclosing state and components by changing the value of &lt;code&gt;key&lt;/code&gt; being passed to it.&lt;/p&gt;

&lt;p&gt;To see a visual demo of me building a form and resetting it, watch the talk &lt;a href="https://youtu.be/Vo97_HfWKoA?t=4556"&gt;from here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Link to &lt;a href="https://github.com/akash-joshi/react-native-blr/blob/main/pages/formreset.tsx"&gt;code example&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Idea 4 - Why do useState and useEffect exist?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uQdVuvuJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.bacancytechnology.com/blog/wp-content/uploads/2020/08/React-Natvie-Table.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uQdVuvuJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.bacancytechnology.com/blog/wp-content/uploads/2020/08/React-Natvie-Table.png" alt="useState vs useEffect" width="880" height="630"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Image from &lt;a href="https://www.bacancytechnology.com/blog/react-native-hooks-to-build-app"&gt;Bacancy Technology&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Before React Hooks using functional components were introduced in 2018, the standard way of building React components was via &lt;a href="https://reactjs.org/docs/state-and-lifecycle.html#adding-local-state-to-a-class"&gt;Class Components&lt;/a&gt;. While defining reactivity in Functional components is as simple as using the &lt;code&gt;useState&lt;/code&gt; hook to define reactive state, and defining effects in &lt;code&gt;useEffect&lt;/code&gt;, it works differently in Class components. Primarily -&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;State was defined in the constructor and was a &lt;a href="https://reactjs.org/docs/hooks-faq.html#should-i-use-one-or-many-state-variables"&gt;combined object&lt;/a&gt; of all the state that a component needs to keep a track of and react to.&lt;/li&gt;
&lt;li&gt;Reacting to state was done as a part of &lt;a href="https://reactjs.org/docs/react-component.html#componentdidupdate"&gt;class lifecycle methods&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;One needed to make an explicit comparison between the previous and present state to know when to run effects like network calls. However, this creates an implicit dependency between state variables and effects, which reduces code readability, and can lead to unexpected behavior for effects.&lt;/p&gt;

&lt;p&gt;The primary solution for this problem are the useState and useEffect hooks. Here's how:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;useState&lt;/code&gt; explicitly defines which variable should cause a React component to re-render on change.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;useEffect&lt;/code&gt; allows a user to define explicit dependencies between state and effects. For eg, one can create an &lt;strong&gt;explicit&lt;/strong&gt; dependency for fetching a user's data, when a &lt;code&gt;userId&lt;/code&gt; state variable changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Through these explicitly defined dependencies between effects and state, the code is less likely to become spaghetti and becomes easier to read. There are no code examples for this part of the topic, but feel free to go through all of the linked documentation above.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: Rerender Cascades and how to Prevent them
&lt;/h2&gt;

&lt;p&gt;Did you know that updating the state of a React component causes the component and all its children to rerender? Even if they don't depend on that state?&lt;/p&gt;

&lt;p&gt;Don't be surprised, because this is expected behavior. In fact, React also provides developers with an easy way of preventing this, if one wishes to do so (via &lt;a href="https://reactjs.org/docs/react-api.html#reactmemo"&gt;React.memo&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;If you liked this article, I would appreciate it if you could share it around. In a future article, I'll do a deep dive into state, the context API, memoization, and when to use which of these. Subscribe to my &lt;a href="https://thewriting.dev"&gt;tiny newsletter&lt;/a&gt; to be notified via email when I put out something interesting.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Web3 is nigh, are my Old Skills irrelevant?</title>
      <dc:creator>Akash Joshi</dc:creator>
      <pubDate>Mon, 22 Nov 2021 15:52:30 +0000</pubDate>
      <link>https://dev.to/thewritingdev/web3-is-nigh-are-my-old-skills-irrelevant-pog</link>
      <guid>https://dev.to/thewritingdev/web3-is-nigh-are-my-old-skills-irrelevant-pog</guid>
      <description>&lt;p&gt;Hey all! Last month we had an interesting and enlightening call with Shadab, who is presently a Full-stack developer working in React, who previously has worked for 2 years in the R&amp;amp;D department of a Multi-National Corp as a Blockchain Research Analyst. The crux of this discussion was Shadab's opinion that beginners shouldn't focus on blockchain while starting to learn programming. Here's a short summary of the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  Shadab's Story
&lt;/h2&gt;

&lt;p&gt;Shadab has completed his bachelors in Mechanical Engineering. During senior year of college, he realized that a job in the Mechanical sector wasn't something that he would pursue long term, and was introduced to the world of tech through an internship that he did at a startup. Through a growing interest in cryptocurrencies and tech, Shadab started mining cryptocurrencies himself, and eventually built projects around it.&lt;/p&gt;

&lt;p&gt;He eventually started working in the R&amp;amp;D department of TCS (Tata Consultancy Services) as a Blockchain Researcher, where he made use of Hyperledger Fabric and the Ethereum Network to build Proof of Concept projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Smart Contract Development?
&lt;/h2&gt;

&lt;p&gt;There are several layers in any software. A frontend layer, which may use HTML, CSS and JS to build and display a UI, and a backend layer involving a server for processing transactions and a database for persisting data. Smart Contracts are just an addition to these layers. For a complete app, all layers have to be involved.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Smart Contracts, unlike other software layers, are very flexible. They may not need a separate frontend and backend. Business logic can be coded in the smart contracts and deployed into the respective network directly.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;On Smart Contracts:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Smart contracts have an inbuilt system of authentication. You supply your public key, and sign a secret with your private key, to prove your identity. Smart Contracts run on blockchain nodes, meaning any machine which is part of the blockchain can execute your code. You pay the nodes a gas fee to have your code executed.  To store data on the blockchain, you similarly pay gas fees to have your data/variables appended to the blockchain.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why not Learn it as a Beginner?
&lt;/h2&gt;

&lt;p&gt;While Shadab gained a lot of expertise in the field of blockchain, he advices young developers to skip the trend. In TCS, Shadab worked with clients from the automotive industry who wanted to integrate Blockchain with manufacturing. In this process, he realized that the value proposition of blockchain technologies was low, because of the low value generation as compared to the investment needed to run and maintain a smart contract.&lt;/p&gt;

&lt;p&gt;His observation was that the interest in these technologies has been because of the hype itself.&lt;/p&gt;

&lt;p&gt;Owing to this hype, students and new-comers to technology are not yet accustomed with the underlying technologies themselves. Web3 App development is similar to other software development. UI and UX still matters. Building projects by the traditional ways is how one truly understands the true meaning and use of decentralized systems.&lt;/p&gt;

&lt;p&gt;Shadab also stresses on the fact that Blockchain is still in a very adolescent stage, where it's not mature enough to handle the complexities of real world problems.&lt;/p&gt;

&lt;p&gt;You can check the complete conversation on YouTube. In case you want to attend future spaces (which we hold every 3rd weekend now), &lt;a href="https://twitter.com/thewritingdev"&gt;follow me on Twitter&lt;/a&gt; for updates.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/aYrd8N33QMY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>web3</category>
      <category>blockchain</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Learn the Right Way to build React apps in Deno in 10 minutes [Aleph.JS]</title>
      <dc:creator>Akash Joshi</dc:creator>
      <pubDate>Sun, 20 Jun 2021 04:12:57 +0000</pubDate>
      <link>https://dev.to/thewritingdev/learn-the-right-way-to-build-react-apps-in-deno-in-10-minutes-aleph-js-4b05</link>
      <guid>https://dev.to/thewritingdev/learn-the-right-way-to-build-react-apps-in-deno-in-10-minutes-aleph-js-4b05</guid>
      <description>&lt;p&gt;Hey all 👋, you must have read about Deno, the new backend #javascript runtime recently. I was hacking around with it in one of my older videos, and I wondered if we can build #ReactJs apps on it. Turns out we can!&lt;/p&gt;

&lt;p&gt;Using AlephJs, one can build a React app in Deno while using the exact same API as #NextJS, ie,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;pages&lt;/li&gt;
&lt;li&gt;components&lt;/li&gt;
&lt;li&gt;api, etc&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In my new video, I'll teach you how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create websites using Deno and React&lt;/li&gt;
&lt;li&gt;Understand how to import BOTH deno and node components and use them&lt;/li&gt;
&lt;li&gt;Customize some code to show how to use AlephJS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you like the content, follow me &lt;a href="https://twitter.com/thewritingdev"&gt;on Twitter&lt;/a&gt; for similar videos.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/SDTedmFhnQc"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>deno</category>
      <category>react</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
