<?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>Forem: Jonny</title>
    <description>The latest articles on Forem by Jonny (@jdtoombs).</description>
    <link>https://forem.com/jdtoombs</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%2F1284701%2F75a48187-a1f7-499d-9363-4b288d84ef73.png</url>
      <title>Forem: Jonny</title>
      <link>https://forem.com/jdtoombs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/jdtoombs"/>
    <language>en</language>
    <item>
      <title>Neovim changed my perspective</title>
      <dc:creator>Jonny</dc:creator>
      <pubDate>Tue, 20 Feb 2024 00:11:56 +0000</pubDate>
      <link>https://forem.com/jdtoombs/aftermath-of-switching-from-vscode-to-neovim-4efl</link>
      <guid>https://forem.com/jdtoombs/aftermath-of-switching-from-vscode-to-neovim-4efl</guid>
      <description>&lt;p&gt;&lt;em&gt;How deep down do I want to explore?&lt;/em&gt; A thought I ponder, neck-deep in a project trying to use &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components"&gt;Web Components&lt;/a&gt; instead of &lt;a href="https://react.dev/"&gt;React&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Is it worth it?&lt;/em&gt; I think while attempting to create a game engine with the Canvas API and vanilla JavaScript. (I quickly ditched that idea and started using &lt;a href="https://phaser.io/"&gt;Phaser&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Should I build my own hot reload?&lt;/em&gt; I wonder while exploring the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API"&gt;WebSocket&lt;/a&gt; API because I decided to potentially not use &lt;a href="https://vitejs.dev/guide/"&gt;Vite&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But you get the point - a common dilemma I encounter is how far back I want to learn about a certain topic. But the thing is - all these "rabbit hole" experiences I've encountered have proven to be, time and time again, some of the most valuable experiences I face. I have never regretted my time exploring these technologies, even if I didn't end up using them. Having a deeper understanding of the tools I use every day allows me to make better implementation decisions in my job, for my personal projects, and even when brainstorming my next project. &lt;/p&gt;

&lt;p&gt;Let's rewind...&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"...neck-deep in a project trying to use &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components"&gt;Web Components&lt;/a&gt; instead of &lt;a href="https://react.dev/"&gt;React&lt;/a&gt;..."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I ended up choosing to stick with Web Components. Although I could have built my idea much more quickly using a framework like React, a little bit of research is what sold it for me. It was as simple as figuring out how I could make my own version of React's state variable within a Web Component. That sparked my interest in how this magic behind closed doors with React occurs. This is obviously just the tip of the iceberg, and I want to learn more.&lt;/p&gt;

&lt;p&gt;For those interested - and as you probably could have guessed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// React state variable&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Initialize the state variable 'count' with a default value of 0&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&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="c1"&gt;// Function to increment the count&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;incrementCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&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="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;You clicked the button &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; times.&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;incrementCount&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Click me&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

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

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// WebComponent&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CounterComponent&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;HTMLElement&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Always call super() first in the constructor.&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Initialize the state.&lt;/span&gt;

    &lt;span class="c1"&gt;// Create a shadow root to encapsulate styles and markup.&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;shadow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;attachShadow&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;open&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="c1"&gt;// Initial render of the component.&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// Method to increment the count.&lt;/span&gt;
  &lt;span class="nf"&gt;incrementCount&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Re-render the component with the new count.&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// Method to render the component.&lt;/span&gt;
  &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;shadow&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`
      &amp;lt;style&amp;gt;
        /* Styles specific to this component */
        div {
          padding: 10px;
          background-color: #f0f0f0;
          border-radius: 5px;
          display: inline-block;
        }
        button {
          margin-top: 10px;
        }
      &amp;lt;/style&amp;gt;
      &amp;lt;div&amp;gt;
        &amp;lt;p&amp;gt;You clicked the button &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; times.&amp;lt;/p&amp;gt;
        &amp;lt;button&amp;gt;Click me&amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
    `&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Attach the click event listener to the button.&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;shadow&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;onclick&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;incrementCount&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="c1"&gt;// Define the new element.&lt;/span&gt;
&lt;span class="nx"&gt;customElements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;counter-component&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;CounterComponent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This leads me to discover the Shadow DOM. My first thought was, is it like the Virtual DOM? To answer that question... sort of, but not really... I will quickly highlight some of their similarities before going over what makes them different.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How are they similar?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;they both aim to optimize DOM interactions giving a smoother user experience&lt;/li&gt;
&lt;li&gt;the both perform DOM manipulation for dynamic content updates&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How are they different?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shadow DOM is native to the browser, while the Virtual DOM is a concept in JavaScript frameworks like React&lt;/li&gt;
&lt;li&gt;Virtual DOM uses a diffing algorithm to update the DOM efficiently&lt;/li&gt;
&lt;li&gt;Shadow DOM's main goal is encapsulation and isolation within the DOM&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are just a few examples of gathering a deeper understanding of the tools we use everyday from a tiny bit of research.&lt;/p&gt;

&lt;p&gt;A common consensus throughout the dev community is that a lot of us newbies (including myself) are learning things backwards. Yes, I went through a Computer Science degree and learned the fundamentals and theory; however, it felt like that wasn't enough to prepare me for the &lt;em&gt;&lt;u&gt;shields&lt;/u&gt;&lt;/em&gt; of frameworks and libraries I would be using and what they are actually doing behind the scenes.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I view some of these frameworks as "shields" as I find I often get too comfortable using these tools without understanding what is going on under the hood...&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;But wait, how does any of this tie into Neovim?&lt;/p&gt;

&lt;p&gt;All these thoughts I've shared, I would have them on occasion - but ever since I switched to Linux and &lt;a href="https://neovim.io/"&gt;Neovim&lt;/a&gt;, my curiosity has been through the roof. Switching over to Neovim and Linux was a not so fun weekend of configuration and spending half a day getting my work's local dev environment running on my new OS (which no one has tested development on). But I now have a deeper understanding of the tools I use, and have a text editor configured to be the most optimal for the way I want to use it. &lt;/p&gt;

&lt;p&gt;Yeah, thinking back logically, I would have done it differently. But diving headfirst like that has truly sparked drive, curiosity, confidence, and confirmation that I have in fact chosen the right field. I feel grateful to be in it. If you're on the verge of deciding to try Vim? I say absolutely go for it, just be cautious you may lose some efficiency at the start. But in my experience, it does not take long at all to surpass that of moving with the mouse. If you're on the verge of trying Neovim? Do it. These things aren't as easy to set up as VSCode or Sublime - but they are what resparked my passion for development.&lt;/p&gt;

&lt;p&gt;Understanding one of the tools I use everyday (my text editor) has led to a chain reaction of curiosity into almost every tool I use for development, and that excites me.&lt;/p&gt;

&lt;p&gt;Let me know what your experiences are with Neovim/Vim motions if you have tried them out after using mouse and keyboard for a long time.&lt;/p&gt;

&lt;p&gt;Shout out (not that he needs it) to the &lt;a href="https://twitter.com/ThePrimeagen"&gt;Primeagen&lt;/a&gt;. All those "Vim btw" jokes wore me down to the point of where I decided to try it.&lt;/p&gt;

&lt;p&gt;He has a great video found &lt;a href="https://youtu.be/w7i4amO_zaE?si=v4DDsmLAT_oI8yru"&gt;here&lt;/a&gt; that goes through setting up an environment from scratch for Neovim.&lt;/p&gt;

&lt;p&gt;Ps. If feel free to share additional information, I am all ears and open to correction :)&lt;/p&gt;

</description>
      <category>neovim</category>
      <category>webdev</category>
      <category>react</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
