<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title>Jon Kuperman</title>
	<subtitle>Writing about JavaScript runtimes, compilers, developer tooling, and engineering leadership.</subtitle>
	
	<link href="https://jonkuperman.com/feed/feed.xml" rel="self"/>
	<link href="https://jonkuperman.com/"/>
	<updated>2025-06-10T00:00:00Z</updated>
	<id>https://jonkuperman.com</id>
	<author>
		<name>Jon Kuperman</name>
		<email></email>
	</author>
	
	<entry>
		<title>Chatting with an old friend</title>
		<link href="https://jonkuperman.com/chatting-with-an-old-friend/"/>
		<updated>2025-06-10T00:00:00Z</updated>
		<id>https://jonkuperman.com/chatting-with-an-old-friend/</id>
		<content type="html">&lt;p&gt;Mikeal Rogers passed away yesterday. We hadn&#39;t kept in touch nearly enough, but he had a profound impact on my life and was always very kind to me. One of my favorite tweets of all time was from him, when I gave a talk as a young kid about how cool Chrome DevTools were and the Chrome DevTools team showed up unexpectedly to watch.&lt;/p&gt;
&lt;blockquote class=&quot;twitter-tweet&quot; data-dnt=&quot;true&quot; align=&quot;center&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;Watching &lt;a href=&quot;https://twitter.com/paul_irish?ref_src=twsrc%5Etfw&quot;&gt;@paul_irish&lt;/a&gt; watch a talk at &lt;a href=&quot;https://twitter.com/wafflejs?ref_src=twsrc%5Etfw&quot;&gt;@wafflejs&lt;/a&gt; about Chrome Dev Tools. &lt;a href=&quot;https://t.co/nXNAIUIn8f&quot;&gt;pic.twitter.com/nXNAIUIn8f&lt;/a&gt;&lt;/p&gt;&amp;mdash; Mikeal Rogers (@mikeal) &lt;a href=&quot;https://twitter.com/mikeal/status/684960175527084032?ref_src=twsrc%5Etfw&quot;&gt;January 7, 2016&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;https://platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;
&lt;p&gt;I was reading Jenn Schiffer&#39;s Bluesky post about him when I realized I had also recorded a podcast with Mikeal, way back in the day.&lt;/p&gt;
&lt;blockquote class=&quot;bluesky-embed&quot; data-bluesky-uri=&quot;at://did:plc:x5leeami62gbmjekf7ro6sqo/app.bsky.feed.post/3lrbfmksxnk2d&quot; data-bluesky-cid=&quot;bafyreigelu2ngfgbnhgs66fdauct2nduwkwe5sqimi4ltingddrrivtncy&quot; data-bluesky-embed-color-mode=&quot;system&quot;&gt;&lt;p lang=&quot;en&quot;&gt;a collaborator and friend has moved on this week, and in memoriam i wanted to share my train of thought in grief.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;https://bsky.app/profile/did:plc:x5leeami62gbmjekf7ro6sqo/post/3lrbfmksxnk2d?ref_src=embed&quot;&gt;[image or embed]&lt;/a&gt;&lt;/p&gt;&amp;mdash; jenn schiffer 🕷️🕯️ (&lt;a href=&quot;https://bsky.app/profile/did:plc:x5leeami62gbmjekf7ro6sqo?ref_src=embed&quot;&gt;@jennschiffer.com&lt;/a&gt;) &lt;a href=&quot;https://bsky.app/profile/did:plc:x5leeami62gbmjekf7ro6sqo/post/3lrbfmksxnk2d?ref_src=embed&quot;&gt;June 10, 2025 at 6:19 PM&lt;/a&gt;&lt;/blockquote&gt;&lt;script async=&quot;&quot; src=&quot;https://embed.bsky.app/static/embed.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;
&lt;h2 id=&quot;the-web-behind&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chatting-with-an-old-friend/#the-web-behind&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Web Behind&lt;/h2&gt;
&lt;p&gt;I had started this podcast called The Web Behind in 2015 (I know...) to interview developers I knew (mostly in SF) and ask them about how they got their start. It was really fun for me getting to know people and hearing their diverse stories. I went to go to my &lt;a href=&quot;https://webbehind.com/&quot;&gt;old website&lt;/a&gt; to listen to the episode with Mikeal but there was a problem.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/web-behind-gone.png&quot; alt=&quot;web behind website is gone&quot; /&gt;&lt;/p&gt;
&lt;p&gt;That&#39;s annoying, but then I figured I could use the way back machine to find it!&lt;/p&gt;
&lt;p&gt;I found a snapshot of the old site, and found the link for the episode! But there was no audio embed!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/wayback-web-behind.png&quot; alt=&quot;wayback machine web behind&quot; /&gt;&lt;/p&gt;
&lt;p&gt;That&#39;s ok, I opened the Chrome Devtools and found the embed link! It&#39;s for a Soundcloud file. But when I clicked on it, it just redirected to the Soundcloud home page. At least I had a lead...&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/wayback-devtools.png&quot; alt=&quot;wayback machine chrome devtools&quot; /&gt;&lt;/p&gt;
&lt;p&gt;I searched Soundcloud for &amp;quot;web behind&amp;quot; and I found the page! But strangely, there were only 4 episodes on there and Mikeal&#39;s wasn&#39;t one of them. Even stranger, the right sidebar said &amp;quot;8 tracks&amp;quot; but I could only see 4. I wondered if I could still get into that account.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/soundcloud-web-behind.png&quot; alt=&quot;soundcloud web behind&quot; /&gt;&lt;/p&gt;
&lt;p&gt;I went to soundcloud and logged in with my email address. Had to reset it multiple times since I had missed multiple security breaches while I&#39;d been gone. I finally got in only to find that email address did not own the Web Behind account.&lt;/p&gt;
&lt;p&gt;I searched a few times to see if there was any way to figure out what email address a channel belonged to but obviously that would be a terrible thing for Soundcloud to do so I was stuck.&lt;/p&gt;
&lt;h2 id=&quot;a-lucky-break&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chatting-with-an-old-friend/#a-lucky-break&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; A lucky break&lt;/h2&gt;
&lt;p&gt;I was clicking all around, trying old email addresses, looking at my web hosting to see all the email accounts I&#39;ve ever created but having no luck. I kept trying things like &lt;code&gt;jon@webbehind.com&lt;/code&gt; or &lt;code&gt;admin@webbehind.com&lt;/code&gt;. One nice thing is that Soundcloud lets you know after you enter just an email address whether it&#39;s associated with an account or not. No luck.&lt;/p&gt;
&lt;p&gt;I was playing around with Postman to see if I could scrape any information when I caught a break! It turns out that I had linked my Soundcloud account to iTunes and the iTunes email address is listed in the RSS feed!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/soundcloud-rss.png&quot; alt=&quot;soundcloud rss&quot; /&gt;&lt;/p&gt;
&lt;p&gt;I couldn&#39;t guess the gmail password but as luck would have it, I did set up my real email address as the backup for the account, so I was able to reset it!&lt;/p&gt;
&lt;p&gt;With that, I was able to reset my Soundcloud password and log in! At first I had no luck, I was still only able to see the 4 public episodes. But then I noticed on the Insights page if I zoomed out I could see traffic to Mikeal&#39;s episode from years ago. Eventually I figured out what had happened!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/soundcloud-hidden.png&quot; alt=&quot;soundcloud hidden tracks&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It turns out Soundcloud had changed their free plan, and my account was way over the limit of upload minutes. So they must have removed my oldest episdoes so that I was in line with the free plan.&lt;/p&gt;
&lt;h2 id=&quot;a-bargain-at-any-price&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chatting-with-an-old-friend/#a-bargain-at-any-price&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; A bargain at any price&lt;/h2&gt;
&lt;p&gt;All I needed to do was give Soundcloud $10 for whatever Soundcloud Artist is and download the episode!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/soundcloud-artist.png&quot; alt=&quot;soundcloud artist&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/soundcloud-unlocked.png&quot; alt=&quot;soundcloud unlocked&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;it&#39;s-nice-to-hear-your-voice&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chatting-with-an-old-friend/#it&#39;s-nice-to-hear-your-voice&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; It&#39;s nice to hear your voice&lt;/h2&gt;
&lt;p&gt;Thanks for the puzzle, Mikeal. It&#39;s nice to hear your voice again.&lt;/p&gt;
&lt;iframe width=&quot;100%&quot; height=&quot;300&quot; scrolling=&quot;no&quot; frameborder=&quot;no&quot; allow=&quot;autoplay&quot; src=&quot;https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/252513132&amp;color=%23ff5500&amp;auto_play=false&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false&amp;show_teaser=true&amp;visual=true&quot;&gt;&lt;/iframe&gt;&lt;div style=&quot;font-size: 10px; color: #cccccc;line-break: anywhere;word-break: normal;overflow: hidden;white-space: nowrap;text-overflow: ellipsis; font-family: Interstate,Lucida Grande,Lucida Sans Unicode,Lucida Sans,Garuda,Verdana,Tahoma,sans-serif;font-weight: 100;&quot;&gt;&lt;a href=&quot;https://soundcloud.com/the-web-behind&quot; title=&quot;The Web Behind&quot; target=&quot;_blank&quot; style=&quot;color: #cccccc; text-decoration: none;&quot;&gt;The Web Behind&lt;/a&gt; · &lt;a href=&quot;https://soundcloud.com/the-web-behind/mikeal-rogers&quot; title=&quot;Mikeal Rogers&quot; target=&quot;_blank&quot; style=&quot;color: #cccccc; text-decoration: none;&quot;&gt;Mikeal Rogers&lt;/a&gt;&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>C++ Pointers for JavaScript/TypeScript Developers</title>
		<link href="https://jonkuperman.com/cpp-pointers-js-devs/"/>
		<updated>2025-03-14T00:00:00Z</updated>
		<id>https://jonkuperman.com/cpp-pointers-js-devs/</id>
		<content type="html">&lt;h2 id=&quot;introduction&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#introduction&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Introduction&lt;/h2&gt;
&lt;p&gt;I&#39;ve been coding in JavaScript for years, but recently started working on a project that required C++. The biggest mental hurdle? Pointers. If you&#39;re like me, coming from JavaScript or TypeScript, the concept of pointers can feel alien at first.&lt;/p&gt;
&lt;p&gt;In JavaScript, we create objects and arrays without thinking about where they live in memory:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// JavaScript - create and forget&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; user &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Alice&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; users &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Bob&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But in C++, you need to be much more explicit about memory:&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// C++ - be explicit about memory&lt;/span&gt;
User&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; user &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Alice&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Allocate on heap&lt;/span&gt;
User users&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Bob&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Copy to stack array&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;delete&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Clean up when done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This post is my attempt to explain pointers in a way that makes sense to JavaScript developers. I won&#39;t pretend pointers are simple - they&#39;re powerful and can be dangerous - but understanding them will make you a better programmer, even if you never write C++ professionally.&lt;/p&gt;
&lt;p&gt;Pointers give you direct access to memory, but they require careful handling to avoid bugs that simply don&#39;t exist in JavaScript.&lt;/p&gt;
&lt;h2 id=&quot;memory-management:-the-fundamental-difference&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#memory-management:-the-fundamental-difference&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Memory Management: The Fundamental Difference&lt;/h2&gt;
&lt;p&gt;The biggest difference between JavaScript and C++ is how they handle memory. In JavaScript, the runtime does all the heavy lifting:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// JavaScript&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;createUsers&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; users &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; count&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    users&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; i&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;User &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;i&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; users&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// JavaScript handles memory automatically&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; myUsers &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;createUsers&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Later, when myUsers is no longer referenced...&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// JavaScript garbage collector cleans up&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In C++, you&#39;re responsible for memory management. You need to explicitly allocate and free memory:&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// C++&lt;/span&gt;
User&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;createUsers&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; count&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  User&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; users &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; User&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;count&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Allocate array on heap&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; count&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    users&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;User &quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;to_string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Allocate each user on heap&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; users&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Later...&lt;/span&gt;
User&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; myUsers &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;createUsers&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// YOU must clean up&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;delete&lt;/span&gt; myUsers&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Free each user&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;delete&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; myUsers&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Free the array&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Forget that cleanup code, and you&#39;ve got a memory leak. In JavaScript, you&#39;d never have to worry about this.&lt;/p&gt;
&lt;h3 id=&quot;stack-vs.-heap:-where-variables-live&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#stack-vs.-heap:-where-variables-live&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Stack vs. Heap: Where Variables Live&lt;/h3&gt;
&lt;p&gt;In C++, you need to understand where your data lives:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Stack&lt;/strong&gt;: Fast, automatic memory for local variables. Limited in size, automatically cleaned up.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Heap&lt;/strong&gt;: Larger, manual memory that persists until you explicitly free it.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;example&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Stack allocation - automatic cleanup when function ends&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; stackNumber &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  User &lt;span class=&quot;token function&quot;&gt;stackUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Alice&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  
  &lt;span class=&quot;token comment&quot;&gt;// Heap allocation - manual cleanup required&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; heapNumber &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  User&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; heapUser &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Bob&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  
  &lt;span class=&quot;token comment&quot;&gt;// Must clean up heap allocations!&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;delete&lt;/span&gt; heapNumber&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;delete&lt;/span&gt; heapUser&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;when-to-use-stack-vs.-heap&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#when-to-use-stack-vs.-heap&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; When to use Stack vs. Heap&lt;/h4&gt;
&lt;p&gt;It&#39;s important to understand that it&#39;s not the asterisk (&lt;code&gt;*&lt;/code&gt;) that determines stack vs. heap allocation - it&#39;s how you create the object:&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Stack allocation (no &#39;new&#39; keyword)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; stackInt &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;                &lt;span class=&quot;token comment&quot;&gt;// On stack&lt;/span&gt;
User &lt;span class=&quot;token function&quot;&gt;stackUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Alice&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;          &lt;span class=&quot;token comment&quot;&gt;// On stack&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; stackArray&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;               &lt;span class=&quot;token comment&quot;&gt;// On stack&lt;/span&gt;
User&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; pointerToStackUser &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;stackUser&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Pointer is on stack, pointing to stack object&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Heap allocation (using &#39;new&#39; keyword)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; heapInt &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;       &lt;span class=&quot;token comment&quot;&gt;// On heap&lt;/span&gt;
User&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; heapUser &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Bob&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// On heap&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; heapArray &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;     &lt;span class=&quot;token comment&quot;&gt;// On heap&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;What does the asterisk (*) actually mean?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The asterisk (&lt;code&gt;*&lt;/code&gt;) in C++ declarations indicates that a variable is a pointer. A pointer is simply a variable that stores a memory address rather than a value directly. The asterisk itself doesn&#39;t determine where the memory is allocated (stack vs. heap) - it just declares that the variable will hold an address.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;int x = 5;&lt;/code&gt; - Regular variable storing the value 5&lt;/li&gt;
&lt;li&gt;&lt;code&gt;int* ptr;&lt;/code&gt; - Pointer variable that can store the address of an int&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ptr = &amp;amp;x;&lt;/code&gt; - Store the address of x in ptr&lt;/li&gt;
&lt;li&gt;&lt;code&gt;*ptr = 10;&lt;/code&gt; - Follow the address in ptr and get what&#39;s inside (which is 42)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;code&gt;new&lt;/code&gt; keyword is what actually allocates memory on the heap, and the pointer is just used to keep track of where that memory is located.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Choose Stack when:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You need small, fixed-size objects&lt;/li&gt;
&lt;li&gt;The object&#39;s lifetime is limited to the current function/scope&lt;/li&gt;
&lt;li&gt;You want automatic cleanup&lt;/li&gt;
&lt;li&gt;Performance is critical (stack allocation is much faster)&lt;/li&gt;
&lt;li&gt;The object size is known at compile time&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Choose Heap when:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You need large objects (stack size is limited, often to just a few MB)&lt;/li&gt;
&lt;li&gt;You need objects that persist beyond the current function&lt;/li&gt;
&lt;li&gt;You don&#39;t know the size at compile time (like dynamic arrays)&lt;/li&gt;
&lt;li&gt;You&#39;re returning objects from functions that need to live after the function returns&lt;/li&gt;
&lt;li&gt;You&#39;re sharing objects between different parts of your program&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In JavaScript, this decision is made for you - primitive values like numbers are similar to stack variables, while objects and arrays are automatically managed on the heap.&lt;/p&gt;
&lt;h2 id=&quot;what-are-pointers-really&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#what-are-pointers-really&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What Are Pointers, Really?&lt;/h2&gt;
&lt;p&gt;A pointer is just a variable that stores a memory address. That&#39;s it. Nothing more magical than that.&lt;/p&gt;
&lt;p&gt;Think of your computer&#39;s memory like a giant apartment building. Each apartment (memory location) has an address and can store some data. A pointer is just a piece of paper with an apartment number written on it.&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; number &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;        &lt;span class=&quot;token comment&quot;&gt;// Create a variable with value 42&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; pointer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;number&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Create a pointer that stores number&#39;s address&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;number&lt;/code&gt; is an apartment containing the value &lt;code&gt;42&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;amp;number&lt;/code&gt; is the address of that apartment (like &amp;quot;Apartment 1234&amp;quot;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;pointer&lt;/code&gt; is a piece of paper with &amp;quot;Apartment 1234&amp;quot; written on it&lt;/li&gt;
&lt;li&gt;&lt;code&gt;*pointer&lt;/code&gt; means &amp;quot;go to the address written on the paper and get what&#39;s inside&amp;quot; (which is 42)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When you use the asterisk in front of a pointer variable (like &lt;code&gt;*pointer&lt;/code&gt;), it&#39;s called &amp;quot;dereferencing&amp;quot; - you&#39;re accessing the value at the address stored in the pointer. This is different from when you use the asterisk in a declaration (like &lt;code&gt;int* ptr&lt;/code&gt;), where it indicates that the variable is a pointer type.&lt;/p&gt;
&lt;h3 id=&quot;how-this-differs-from-javascript-references&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#how-this-differs-from-javascript-references&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; How This Differs From JavaScript References&lt;/h3&gt;
&lt;p&gt;In JavaScript, we have references, which might seem similar but work differently:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; obj &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; reference &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; obj&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Both point to the same object&lt;/span&gt;
reference&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;count &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;obj&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;count&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 100&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// But reassigning the reference just changes what it references&lt;/span&gt;
reference &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;200&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;obj&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;count&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Still 100&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The key differences:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;JavaScript references are &lt;strong&gt;implicit&lt;/strong&gt; - you don&#39;t use special syntax to create or dereference them&lt;/li&gt;
&lt;li&gt;JavaScript references are &lt;strong&gt;higher-level&lt;/strong&gt; - they point to objects, not raw memory addresses&lt;/li&gt;
&lt;li&gt;JavaScript references are &lt;strong&gt;safer&lt;/strong&gt; - you can&#39;t manipulate memory directly or cause memory corruption&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;pointer-syntax-and-operations:-the-basics&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#pointer-syntax-and-operations:-the-basics&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Pointer Syntax and Operations: The Basics&lt;/h2&gt;
&lt;p&gt;Let&#39;s break down the essential pointer operations you&#39;ll need to know:&lt;/p&gt;
&lt;h3 id=&quot;1.-declaring-pointers&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#1.-declaring-pointers&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 1. Declaring Pointers&lt;/h3&gt;
&lt;p&gt;There are two common styles for declaring pointers:&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; ptr&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Style 1: asterisk with the type&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Style 2: asterisk with the variable name&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Both are functionally identical. I prefer the first style because it makes it clearer that the type is &amp;quot;pointer to int,&amp;quot; but you&#39;ll see both in C++ code.&lt;/p&gt;
&lt;h3 id=&quot;2.-getting-an-address-with-and&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#2.-getting-an-address-with-and&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 2. Getting an Address with &amp;amp;&lt;/h3&gt;
&lt;p&gt;The address-of operator &lt;code&gt;&amp;amp;&lt;/code&gt; gives you the memory address of a variable:&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; number &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; ptr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;number&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// ptr now holds the address of number&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;3.-dereferencing-with-*&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#3.-dereferencing-with-*&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 3. Dereferencing with *&lt;/h3&gt;
&lt;p&gt;The dereference operator &lt;code&gt;*&lt;/code&gt; lets you access the value at an address:&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; number &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; ptr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;number&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;ptr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Change the value at the address&lt;/span&gt;
std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;cout &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; number &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;endl&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Prints 100&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;4.-null-pointers&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#4.-null-pointers&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 4. Null Pointers&lt;/h3&gt;
&lt;p&gt;A pointer that doesn&#39;t point to anything should be set to &lt;code&gt;nullptr&lt;/code&gt; (in modern C++):&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; ptr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;nullptr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Explicitly doesn&#39;t point to anything&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Always check before dereferencing&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ptr &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;nullptr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;ptr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Safe&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// Handle null case&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Shorthand if check (nullptr converts to false)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;ptr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Safe&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In older C++ code, you might see &lt;code&gt;NULL&lt;/code&gt; or even &lt;code&gt;0&lt;/code&gt; used instead of &lt;code&gt;nullptr&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;5.-pointer-arithmetic&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#5.-pointer-arithmetic&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 5. Pointer Arithmetic&lt;/h3&gt;
&lt;p&gt;C++ also allows you to perform arithmetic on pointers:&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; numbers&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; ptr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; numbers&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Points to first element&lt;/span&gt;

std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;cout &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;ptr &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;endl&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;      &lt;span class=&quot;token comment&quot;&gt;// 10&lt;/span&gt;
std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;cout &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ptr &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;endl&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 20&lt;/span&gt;
std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;cout &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ptr &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;endl&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 30&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Shorthand using array notation&lt;/span&gt;
std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;cout &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; ptr&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;endl&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;     &lt;span class=&quot;token comment&quot;&gt;// 10&lt;/span&gt;
std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;cout &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; ptr&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;endl&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;     &lt;span class=&quot;token comment&quot;&gt;// 20&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is powerful but dangerous - C++ won&#39;t stop you from accessing memory beyond the array bounds. For example:&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; numbers&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; ptr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; numbers&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// This is dangerous - accessing beyond the array&lt;/span&gt;
std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;cout &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ptr &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;endl&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Reading unknown memory!&lt;/span&gt;
&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ptr &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;                      &lt;span class=&quot;token comment&quot;&gt;// Writing to unknown memory!&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;C++ will happily let you read or write to memory locations that don&#39;t belong to your array. This can cause:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Program crashes (if you&#39;re lucky)&lt;/li&gt;
&lt;li&gt;Corrupted data in other variables&lt;/li&gt;
&lt;li&gt;Security vulnerabilities like buffer overflows&lt;/li&gt;
&lt;li&gt;Unpredictable behavior that&#39;s hard to debug&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;memory-safety-and-modern-languages&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#memory-safety-and-modern-languages&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Memory Safety and Modern Languages&lt;/h3&gt;
&lt;p&gt;This issue is exactly why memory-safe languages like Rust have gained popularity. Rust provides similar performance to C++ but prevents these memory safety issues through its ownership system and compile-time checks.&lt;/p&gt;
&lt;p&gt;In Rust, the equivalent code would fail to compile or would perform bounds checking at runtime:&lt;/p&gt;
&lt;pre class=&quot;language-rust&quot;&gt;&lt;code class=&quot;language-rust&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; numbers &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token macro property&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;{}&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; numbers&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Runtime panic: index out of bounds&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;JavaScript, like Rust, is memory-safe by design:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; numbers &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;numbers&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// undefined (not a crash)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;According to Microsoft, around 70% of their security vulnerabilities are related to memory safety issues in languages like C and C++. This is why there&#39;s a growing movement toward memory-safe languages for systems programming, with Rust leading the charge.&lt;/p&gt;
&lt;p&gt;C++ has evolved to provide safer alternatives like &lt;code&gt;std::vector&lt;/code&gt; with bounds checking, but the raw pointer operations remain available for performance-critical code:&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Safer alternative with bounds checking&lt;/span&gt;
std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;vector&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; numbers &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// This will throw an exception instead of accessing invalid memory&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;cout &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; numbers&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;at&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;endl&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;out_of_range&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;cout &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Error: &quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;what&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;endl&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;references-vs-pointers:-the-c++-alternative&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#references-vs-pointers:-the-c++-alternative&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; References vs Pointers: The C++ Alternative&lt;/h2&gt;
&lt;p&gt;C++ offers another mechanism called &amp;quot;references&amp;quot; that might feel more familiar to JavaScript developers:&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Pointer approach&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;updateUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;User&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    user&lt;span class=&quot;token operator&quot;&gt;-&gt;&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Bob&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Reference approach&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;updateUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;User&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Bob&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;References provide a syntax that feels more like JavaScript&#39;s reference behavior, but with important differences:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;References can&#39;t be null&lt;/li&gt;
&lt;li&gt;References can&#39;t be reassigned&lt;/li&gt;
&lt;li&gt;References must be initialized when declared&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;When to use which?&lt;/strong&gt; Here&#39;s a quick decision guide:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Need to represent &amp;quot;no value&amp;quot;? → Pointer (&lt;code&gt;nullptr&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Need to reassign to point to different objects? → Pointer&lt;/li&gt;
&lt;li&gt;Just need to modify an existing object? → Reference&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;void-pointers-and-type-casting&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#void-pointers-and-type-casting&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Void Pointers and Type Casting&lt;/h2&gt;
&lt;p&gt;Sometimes you need a pointer that can point to any type - enter the &lt;code&gt;void*&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; genericPointer&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; number &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
genericPointer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;number&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Points to an int&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// To use it, you must cast it back&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; numberPointer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;static_cast&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;genericPointer&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is somewhat analogous to TypeScript&#39;s type assertions, but with a crucial difference: in C++, you&#39;re responsible for ensuring the cast is valid.&lt;/p&gt;
&lt;h3 id=&quot;c++-type-casting-vs.-typescript-type-assertions&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#c++-type-casting-vs.-typescript-type-assertions&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; C++ Type Casting vs. TypeScript Type Assertions&lt;/h3&gt;
&lt;p&gt;While both C++ and TypeScript allow you to override the type system, they handle invalid casts very differently:&lt;/p&gt;
&lt;h4 id=&quot;in-typescript:&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#in-typescript:&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; In TypeScript:&lt;/h4&gt;
&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// TypeScript type assertion&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; num &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; str &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; num &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;unknown&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token builtin&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;str&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toUpperCase&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// RUNTIME ERROR: str.toUpperCase is not a function&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;TypeScript&#39;s type assertions are primarily a &lt;strong&gt;compile-time&lt;/strong&gt; construct. The TypeScript compiler will accept your assertion and stop checking types, but at runtime, JavaScript will still enforce type safety and throw errors for invalid operations.&lt;/p&gt;
&lt;h4 id=&quot;in-c++:&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#in-c++:&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; In C++:&lt;/h4&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// C++ type casting&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; num &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; str &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;static_cast&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt;num&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;cout &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; str&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; str&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; str&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// UNDEFINED BEHAVIOR: Reading memory as if it were a string&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;C++ type casts actually reinterpret the raw memory. There&#39;s no runtime type checking - the program will attempt to use the memory as if it were the type you claimed, potentially causing:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Memory corruption&lt;/strong&gt; - Writing to memory as if it were a different type&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Segmentation faults&lt;/strong&gt; - Accessing memory in invalid ways&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Silent data corruption&lt;/strong&gt; - Getting wrong values without any error&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Undefined behavior&lt;/strong&gt; - Anything can happen, including seeming to work correctly sometimes&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In other words, TypeScript&#39;s type assertions are a way to tell the compiler &amp;quot;trust me, I know what I&#39;m doing,&amp;quot; but JavaScript will still protect you at runtime. C++ type casts are more like saying &amp;quot;I&#39;m taking full responsibility for what happens next&amp;quot; - the language won&#39;t protect you from mistakes.&lt;/p&gt;
&lt;h2 id=&quot;pointers-and-arrays:-two-sides-of-the-same-coin&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#pointers-and-arrays:-two-sides-of-the-same-coin&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Pointers and Arrays: Two Sides of the Same Coin&lt;/h2&gt;
&lt;p&gt;In C++, arrays and pointers are intimately connected in ways that might surprise JavaScript developers:&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; numbers&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; ptr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; numbers&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Array name decays to pointer&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// These are equivalent:&lt;/span&gt;
cout &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; numbers&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; endl&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Array syntax&lt;/span&gt;
cout &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ptr &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; endl&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Pointer arithmetic&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This relationship has no real equivalent in JavaScript, though TypedArrays and ArrayBuffers come closest.&lt;/p&gt;
&lt;h2 id=&quot;memory-allocation:-manual-management&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#memory-allocation:-manual-management&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Memory Allocation: Manual Management&lt;/h2&gt;
&lt;p&gt;In JavaScript, you create objects and the runtime handles memory. In C++, you must explicitly request and release memory:&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Allocating memory&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; numbers &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Request space for 100 integers&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Using the memory&lt;/span&gt;
numbers&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// MUST release the memory when done&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;delete&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; numbers&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Return the memory to the system&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you forget the delete, you&#39;ll create memory leaks - a problem JavaScript developers rarely encounter.&lt;/p&gt;
&lt;h2 id=&quot;smart-pointers:-modern-c++-to-the-rescue&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#smart-pointers:-modern-c++-to-the-rescue&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Smart Pointers: Modern C++ to the Rescue&lt;/h2&gt;
&lt;p&gt;Modern C++ provides smart pointers that help manage memory automatically, bringing some of JavaScript&#39;s convenience to C++:&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Old way with manual management&lt;/span&gt;
User&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; user &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Alice&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// ... code that might throw exceptions ...&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;delete&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Might never get called if an exception occurs!&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Modern way with smart pointers&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;auto&lt;/span&gt; user &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;make_unique&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;User&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Alice&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// No need to delete - memory is automatically freed when user goes out of scope&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Types of smart pointers:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;std::unique_ptr&lt;/code&gt; - Exclusive ownership (only one pointer can own the object)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;std::shared_ptr&lt;/code&gt; - Shared ownership with reference counting (similar to JS objects)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;std::weak_ptr&lt;/code&gt; - Non-owning reference to a shared_ptr object&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;when-to-use-each-type-of-smart-pointer&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#when-to-use-each-type-of-smart-pointer&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; When to Use Each Type of Smart Pointer&lt;/h3&gt;
&lt;h4 id=&quot;use-std::unique_ptr-when:&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#use-std::unique_ptr-when:&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Use &lt;code&gt;std::unique_ptr&lt;/code&gt; when:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;You need a single, clear owner for a resource&lt;/li&gt;
&lt;li&gt;You want to transfer ownership (using &lt;code&gt;std::move&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;You want the best performance (it has almost zero overhead compared to raw pointers)&lt;/li&gt;
&lt;li&gt;The object shouldn&#39;t be shared between different parts of your code&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Example: A function that creates and returns a resource&lt;/span&gt;
std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;unique_ptr&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Report&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;generateReport&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; Data&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt; data&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;auto&lt;/span&gt; report &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;make_unique&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Report&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    report&lt;span class=&quot;token operator&quot;&gt;-&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;analyze&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; report&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Ownership transfers to the caller&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Usage&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;processData&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; Data&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt; data&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;auto&lt;/span&gt; report &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;generateReport&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// report is automatically deleted when processData ends&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is similar to how JavaScript variables work in a limited scope - they&#39;re automatically cleaned up when they go out of scope.&lt;/p&gt;
&lt;h4 id=&quot;use-std::shared_ptr-when:&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#use-std::shared_ptr-when:&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Use &lt;code&gt;std::shared_ptr&lt;/code&gt; when:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Multiple parts of your code need ownership of the same object&lt;/li&gt;
&lt;li&gt;You don&#39;t know which owner will be the last to use it&lt;/li&gt;
&lt;li&gt;You need objects to live as long as anyone is using them&lt;/li&gt;
&lt;li&gt;You&#39;re comfortable with a small performance overhead for reference counting&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Example: Multiple components sharing access to a configuration&lt;/span&gt;
std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;shared_ptr&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Config&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;loadConfig&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;make_shared&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Config&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;config.json&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;setupComponents&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;auto&lt;/span&gt; config &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;loadConfig&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;token keyword&quot;&gt;auto&lt;/span&gt; ui &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;make_shared&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;UI&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;config&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;      &lt;span class=&quot;token comment&quot;&gt;// UI needs the config&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;auto&lt;/span&gt; network &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;make_shared&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Network&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;config&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Network also needs it&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;auto&lt;/span&gt; storage &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;make_shared&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Storage&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;config&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Storage too&lt;/span&gt;
    
    &lt;span class=&quot;token comment&quot;&gt;// Config will be deleted automatically when all three components&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// (UI, Network, Storage) are destroyed&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is most similar to JavaScript&#39;s normal behavior, where objects stay alive as long as any reference to them exists.&lt;/p&gt;
&lt;h4 id=&quot;use-std::weak_ptr-when:&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#use-std::weak_ptr-when:&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Use &lt;code&gt;std::weak_ptr&lt;/code&gt; when:&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;You need to temporarily access a shared object without extending its lifetime&lt;/li&gt;
&lt;li&gt;You want to break reference cycles (where A references B and B references A)&lt;/li&gt;
&lt;li&gt;You need to check if an object still exists before using it&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Example: Caching system that doesn&#39;t prevent objects from being cleaned up&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Cache&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;unordered_map&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;string&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;weak_ptr&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Resource&lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt; resources&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
    std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;shared_ptr&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Resource&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getResource&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;string&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt; key&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt; weakRef &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; resources&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;key&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        
        &lt;span class=&quot;token comment&quot;&gt;// Try to get a shared_ptr from the weak_ptr&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;auto&lt;/span&gt; resource &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; weakRef&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;lock&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; resource&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Resource still exists, return it&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;token comment&quot;&gt;// Resource was deleted, create a new one&lt;/span&gt;
            &lt;span class=&quot;token keyword&quot;&gt;auto&lt;/span&gt; newResource &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;make_shared&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Resource&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;key&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
            weakRef &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; newResource&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Store weak reference&lt;/span&gt;
            &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; newResource&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;javascript&#39;s-weakref-vs-c++&#39;s-weak_ptr&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#javascript&#39;s-weakref-vs-c++&#39;s-weak_ptr&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; JavaScript&#39;s WeakRef vs C++&#39;s weak_ptr&lt;/h3&gt;
&lt;p&gt;JavaScript has an equivalent to &lt;code&gt;weak_ptr&lt;/code&gt; called &lt;code&gt;WeakRef&lt;/code&gt;. Both serve a similar purpose: they hold a reference to an object without preventing garbage collection.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// JavaScript WeakRef example&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; cache &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getResource&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; weakRef &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; cache&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;key&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  
  &lt;span class=&quot;token comment&quot;&gt;// Check if the reference still exists and is valid&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; resource &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; weakRef&lt;span class=&quot;token operator&quot;&gt;?.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;deref&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;resource&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; resource&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Resource still exists&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// Create new resource since the old one was garbage collected&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; newResource &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;createExpensiveResource&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;key&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    cache&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;key&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;WeakRef&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;newResource&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; newResource&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;smart-pointer-best-practices&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#smart-pointer-best-practices&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Smart Pointer Best Practices&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Use &lt;code&gt;std::make_unique&lt;/code&gt; and &lt;code&gt;std::make_shared&lt;/code&gt; instead of &lt;code&gt;new&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Prefer &lt;code&gt;unique_ptr&lt;/code&gt; by default for its performance&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;shared_ptr&lt;/code&gt; only when you need shared ownership&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;weak_ptr&lt;/code&gt; to break reference cycles in &lt;code&gt;shared_ptr&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Never use &lt;code&gt;delete&lt;/code&gt; with smart pointers - they handle cleanup automatically&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;function-pointers-and-callbacks&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#function-pointers-and-callbacks&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Function Pointers and Callbacks&lt;/h2&gt;
&lt;p&gt;JavaScript developers are familiar with passing functions as arguments. C++ has several ways to achieve this:&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Traditional function pointer&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;processData&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; data&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; size&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;processor&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; size&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        data&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;processor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Modern approach with std::function&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;processData&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; data&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; size&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;function&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; processor&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// Same implementation&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Usage with lambda (similar to JS arrow functions)&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;processData&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;numbers&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; x&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; x &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;common-pitfalls:-where-javascript-developers-stumble&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#common-pitfalls:-where-javascript-developers-stumble&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Common Pitfalls: Where JavaScript Developers Stumble&lt;/h2&gt;
&lt;p&gt;When coming from JavaScript, these are the pointer-related mistakes you&#39;re most likely to make:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Using uninitialized pointers&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; ptr&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Contains random address!&lt;/span&gt;
&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;ptr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// CRASH: Writing to random memory&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Forgetting to delete allocated memory&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;processData&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; data &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// Process data...&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// Oops, forgot to delete[] data&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Memory leak!&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Using a pointer after freeing it&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; ptr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;delete&lt;/span&gt; ptr&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// Free the memory&lt;/span&gt;
cout &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;ptr&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// DANGER: Using freed memory&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;practical-examples:-from-javascript-to-c++&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#practical-examples:-from-javascript-to-c++&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Practical Examples: From JavaScript to C++&lt;/h2&gt;
&lt;p&gt;Let&#39;s see how common JavaScript patterns translate to C++ with pointers:&lt;/p&gt;
&lt;h3 id=&quot;linked-list-implementation&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#linked-list-implementation&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Linked List Implementation&lt;/h3&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// JavaScript&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;next &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// C++&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; value&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    Node&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; next&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;token function&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;int&lt;/span&gt; val&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;val&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;nullptr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;event-handling&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#event-handling&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Event Handling&lt;/h3&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// JavaScript&lt;/span&gt;
element&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Clicked!&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;language-cpp&quot;&gt;&lt;code class=&quot;language-cpp&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// C++&lt;/span&gt;
button&lt;span class=&quot;token operator&quot;&gt;-&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setOnClickListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Button&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; sender&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;cout &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Clicked!&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; std&lt;span class=&quot;token double-colon punctuation&quot;&gt;::&lt;/span&gt;endl&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;conclusion&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/cpp-pointers-js-devs/#conclusion&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Conclusion&lt;/h2&gt;
&lt;p&gt;Understanding pointers in C++ not only helped me work with the language but also deepened my understanding of how memory works in all programming languages. Even in JavaScript, concepts like ArrayBuffer and SharedArrayBuffer expose some of these lower-level memory concerns.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>My first year living in London</title>
		<link href="https://jonkuperman.com/first-year-in-london/"/>
		<updated>2023-09-18T00:00:00Z</updated>
		<id>https://jonkuperman.com/first-year-in-london/</id>
		<content type="html">&lt;p&gt;I just realized it&#39;s been over a year since Kelly and I moved to London! It&#39;s been such an incredible year I figured I should write it all down before I forget.&lt;/p&gt;
&lt;h2 id=&quot;the-move&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/first-year-in-london/#the-move&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The move&lt;/h2&gt;
&lt;p&gt;We were nervous about flying our 4-month-old puppy across the country, so we decided to fly to Michigan first to visit family and reduce the total flight time.&lt;/p&gt;
&lt;p&gt;We packed up our Florida house, put most of our things in storage and grabbed a flight to Detroit!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/packing-freya.jpeg&quot; alt=&quot;Our puppy Freya laying in our suitcase&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We went to Michigan, hung out with family, played some chess, Freya met some other dogs, and then we flew from Detroit to Paris. Strangely, the UK doesn&#39;t allow you to fly with dogs in the cabin when entering, so we flew to Paris and then paid a service to drive us from Paris to London (which means taking a car on a train and the train under the English Channel.)&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/freya-kelly-train.jpg&quot; alt=&quot;Kelly holding up Freya while we&#39;re on a train under the Channel&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;arriving-in-london&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/first-year-in-london/#arriving-in-london&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Arriving in London&lt;/h2&gt;
&lt;p&gt;We arrived, Kelly&#39;s job set us up with a temporary apartment, and we missed the worst heat wave. I was jobless in a new country and having a blast. We ate pub food, visited friends and explored the city together!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/jon-freya-fish.jpg&quot; alt=&quot;Me and my puppy eating fish and chips at a pub&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We had such an awesome first few months. Eating incredible food, wandering through all the great parks London has to offer and making a ton of friends. A few weeks in, our friends Katie and Liz came to visit! It was a great chance to do a bunch of touristy stuff.&lt;/p&gt;
&lt;p&gt;We did the British Museum, Globe Theatre, Agatha Cristie plays, and Jack the Ripper tours and ate incredible Indian food.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/liz-katie-kelly-jon.jpg&quot; alt=&quot;Liz, Katie, Kelly and I at the Sherlock Holmes museum&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We also spent an entire day in Canterbury, and it was awesome.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/canterbury.jpg&quot; alt=&quot;Gondola rides in Canterbury&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Eventually, sadly, Liz had to return to the US, but Kelly, Katie and I took the train to Edinburgh for the &lt;a href=&quot;https://www.edfringe.com/&quot;&gt;Fringe Festival&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Edinburgh is incredible. We saw shows, hiked, ate fantastic food, and drank a bunch of Scotch. It was splendid.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/family-in-edinburgh.jpg&quot; alt=&quot;Kelly and Freya and I hiking Arthur&#39;s Seat in Edinburgh&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We even took the train out to Loch Lomond and hiked and took a boat tour of the Loch. It was freezing but also beautiful.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/loch-lomond.jpg&quot; alt=&quot;Kelly and Freya and I on a boat at Loch Lomond&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/whisky.jpg&quot; alt=&quot;Giant whisky collection&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Katie went home 😢, we returned to London and did more fun things. Including a &lt;a href=&quot;https://www.moonhoneytravel.com/seven-sisters-cliffs-walk-seaford-to-eastbourne/&quot;&gt;14-mile hike&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/14-mile-hike.jpeg&quot; alt=&quot;Kelly, Freya and I hiking&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;settling-in&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/first-year-in-london/#settling-in&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Settling in&lt;/h2&gt;
&lt;p&gt;We enjoyed the end of summer. Flower markets, Sunday roasts at pubs with friends, and bus tours around the city. Late nights out drinking with friends. One weird night, I took a bunch of pictures with a red notebook (a story for another time).&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/friends-out-drinking.jpg&quot; alt=&quot;A bunch of us at a pub&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We found a permanent flat, moved in and finally started feeling settled. The first few months, while fun, I felt like I &amp;quot;missed home&amp;quot; and wanted to return to the States. I think having an apartment that was ours and a job (more on that later) really helped.&lt;/p&gt;
&lt;p&gt;We did more hikes, I started preparing to interview for a job, and we began really settling into our life in London.&lt;/p&gt;
&lt;p&gt;In October, we went to Cardiff, Wales. More hiking, more great food! They have a charming downtown area with no cars, and it was great to walk around. Our friend Josh played host and showed us all the cool spots in the city!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/josh-kelly-freya-wales.jpg&quot; alt=&quot;Josh and Kelly and Freya and me hanging out in Cardiff!&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;my-dad-visits&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/first-year-in-london/#my-dad-visits&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; My dad visits&lt;/h2&gt;
&lt;p&gt;In early November, my dad came to visit. We did a ton of great stuff. We went to metal bars, visited Edinburgh again, ate our way through the fancy markets of London, and saw a concert together! Scotland was a bit chilly at the end of fall, but we made the best of it!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/me-and-dad-edinburgh.jpg&quot; alt=&quot;Me and My dad by Edinburgh Castle&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;the-bad-times&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/first-year-in-london/#the-bad-times&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The bad times&lt;/h2&gt;
&lt;p&gt;A literal supervillain took over Kelly&#39;s company (which was tied to our visas). It was a horrible time, and he remains a despicable person. On the good side, I landed an incredible job at &lt;a href=&quot;https://www.bloomberg.com/uk&quot;&gt;Bloomberg&lt;/a&gt; that came with a visa, and Kelly was able to walk away from the madness!&lt;/p&gt;
&lt;h2 id=&quot;back-to-fun!&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/first-year-in-london/#back-to-fun!&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Back to fun!&lt;/h2&gt;
&lt;p&gt;I went to Dayton, Ohio, at the end of November. Got to see my family and spend some great quality time with them.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/dayton-trip.jpg&quot; alt=&quot;My family in Dayton&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We had a great winter. We visited the &lt;a href=&quot;https://www.rafmuseum.org.uk/london/&quot;&gt;RAF Museum&lt;/a&gt; and &lt;a href=&quot;https://bletchleypark.org.uk/&quot;&gt;Bletchley Park&lt;/a&gt;. We watched the World Cup with our friends and played in the snow.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/kelly-freya-winter.jpg&quot; alt=&quot;Kelly and Freya in the winter&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/friends-christmas.jpg&quot; alt=&quot;Our friends having Christmas together&quot; /&gt;&lt;/p&gt;
&lt;p&gt;In January, Kelly&#39;s mom visited. We ate more bangin food, went to some fancy Michelin star restaurants, saw a ballet, had high tea, and went to Winter Wonderland in Hyde Park.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/hoppers-indian-food.jpg&quot; alt=&quot;Hoppers Indian Food&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Caption: Bangin food&lt;/p&gt;
&lt;h2 id=&quot;new-beginnings&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/first-year-in-london/#new-beginnings&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; New Beginnings&lt;/h2&gt;
&lt;p&gt;In January, I started a great new job. Doing all sorts of cool infrastructure and performance things and building devtools. It&#39;s pretty much a dream come true.&lt;/p&gt;
&lt;p&gt;We went to a bunch of art exhibits and generally tried to get as much sunlight as we could during the 3 hours per day it&#39;s out in London!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/kelly-art-exhibit.jpg&quot; alt=&quot;Kelly at an art exhibit&quot; /&gt;&lt;/p&gt;
&lt;p&gt;My friend Chris visited in February. He stayed at a baller hotel, and we only had a few days together, but we made the most of it!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/chris-kelly-jon.jpg&quot; alt=&quot;Kelly and Chris and I at the London Eye&quot; /&gt;&lt;/p&gt;
&lt;p&gt;At the end of the month, Kelly and I flew back to Florida for her dad&#39;s wedding. It was great to see family and get a tiny bit of sun again!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/florida.jpg&quot; alt=&quot;Florida sunset&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Kelly and our friend Jani had a shared birthday in March! We rented out part of a pub, and all of our friends came. It was an amazing night.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/jani-kelly-birthday.jpg&quot; alt=&quot;Jani and Kelly at their shared birthday party&quot; /&gt;&lt;/p&gt;
&lt;p&gt;FWIW, Freya also had a birthday 🤣&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/freya-birthday-party.jpg&quot; alt=&quot;Freya at her birthday party&quot; /&gt;&lt;/p&gt;
&lt;p&gt;At the end of March, we took a weekend in Bath. Saw the Roman baths, toured a bunch of parks, and had more amazing food. It was great!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/bath-one.jpg&quot; alt=&quot;Houses in Bath&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/bath-two.jpg&quot; alt=&quot;The Roman Baths&quot; /&gt;&lt;/p&gt;
&lt;p&gt;We also went and saw the Pixies at the end of March! They put on such a great show.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/pixies.jpg&quot; alt=&quot;Kelly and I watching the Pixies&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;portugal&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/first-year-in-london/#portugal&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Portugal&lt;/h2&gt;
&lt;p&gt;In April, Kelly and I went to Lisbon, Portugal! I&#39;ve always wanted to go. It was warm and gorgeous, and the food was delicious, and there was music and culture everywhere. We walked all day and all night and had so much fun.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/kelly-and-i-lisbon.jpg&quot; alt=&quot;Kelly and I in the town square, Lisbon&quot; /&gt;&lt;br /&gt;
&lt;img src=&quot;https://jonkuperman.com/img/lisbon-two.jpg&quot; alt=&quot;Beautiful cathedral in Lisbon&quot; /&gt;&lt;br /&gt;
&lt;img src=&quot;https://jonkuperman.com/img/pastel-de-nata.jpg&quot; alt=&quot;Pastel de Nata&quot; /&gt;&lt;/p&gt;
&lt;p&gt;More friends visited at the end of April, including Pancakes (a new friend for Freya!)&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/siggy-pancakes-visiting.jpg&quot; alt=&quot;Siggy and Pancakes visiting us&quot; /&gt;&lt;/p&gt;
&lt;p&gt;London Spring is incredible. More hikes (white cliffs of Dover), more food, more friends and adventures!&lt;/p&gt;
&lt;h2 id=&quot;my-family-visits&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/first-year-in-london/#my-family-visits&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; My family visits&lt;/h2&gt;
&lt;p&gt;In May, my mom and sister came to visit! We did so much stuff. Fancy meals, back to Bath! We saw Stonehenge, ate the fanciest dinner of my life and took some memorable tours.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/fancy-dinner.jpg&quot; alt=&quot;Kelly and I at fancy dinner&quot; /&gt;&lt;br /&gt;
&lt;img src=&quot;https://jonkuperman.com/img/fancy-dinner-two.jpg&quot; alt=&quot;Fancy dinner with my family&quot; /&gt;&lt;br /&gt;
&lt;img src=&quot;https://jonkuperman.com/img/family-bath.jpg&quot; alt=&quot;Family in Bath together&quot; /&gt;&lt;br /&gt;
&lt;img src=&quot;https://jonkuperman.com/img/mom.jpg&quot; alt=&quot;My mom in London&quot; /&gt;&lt;br /&gt;
&lt;img src=&quot;https://jonkuperman.com/img/family-stonehenge.jpg&quot; alt=&quot;My fmaily at Stonehenge&quot; /&gt;&lt;br /&gt;
&lt;img src=&quot;https://jonkuperman.com/img/lauren-tour.jpg&quot; alt=&quot;Lauren on our night time tour&quot; /&gt;&lt;br /&gt;
&lt;img src=&quot;https://jonkuperman.com/img/lauren-fancy-dinner.jpeg&quot; alt=&quot;Lauren at our fancy dinner&quot; /&gt;&lt;/p&gt;
&lt;p&gt;In June, I got to visit NYC for work. I flew Business Class for the first time ever (life-changing) and got to see some great friends while in town! I met a bunch of my New York teammates and had a great time.&lt;/p&gt;
&lt;h2 id=&quot;helsinki&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/first-year-in-london/#helsinki&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Helsinki&lt;/h2&gt;
&lt;p&gt;Later in June, Kelly and I got to visit Helsinki for a conference. The conference was amazing, a bunch of our friends spoke. The food was great. We had such a lovely time. At the end of the week, Kelly flew to Dublin for a work retreat, and I went up north in Finland with some friends to a lakehouse we rented (what even is our lives).&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/finland-meat-pies.jpeg&quot; alt=&quot;Finland meat pies with friends&quot; /&gt;&lt;br /&gt;
&lt;img src=&quot;https://jonkuperman.com/img/finland-lake.jpeg&quot; alt=&quot;Finland lake&quot; /&gt;&lt;br /&gt;
&lt;img src=&quot;https://jonkuperman.com/img/the-perfect-lakehouse.jpeg&quot; alt=&quot;The perfect lakehouse&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;tc39-in-bergen&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/first-year-in-london/#tc39-in-bergen&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; TC39 in Bergen&lt;/h2&gt;
&lt;p&gt;In July, I was given the opportunity to join &lt;a href=&quot;https://tc39.es/&quot;&gt;TC39&lt;/a&gt;. It&#39;s been a career-long dream of mine, and it was just as cool as I thought it would be! I got to attend their plenary in Bergen, Norway.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/bergen-hotel.jpeg&quot; alt=&quot;Bergen Hotel&quot; /&gt;&lt;br /&gt;
&lt;img src=&quot;https://jonkuperman.com/img/tc39-sign.jpeg&quot; alt=&quot;TC39 sign&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;back-in-london&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/first-year-in-london/#back-in-london&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Back in London&lt;/h2&gt;
&lt;p&gt;We did a bunch more cool stuff, but I&#39;m getting tired as I type 😂&lt;/p&gt;
&lt;p&gt;Kelly and I had a 5-star meal on a fancy bus as it toured London!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/fancy-bus-dinner.jpeg&quot; alt=&quot;Kelly having cocktails on a fancy bus&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;isle-of-skye&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/first-year-in-london/#isle-of-skye&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Isle of Skye&lt;/h2&gt;
&lt;p&gt;In August, a bunch of friends came to visit! We had a few lovely days in London and then went up to the Isle of Skye in Scotland. It was rainy, freezing and stunningly beautiful.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/isle-of-skye-group-pic.jpeg&quot; alt=&quot;The group of us in front of a mountain in Skye&quot; /&gt;&lt;br /&gt;
&lt;img src=&quot;https://jonkuperman.com/img/isle-of-skye-castle.jpeg&quot; alt=&quot;A castle in Skye&quot; /&gt;&lt;br /&gt;
&lt;img src=&quot;https://jonkuperman.com/img/sunrise-in-skye.jpeg&quot; alt=&quot;A sunrise in Skye&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;kelly&#39;s-sister-visits&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/first-year-in-london/#kelly&#39;s-sister-visits&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Kelly&#39;s sister visits&lt;/h2&gt;
&lt;p&gt;Kelly&#39;s sister, Amber, came at the end of August. We saw a fantastic concert (Yeah Yeah Yeah&#39;s and The Strokes), had high tea and explored so much of London!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/yeahyeahyeahs.jpeg&quot; alt=&quot;The three of us at a concert&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/kelly-amber-high-tea.jpeg&quot; alt=&quot;Kelly and Amber having high tea&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;tpac-in-seville&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/first-year-in-london/#tpac-in-seville&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; TPAC in Seville&lt;/h2&gt;
&lt;p&gt;I also got to go to Spain! Although the trip was technically past the 1-year mark. I got to attend &lt;a href=&quot;https://www.w3.org/2023/09/TPAC/&quot;&gt;TPAC&lt;/a&gt; with two coworkers. Seville was beautiful, and I finally got to practice my Spanish!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/seville-hotel.jpeg&quot; alt=&quot;Hotel in Seville&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/first-year-in-london/#conclusion&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Conclusion&lt;/h2&gt;
&lt;p&gt;What an absolutely incredible year. I cannot wait until the next one!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>JavaScript format number</title>
		<link href="https://jonkuperman.com/javascript-format-number/"/>
		<updated>2022-01-04T00:00:00Z</updated>
		<id>https://jonkuperman.com/javascript-format-number/</id>
		<content type="html">&lt;p&gt;Using JavaScript to format numbers is a very common task. The cool thing is, there are a lot of new built-in methods that make JavaScript format number a lot easier.&lt;/p&gt;
&lt;p&gt;Let&#39;s take a look at three common strategies.&lt;/p&gt;
&lt;h2 id=&quot;format-numbers-with-regular-expressions&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/javascript-format-number/#format-numbers-with-regular-expressions&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Format numbers with Regular expressions&lt;/h2&gt;
&lt;p&gt;The first thing we can try is using &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions&quot;&gt;Regular Expressions&lt;/a&gt;. We can take any number, cast it to a string and then use the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace&quot;&gt;replace()&lt;/a&gt; method to add add a comma or decmial after every group of 3 numbers.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; number &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000000000000&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;number&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;(.)(?=(&#92;d{3})+$)&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-flags&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;$1,&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This returns &lt;code&gt;&#39;1,000,000,000,000&#39;&lt;/code&gt;. And if you want decimals instead, change the last symbol to a period like so:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; number &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000000000000&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;number&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;(.)(?=(&#92;d{3})+$)&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-flags&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;$1.&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This returns &lt;code&gt;&#39;1.000.000.000.000&#39;&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;javascript-format-number-with-tolocalestring&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/javascript-format-number/#javascript-format-number-with-tolocalestring&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; JavaScript format number with toLocaleString&lt;/h2&gt;
&lt;p&gt;A better approach would be to use the built-in &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString&quot;&gt;toLocaleString&lt;/a&gt; which returns language sensitive representations of numbers. We can simply:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; number &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000000000000&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; number&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toLocaleString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will print &lt;code&gt;&#39;1.000.000.000.000&#39;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;What&#39;s cool about this approach is, if you are using JavaScript to format money, you can pass in the user&#39;s country code and it will adapt. For example:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; number &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000000000000&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; number&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toLocaleString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;ja-JP&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;currency&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;currency&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;JPY&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will print &lt;code&gt;&#39;￥1,000,000,000,000&#39;&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;format-javascript-numbers-with-numberformat&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/javascript-format-number/#format-javascript-numbers-with-numberformat&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Format JavaScript numbers with NumberFormat&lt;/h2&gt;
&lt;p&gt;While &lt;code&gt;toLocaleString&lt;/code&gt; is super clean and easy, it will slow down significantly when passing it large numbers. From &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString&quot;&gt;MDN&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;When formatting large numbers of numbers, it is better to create a Intl.NumberFormat object and use the function provided by its format property.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So, if we have a large number we need to format, we can use &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat&quot;&gt;NumberFormat&lt;/a&gt; instead.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; number &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000000000000&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Intl&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;NumberFormat&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;number&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will return &lt;code&gt;&#39;1,000,000,000,000&#39;&lt;/code&gt;. The API is a little bit harder to use but you can still pass in all the country codes and formatting options that we used with &lt;code&gt;toLocaleString&lt;/code&gt;. For example:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; number &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000000000000&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Intl&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;NumberFormat&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;ja-JP&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;currency&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;currency&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;JPY&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;number&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which will return &lt;code&gt;&#39;￥1,000,000,000,000&#39;&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/javascript-format-number/#conclusion&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Conclusion&lt;/h2&gt;
&lt;p&gt;Formatting JavaScript numbers used to be really hard. You had to write your own Regular Expression and cast your number to a string to use it. Now we have 2 great browser APIs for this task and they have a ton of flexibility.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Musings on Developer Relations</title>
		<link href="https://jonkuperman.com/musings-on-developer-relations/"/>
		<updated>2021-12-09T00:00:00Z</updated>
		<id>https://jonkuperman.com/musings-on-developer-relations/</id>
		<content type="html">&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/musings-developer-relations.png&quot; alt=&quot;Banner image&quot; /&gt;&lt;/p&gt;
&lt;p&gt;I&#39;ve been doing Developer Relations for about four months now. It&#39;s been a lot of fun! I can already tell I&#39;ve been learning and growing my career in some new ways. I&#39;ve also been able to see how DevRel can help a company.&lt;/p&gt;
&lt;p&gt;I had a lot of misunderstandings about DevRel, and its role at a company. I want to explore those and speculate on some growth areas I see coming to the field.&lt;/p&gt;
&lt;h2 id=&quot;devrel-is-all-selfies-and-conferences-right&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/musings-on-developer-relations/#devrel-is-all-selfies-and-conferences-right&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; DevRel is all selfies and conferences, right?&lt;/h2&gt;
&lt;p&gt;I have to admit, when Developer Relations started getting popular, I had a lot of FOMO. I kept seeing people on Twitter, jet-setting around the world and drinking fancy drinks in tropical locations. It looked too good to be true!&lt;/p&gt;
&lt;p&gt;Here are some things I didn&#39;t understand about DevRel but have learned over the last four months:&lt;/p&gt;
&lt;h3 id=&quot;1.-conference-talks-are-only-a-tiny-part-of-the-job&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/musings-on-developer-relations/#1.-conference-talks-are-only-a-tiny-part-of-the-job&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 1. Conference talks are only a tiny part of the job&lt;/h3&gt;
&lt;p&gt;Conference involvement must vary heavily by company. Regardless, your company DevRel strategy almost certainly involves documentation, blogging, social media engagement, community building, making demos, starter projects, internal advocacy (mentioned later) and more.&lt;/p&gt;
&lt;p&gt;I would wager that most DevRel conference talks you see are the final step of a vast engineering/marketing push. That person probably:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Embedded with the team as they built the project&lt;/li&gt;
&lt;li&gt;Tested it and gave feedback&lt;/li&gt;
&lt;li&gt;Organized community feedback sessions&lt;/li&gt;
&lt;li&gt;Wrote official docs for the feature before launch&lt;/li&gt;
&lt;li&gt;Wrote a blog post after launch&lt;/li&gt;
&lt;li&gt;Made some demos to help bring the docs to life&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;And only after all of that, packaged it up and submitted it as a talk!&lt;/p&gt;
&lt;h3 id=&quot;2.-it&#39;s-difficult-work-that-requires-your-authentic-self&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/musings-on-developer-relations/#2.-it&#39;s-difficult-work-that-requires-your-authentic-self&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 2. It&#39;s difficult work that requires your authentic self&lt;/h3&gt;
&lt;p&gt;I spent my entire career as an engineer. It&#39;s challenging work. It&#39;s fun, rewarding and high-paying work, but it is difficult!&lt;/p&gt;
&lt;p&gt;Developer Relations uses a very different set of muscles. On the one hand, I don&#39;t end up with as many &amp;quot;deep work&amp;quot; tasks with tight deadlines. I still code a lot, but since I&#39;m building demos and libraries around services our engineering teams made, it&#39;s a very different experience.&lt;/p&gt;
&lt;p&gt;On the other hand, as an engineer, I could deep-dive into my particular product or part of the stack. It was pretty easy to become familiar and productive, and I could focus on my little kingdom.&lt;/p&gt;
&lt;p&gt;DevRel is very different. The easiest way to describe it is that engineering requires a depth of knowledge, whereas Developer Relations requires breadth.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Engineering requires a depth of knowledge, whereas Developer Relations requires breadth.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id=&quot;3.-content-switching-between-marketing-and-engineering-is-hard&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/musings-on-developer-relations/#3.-content-switching-between-marketing-and-engineering-is-hard&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 3. Content switching between marketing and engineering is hard&lt;/h3&gt;
&lt;p&gt;Some organizations house Developer Relations under engineering, some under marketing. I feel like it fits better under engineering, but there is a fair amount of marketing involved. As an engineer, I had a tough time context switching between projects or between meetings and coding.&lt;/p&gt;
&lt;p&gt;Switching from an engineering hat to a marketing hat is difficult for me. I&#39;ll be late for a meeting because I&#39;m stuck and desperately trying to get my code to work. Then I&#39;ll hop on the call and fumble with my words as I try to explain why I think an event is worth attending. It feels like I need at least five minutes dedicated to switching my thought process.&lt;/p&gt;
&lt;h3 id=&quot;4.-internal-advocacy-is-as-important-as-external&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/musings-on-developer-relations/#4.-internal-advocacy-is-as-important-as-external&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 4. Internal advocacy is as important as external&lt;/h3&gt;
&lt;p&gt;To be honest, I didn&#39;t even know internal dev advocacy was a thing until we hired our first person for the role! Three months in, I don&#39;t know how we lived without him.&lt;/p&gt;
&lt;p&gt;Imagine having folks in your company intimately familiar with your APIs, tools, issues and upcoming features. You go to build a new product or feature, and they embed with you, helping you get up to speed on all the internal systems.&lt;/p&gt;
&lt;p&gt;Seriously, think about this. Every job I&#39;ve ever had, I&#39;ve complained about wanting to use open-source tools instead of these confusing internal ones?&lt;/p&gt;
&lt;p&gt;Going back over my career, there isn&#39;t a single job I&#39;ve had where I wouldn&#39;t have significantly benefitted from having an internal dev advocate helping me ramp up on our authentication, serverless platform, storage APIs, etc.&lt;/p&gt;
&lt;h2 id=&quot;my-predictions-for-devrel-in-2022-and-beyond&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/musings-on-developer-relations/#my-predictions-for-devrel-in-2022-and-beyond&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; My predictions for DevRel in 2022 and beyond&lt;/h2&gt;
&lt;h3 id=&quot;1.-internal-advocacy-is-going-to-blow-up&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/musings-on-developer-relations/#1.-internal-advocacy-is-going-to-blow-up&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 1. Internal advocacy is going to blow up&lt;/h3&gt;
&lt;p&gt;I think this is going to be the next big thing. Teams of folks who are intimately familiar with your tooling and APIs. Available for office hours or embedding with your team. They know how to get started and who to talk to. They help write internal documentation, surface pain points to infra teams and make feature teams more productive.&lt;/p&gt;
&lt;p&gt;Does your company have internal developer advocacy? I&#39;d love to hear about it!&lt;/p&gt;
&lt;h3 id=&quot;2.-people-will-start-moving-into-leadership-roles-from-devrel&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/musings-on-developer-relations/#2.-people-will-start-moving-into-leadership-roles-from-devrel&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 2. People will start moving into leadership roles from DevRel&lt;/h3&gt;
&lt;p&gt;I also suspect that we&#39;ll see more developer relations folks making it into leadership roles. The role gives you a great breadth of experience, and you get to know the engineering org intimately, but you also have a great understanding of what the sales and marketing teams are dealing with.&lt;/p&gt;
&lt;p&gt;Typically I&#39;ve seen folks from engineering or product promoted into leadership. This works great, but they often have to work hard ramping up on whichever org they weren&#39;t previously in. DevRel folks often know everyone at the company already, and I think this is super valuable.&lt;/p&gt;
&lt;p&gt;What do you all think? Am I way off base with my predictions? Does your company have any developer relations people?&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>GitHub find which PR deleted a file</title>
		<link href="https://jonkuperman.com/github-find-deleted-file/"/>
		<updated>2021-12-07T00:00:00Z</updated>
		<id>https://jonkuperman.com/github-find-deleted-file/</id>
		<content type="html">&lt;p&gt;Today at work I noticed a file had been deleted in our repository. I wasn&#39;t sure who deleted it or why it was deleted. I really wanted to figure out which GitHub PR removed the file so I could get some context!&lt;/p&gt;
&lt;h2 id=&quot;an-example&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/github-find-deleted-file/#an-example&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; An example&lt;/h2&gt;
&lt;p&gt;To test this out, without revealing any of my work code, I created a new file named &lt;code&gt;foo&lt;/code&gt; in &lt;a href=&quot;https://github.com/jkup/jonkuperman.com&quot;&gt;this repo&lt;/a&gt;. Then I made a PR deleting that file and merged it into main.&lt;/p&gt;
&lt;h2 id=&quot;step-1:-find-the-commit-that-deleted-the-file&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/github-find-deleted-file/#step-1:-find-the-commit-that-deleted-the-file&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Step 1: Find the commit that deleted the file&lt;/h2&gt;
&lt;p&gt;This took a bit of searching, but I was able to find &lt;a href=&quot;https://stackoverflow.com/questions/6839398/find-when-a-file-was-deleted-in-git&quot;&gt;on Stack Overflow&lt;/a&gt; a git command that will show you the full history of a file, even if it has been deleted.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; log --full-history  -- &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;file path&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So, for my &lt;code&gt;foo&lt;/code&gt; file, I typed in:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; log --full-history  -- foo&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And got back:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;commit 63ca48a2cc63196df5428ddb0c09cda3002a8da3 &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;HEAD -&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; master, origin/master, origin/HEAD&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
Merge: b7f2ad2 c48771f
Author: Jon Kuperman &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;jon.kuperman@nicetry.com&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
Date:   Tue Dec &lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;13&lt;/span&gt;:38:00 &lt;span class=&quot;token number&quot;&gt;2021&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-0500&lt;/span&gt;

    Merge pull request &lt;span class=&quot;token comment&quot;&gt;#14 from jkup/sample-pr&lt;/span&gt;

    Delete foo &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;you found me&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

commit c48771fd5dadf28d456be9202079dd95a0cff47a &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;origin/sample-pr, sample-pr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
Author: Jon Kuperman &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;jon.kuperman@nicetry.com&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
Date:   Tue Dec &lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;13&lt;/span&gt;:37:39 &lt;span class=&quot;token number&quot;&gt;2021&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-0500&lt;/span&gt;

    Delete foo &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;you found me&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

commit b7f2ad23d2d19fb7d589f993a87946141fb9cbae
Author: Jon Kuperman &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;jon.kuperman@nicetry.com&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
Date:   Tue Dec &lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;13&lt;/span&gt;:37:22 &lt;span class=&quot;token number&quot;&gt;2021&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-0500&lt;/span&gt;

    &lt;span class=&quot;token function&quot;&gt;add&lt;/span&gt; foo&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;step-2:-grab-the-git-sha&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/github-find-deleted-file/#step-2:-grab-the-git-sha&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Step 2: Grab the git SHA&lt;/h2&gt;
&lt;p&gt;Now I can see the entire history of the file. I want to see when it was deleted and that means I want to see the very last commit that touched it. Therefore, I&#39;ll copy the SHA at the top of the output, &lt;code&gt;63ca48a2cc63196df5428ddb0c09cda3002a8da3&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;step-3:-a-cool-github-url&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/github-find-deleted-file/#step-3:-a-cool-github-url&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Step 3: A cool GitHub URL&lt;/h2&gt;
&lt;p&gt;The final step is figuring out what PR contained the offending commit. For that we can use this neat GitHub URL:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;github.com/username/project/commit/SHA&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;For our example we have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;username: jkup&lt;/li&gt;
&lt;li&gt;projects: &lt;a href=&quot;http://jonkuperman.com/&quot;&gt;jonkuperman.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;sha: 63ca48a2cc63196df5428ddb0c09cda3002a8da3&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So our final URL is:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/jkup/jonkuperman.com/commit/63ca48a2cc63196df5428ddb0c09cda3002a8da3&quot;&gt;https://github.com/jkup/jonkuperman.com/commit/63ca48a2cc63196df5428ddb0c09cda3002a8da3&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;step-4:-click-the-pr&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/github-find-deleted-file/#step-4:-click-the-pr&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Step 4: Click the PR&lt;/h2&gt;
&lt;p&gt;The last bit is just clicking through the GitHub UI to go from commit to PR. If you look at the top of the link above, you&#39;ll see the PR in parenthesis. In this case it&#39;s #14. Click on that and it will take you to the offending PR!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/github-find-deleted-file.png&quot; alt=&quot;GitHub find PR for deleted file&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And there it is, the PR that deleted &lt;code&gt;foo&lt;/code&gt; from my repo: &lt;a href=&quot;https://github.com/jkup/jonkuperman.com/pull/14&quot;&gt;https://github.com/jkup/jonkuperman.com/pull/14&lt;/a&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Chasing accurate analytics: Server-side vs client-side analytics</title>
		<link href="https://jonkuperman.com/chasing-accurate-analytics-server-side-analytics-vs-client-side/"/>
		<updated>2021-12-06T00:00:00Z</updated>
		<id>https://jonkuperman.com/chasing-accurate-analytics-server-side-analytics-vs-client-side/</id>
		<content type="html">&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/chasing-accurate-analytics.png&quot; alt=&quot;Blog post banner&quot; /&gt;&lt;/p&gt;
&lt;p&gt;I&#39;ve been thinking about server-side analytics vs client-side. The other day I Tweeted:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/jkup/status/1465780792940978182&quot;&gt;https://twitter.com/jkup/status/1465780792940978182&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I got a lot of different responses. Some folks prefer server-side and some prefer client-side. Most are unhappy with both! Some folks are upset that ad-blockers make it difficult to get good data. Other folks are finding clever ways of getting around ad-blockers. There is a lot to unpack here!&lt;/p&gt;
&lt;h2 id=&quot;what&#39;s-the-problem&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chasing-accurate-analytics-server-side-analytics-vs-client-side/#what&#39;s-the-problem&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What&#39;s the problem?&lt;/h2&gt;
&lt;p&gt;For those that don&#39;t know, typical analytics tools like &lt;a href=&quot;https://analytics.google.com/analytics/web/&quot;&gt;Google Analytics&lt;/a&gt; work by asking website owners to add a JavaScript file to their website. That JavaScript file often fetches more files, adds a &lt;a href=&quot;https://www.digitalmarketer.com/blog/what-is-tracking-pixel/&quot;&gt;tracking pixel&lt;/a&gt; and starts batching and sending updates to your analytics dashboard as users browse your site.&lt;/p&gt;
&lt;p&gt;The problem is that tools like Google Analytics is that they rely on JavaScript being enabled in the user&#39;s browser. And with the rise of ad-blockers, more and more users are disabling JavaScript. In fact, over 26% of internet users now use ad-blockers (although this number is likely higher for people that only use desktop computers).&lt;/p&gt;
&lt;p&gt;This means that if you&#39;re relying on JavaScript-based analytics to figure out how much traffic your website is getting, you&#39;re likely going to get bad information.&lt;/p&gt;
&lt;h2 id=&quot;server-side-analytics&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chasing-accurate-analytics-server-side-analytics-vs-client-side/#server-side-analytics&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Server-side analytics&lt;/h2&gt;
&lt;p&gt;Server-side analytics software first came out in the mid-2000s and operate by making an HTTP request to the website just like a normal web browser would. This means that it can update your analytics dashboard regardless of whether JavaScript is enabled or not.&lt;/p&gt;
&lt;p&gt;Some people suggest that server-side analytics are inherently better than client-side analytics because they&#39;re &amp;quot;less invasive&amp;quot; (client-side analytics require JavaScript to run). This is a myth.&lt;/p&gt;
&lt;p&gt;Server-side analytics tools gather as much personal information as their client-side counterparts do. The only difference between the two is that because they&#39;re not dependent on JavaScript, the amount of information they can gather is greatly reduced (but usually isn&#39;t eliminated entirely).&lt;/p&gt;
&lt;h2 id=&quot;client-side-analytics&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chasing-accurate-analytics-server-side-analytics-vs-client-side/#client-side-analytics&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Client-side analytics&lt;/h2&gt;
&lt;p&gt;Client-side analytics, on the other hand, get you access to a ton of information. Services like Google Analytics can capture exactly what users are doing on your website when they&#39;re doing it, and if they do it multiple times.&lt;/p&gt;
&lt;p&gt;The only downside to using Google Analytics is that, as we&#39;ve established, a lot of users have ad-blockers enabled which means you&#39;re not getting an accurate count of how many people are actually visiting your website.&lt;/p&gt;
&lt;h2 id=&quot;client-side-vs-server-side-comparison&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chasing-accurate-analytics-server-side-analytics-vs-client-side/#client-side-vs-server-side-comparison&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Client-side vs Server-side comparison&lt;/h2&gt;
&lt;p&gt;Let&#39;s look at a few different metrics and compare the two options.&lt;/p&gt;
&lt;h2 id=&quot;accuracy&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chasing-accurate-analytics-server-side-analytics-vs-client-side/#accuracy&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Accuracy&lt;/h2&gt;
&lt;p&gt;As we already covered, client-side analytics can be inaccurate because 100% of users using an ad-blocker or with JavaScript disabled will not be logged. This means, on average, 26% of your visitors will not show up in your analytics dashboard. If you have a website that attracts more technical people (such as this blog!) it could be a lot higher.&lt;/p&gt;
&lt;p&gt;On the other hand, server-side analytics suffer from the opposite problem. User&#39;s with ad-blockers or JS disabled will show up in the dashboard, but so will a ton of bots and spam content.&lt;/p&gt;
&lt;p&gt;This discrepancy can be massive. For example, this month on my personal blog Google Analytics (client-side) shows &lt;strong&gt;1200 unique visitors&lt;/strong&gt; but my Cloudflare Analytics (server-side) shows &lt;strong&gt;7000 unique visitors&lt;/strong&gt;. As much as I&#39;d love Cloudflare to be right, I suspect the truth is somewhere in between.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Winner&lt;/strong&gt;: Client-Side (Really the bots are winning)&lt;/p&gt;
&lt;h2 id=&quot;ease-of-use&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chasing-accurate-analytics-server-side-analytics-vs-client-side/#ease-of-use&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Ease of use&lt;/h2&gt;
&lt;p&gt;It used to be quite difficult to set up your own server-side analytics platform. One of the biggest selling points for Google Analytics was that you just had to copy and paste a small JavaScript snippet into your HTML. These days, website hosts like &lt;a href=&quot;https://www.netlify.com/products/analytics/&quot;&gt;Netlify&lt;/a&gt; and &lt;a href=&quot;https://www.cloudflare.com/analytics/&quot;&gt;Cloudflare&lt;/a&gt; offer analytics alongside their hosting platform. If you are using one of these platforms to host your website, analytics are just a click away.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Winner&lt;/strong&gt;: tie&lt;/p&gt;
&lt;h2 id=&quot;performance&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chasing-accurate-analytics-server-side-analytics-vs-client-side/#performance&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Performance&lt;/h2&gt;
&lt;p&gt;Another point worth mentioning is that client-side analytics require JS to be sent on each request, slowing your website down. In some cases, this slow down can be negligible but it&#39;s worth mentioning that server-side analytics get you some tracking without adding any bloat to your website.&lt;/p&gt;
&lt;p&gt;Website bundles are getting bigger every year. In fact, the average time it takes to fully render a web page is 1.5 seconds which means server-side analytics are going to be faster for your users even if you don&#39;t care about server costs.&lt;/p&gt;
&lt;p&gt;If speed is a big issue for you, server-side analytics might be a better option to help improve your bounce rate and conversion.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Winner&lt;/strong&gt;: Server-side&lt;/p&gt;
&lt;h2 id=&quot;what-is-a-visitor-anyway&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chasing-accurate-analytics-server-side-analytics-vs-client-side/#what-is-a-visitor-anyway&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What is a visitor, anyway?&lt;/h2&gt;
&lt;p&gt;There are a lot of bots on the web. Like, a lot. This &lt;a href=&quot;https://www.imperva.com/blog/bot-traffic-report-2013/?utm_campaign=Incapsula-moved&quot;&gt;report&lt;/a&gt; from Imperva claims that 61.5% of all web traffic comes from bots.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Compared to the previous report from 2012, we see a 21% growth in total bot traffic, which now represents 61.5% of website visitors.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This makes me feel like the client-side analytics numbers are closer to the truth. They might be a bit low due to ad-blockers, but server-side analytics numbers are very high because of bot traffic.&lt;/p&gt;
&lt;h2 id=&quot;what-are-these-bots-doing&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chasing-accurate-analytics-server-side-analytics-vs-client-side/#what-are-these-bots-doing&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What are these bots doing?&lt;/h2&gt;
&lt;p&gt;The most common types of web traffic bots are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;search engine crawlers (spiders and worms)&lt;/li&gt;
&lt;li&gt;content scrapers&lt;/li&gt;
&lt;li&gt;comment spammers&lt;/li&gt;
&lt;li&gt;sign-up bots&lt;/li&gt;
&lt;li&gt;malware bots&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These bots are all looking for different things. Crawlers and scrapers are looking for content to copy or steal, comment spammers are trying to add links to their websites, sign-up bots are trying to create fake accounts, and malware bots are trying to infect your website.&lt;/p&gt;
&lt;h2 id=&quot;client-side-server-side-analytics&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chasing-accurate-analytics-server-side-analytics-vs-client-side/#client-side-server-side-analytics&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Client-side server-side analytics&lt;/h2&gt;
&lt;p&gt;Or should it be server-side client-side analytics? Anyway if you&#39;re up for it you can host your own Google Analytics instance and pipe your server-side traffic to it. This means you don&#39;t bloat your website with extra client-side JavaScript but you still get the nice Google dashboard!&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/cramforce/status/1465800579649662980&quot;&gt;https://twitter.com/cramforce/status/1465800579649662980&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;getting-tricky&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chasing-accurate-analytics-server-side-analytics-vs-client-side/#getting-tricky&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Getting tricky&lt;/h2&gt;
&lt;p&gt;One final option is to be a little tricky. Ad-blockers work by maintaining a list of common ads and tracking endpoints and then blocking all requests to those endpoints. Check out this &lt;a href=&quot;https://easylist.to/easylist/easylist.txt&quot;&gt;massive list&lt;/a&gt; of blocked endpoints and filenames.&lt;/p&gt;
&lt;p&gt;These lists will have all the Google Analytics URLs blocked by default. If you really want to get around this, you can proxy all of your analytics requests through an innocent-looking endpoint. For example, you could use a service like &lt;a href=&quot;https://plausible.io/&quot;&gt;Plausible&lt;/a&gt; to establish client-side analytics at a custom endpoint that these lists will not block.&lt;/p&gt;
&lt;p&gt;You could make an argument that this isn&#39;t super ethical. But I&#39;m not sure it&#39;s more/less ethical than using a server-side analytics service that tracks users regardless of whether or not they have an ad-blocker or JavaScript disabled.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/t3dotgg/status/1465787631367716868&quot;&gt;https://twitter.com/t3dotgg/status/1465787631367716868&lt;/a&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Human Partner: How AI and Assistive Technology is Making Humans More Productive</title>
		<link href="https://jonkuperman.com/technology-makes-humans-more-productive/"/>
		<updated>2021-11-29T00:00:00Z</updated>
		<id>https://jonkuperman.com/technology-makes-humans-more-productive/</id>
		<content type="html">&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/robot.jpg&quot; alt=&quot;Robot from Terminator&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Humans fear being replaced by technology. Although it has happened with switchboard and elevator operators, bowling alley pin boys, and data entry people, it&#39;s more common that technology assists employees instead of replacing them. Let&#39;s look at some technology getting significant investments and how I see it helping workers instead of replacing them.&lt;/p&gt;
&lt;p&gt;We hear new technology will be the death of us and that we&#39;ll soon all be unemployed. This is a misconception. In reality, innovation in AI and assistive technology is making humans more productive than ever before.&lt;/p&gt;
&lt;h3 id=&quot;a-history-of-job-replacing-technology&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/technology-makes-humans-more-productive/#a-history-of-job-replacing-technology&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; A history of job replacing technology&lt;/h3&gt;
&lt;p&gt;Although I feel strongly that modern technology advancements will assist current workers, I would be remiss if I didn&#39;t mention jobs that have already been replaced by technology in the past.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/pinboys.jpg&quot; alt=&quot;Pin boys setting up pins in the 1950s&quot; /&gt;&lt;/p&gt;
&lt;p&gt;A few jobs that have been entirely replaced by technology include :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Switchboard operators (first half of the 20th century)&lt;/li&gt;
&lt;li&gt;Elevator operators (1950s-1970s)&lt;/li&gt;
&lt;li&gt;Bowling alley pin boys (1930s–1970s)&lt;/li&gt;
&lt;li&gt;Data entry clerks (1990s and on).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are many more jobs that have been replaced by technology. These are the first ones that came to mind, and they all seem apparent when you think about them.&lt;/p&gt;
&lt;p&gt;Before I get too far down the &amp;quot;technology will not replace jobs&amp;quot; road, I wanted to acknowledge that it indeed has happened before, and that&#39;s a worthwhile conversation to have!&lt;/p&gt;
&lt;h3 id=&quot;example-1-self-driving-cars&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/technology-makes-humans-more-productive/#example-1-self-driving-cars&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Example 1 - self-driving cars&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/self-driving-car.png&quot; alt=&quot;Futuristic car&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Self-driving car technology first debuted in 1925, but it is truly starting to become practical for everyday use. Some people argue that Leonardo da Vinci debuted the first self-driving car&lt;a href=&quot;https://www.tomorrowsworldtoday.com/2021/08/09/history-of-autonomous-cars/&quot;&gt; in the 1500s&lt;/a&gt;, but that&#39;s a story for another time.&lt;/p&gt;
&lt;p&gt;The technology in self-driving cars has come a long way since we showcased the first models publicly, and it&#39;s incredible how much they&#39;ve improved!&lt;/p&gt;
&lt;p&gt;Some of the benefits of self-driving cars are :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Fewer accidents - In 2015, there were over five million car accidents in the United States alone. These crashes resulted in 35,0902 injuries and killed an estimated two-hundred thirty-six thousand people!&lt;/li&gt;
&lt;li&gt;Increased productivity - I think most of us would agree that driving isn&#39;t exactly our favorite activity.&lt;/li&gt;
&lt;li&gt;Traffic efficiency - Self-driving cars can drive more efficiently than humans, resulting in significant time savings for commuters.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When they first debuted, we were promised fully autonomous vehicles being on the streets by the early 2000s. As with most technology estimates, it wasn&#39;t entirely accurate.&lt;/p&gt;
&lt;p&gt;Flash forward to the end of 2021, and we are still &amp;quot;just a few years away&amp;quot; from fully autonomous vehicles. In the meantime, we&#39;ve seen the rise of backup cameras, lane assist, intelligent cruise control, remote start, and so many more technological advancements.&lt;/p&gt;
&lt;p&gt;I don&#39;t care if we ever get fully self-driving cars. I love all the safety advancements we&#39;ve already seen, and hope driving becomes safe and safer each year.&lt;/p&gt;
&lt;h3 id=&quot;example-2-copywriting-ai&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/technology-makes-humans-more-productive/#example-2-copywriting-ai&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Example 2 - Copywriting AI&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/jarvis.jpeg&quot; alt=&quot;Jarvis logo&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The next thing I&#39;d like to look at is intelligent copywriting tools like&lt;a href=&quot;https://www.jarvis.ai/&quot;&gt; Jarvis&lt;/a&gt; and&lt;a href=&quot;https://www.copy.ai/&quot;&gt; CopyAI&lt;/a&gt;. These tools sell themselves as giving marketers the ability to create content on their own, which is excellent if you don&#39;t have a copywriter or there are last-minute deadlines!&lt;/p&gt;
&lt;p&gt;The benefits of intelligent copywriting tools are :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Increased productivity - A human writer can produce about 275 words per hour. With some artificial intelligence writers, that number jumps up to over 1000+ words.&lt;/li&gt;
&lt;li&gt;Cost-effective - For some businesses, hiring a copywriter can be too costly to justify. Intelligent copywriting tools are cheap and give you the benefits of having an in-house writer without actually needing one!&lt;/li&gt;
&lt;li&gt;Automating repetitive tasks - There is a lot of writing involved in running a business. If these tools can improve even 20% of it, that could save a ton of time!&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Again, these tools are billed as being able to replace human content writers entirely. But I feel like that isn&#39;t why they are helpful and shouldn&#39;t be the end goal.&lt;/p&gt;
&lt;p&gt;The best part about using automatic copywriting tools is using them alongside a human writer to help with research, writer&#39;s block and turning ideas into content.&lt;/p&gt;
&lt;h4 id=&quot;using-copywriting-ai-to-speed-up-research&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/technology-makes-humans-more-productive/#using-copywriting-ai-to-speed-up-research&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Using copywriting AI to speed up research&lt;/h4&gt;
&lt;p&gt;One of my favorite uses for these tools is saving me the few clicks it takes to search for something on Google. For example, I can type &amp;quot;The first automobile was created in &amp;quot; and then hit the &amp;quot;generate content&amp;quot; button, and it will fill in:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The first automobile was created in 1886 by German inventor Karl Benz.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I can also type &amp;quot;The most popular Content Management Systems in 2021 are &amp;quot; and hit the&amp;quot;generate content&amp;quot; button, and it will fill in:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The most popular Content Management Systems in 2021 are WordPress, Drupal and Squarespace.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I use this all the time while writing blog posts. It allows me to stay in the zone, focused on my text editor and lean on Jarvis or CopyAI to fill in bits of data.&lt;/p&gt;
&lt;h4 id=&quot;using-copywriting-ai-to-manage-writer&#39;s-block&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/technology-makes-humans-more-productive/#using-copywriting-ai-to-manage-writer&#39;s-block&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Using copywriting AI to manage writer&#39;s block&lt;/h4&gt;
&lt;p&gt;I get excited about blog posts all the time. I often use these tools to add a few sentences or paragraphs if I get stuck somewhere along the lines. It gives me the boost I need to keep pushing forward! I&#39;ll quickly bust out a fun title and an intro paragraph, but somewhere along the line, I get stuck.&lt;/p&gt;
&lt;p&gt;Cards on the table I delete about 70% of the generated paragraphs and spend a decent amount of time reworking the content I do keep. Still, anything that helps me get over writer&#39;s block and back to writing I consider a win!&lt;/p&gt;
&lt;h4 id=&quot;using-copywriting-ai-to-generate-ideas&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/technology-makes-humans-more-productive/#using-copywriting-ai-to-generate-ideas&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Using copywriting AI to generate ideas&lt;/h4&gt;
&lt;p&gt;Finally, one of my favorite ways I like using these tools is as an idea generator. Suppose you&#39;re working on a project with multiple people. In that case, it&#39;s nice to have the first few sentences written out for everyone to get caught up and then work together on refining that paragraph or sentence into something useful.&lt;/p&gt;
&lt;p&gt;For example, I&#39;ll type a blog post idea that I&#39;m not super fond of into Jarvis, and it will spit out eight similar post ideas. Usually, one of them is exciting enough to get me writing!&lt;/p&gt;
&lt;p&gt;I also love asking the AI to weigh in on an opinion piece. For example, while working on this post, I typed in, &amp;quot;People are afraid that artificial intelligence will take over jobs and make workers obsolete.&amp;quot; and let it run! It came back with:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;People are afraid that artificial intelligence will take over jobs and make workers obsolete.&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;
Humans have been afraid of new technology for decades. In 1870, the Luddites destroyed weaving machines that they feared would put them out of work.&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;
In reality, these advances made humans more productive and increased the demand for their labor.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It looks like the robots don&#39;t want you to fear them, which is just what they would want you to think if they were up to something!&lt;/p&gt;
&lt;h3 id=&quot;technology-replaces-some-jobs-improves-others.&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/technology-makes-humans-more-productive/#technology-replaces-some-jobs-improves-others.&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Technology replaces some jobs, improves others.&lt;/h3&gt;
&lt;p&gt;In the end, I think people are half right when they fear technology replacing workers at their jobs. There are specific jobs that no longer exist due to technological improvements. Some positions may be replaced soon, like bookkeepers, proofreaders and market researchers. There are also a lot of jobs that will continue to be done by people, but technology will allow them to do those jobs more efficiently.&lt;/p&gt;
&lt;h3 id=&quot;i-wish-it-didn&#39;t-matter.&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/technology-makes-humans-more-productive/#i-wish-it-didn&#39;t-matter.&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; I wish it didn&#39;t matter.&lt;/h3&gt;
&lt;p&gt;We&#39;ll have to square with what to do with a society where we can automate a larger and larger percent of work. Ideally, we&#39;d all find ourselves with way more free time and autonomy, but, somehow, we&#39;re busier than ever before!&lt;/p&gt;
&lt;p&gt;I think it&#39;s important to remember that technology alone isn&#39;t enough to fix human issues. This is a tech post, not a political post, so I&#39;ll leave it for now, but as we can automate more and more tasks, we should try not to take each win as an opportunity to require more and more output from workers.&lt;/p&gt;
&lt;p&gt;If technology is supposed to make our lives easier and it keeps advancing. Why are we still working so much? After reading some articles on&lt;a href=&quot;https://ourworldindata.org/working-more-than-ever&quot;&gt; Our World in Data&lt;/a&gt;, it looks like, while we are still working a lot, we may be heading in the right direction year over year!&lt;/p&gt;
&lt;p&gt;Look at this graph on the numbers of hours worked per year.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/annual-working-hours-per-worker.png&quot; alt=&quot;Graph of annual working hours per year by country&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And this one on the number of days off per year.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/days-off-from-work-vacations-holidays.png&quot; alt=&quot;Graph of annual vacation days by year by country&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;conclusion&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/technology-makes-humans-more-productive/#conclusion&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Conclusion&lt;/h3&gt;
&lt;p&gt;The main takeaway of this post is to focus less on the distant possibility of technology replacing humans and start looking forward to the frequent advancements of technology as assistive technology.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>A Content Security Policy for Google Analytics</title>
		<link href="https://jonkuperman.com/google-analytics-csp/"/>
		<updated>2021-11-27T00:00:00Z</updated>
		<id>https://jonkuperman.com/google-analytics-csp/</id>
		<content type="html">&lt;p&gt;So you want to add Google Analytics to a website that has a &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP&quot;&gt;Content Security Policy&lt;/a&gt;? Well you are in for a treat!&lt;/p&gt;
&lt;p&gt;The problem is that having a good CSP locks your site down. That means scripts, CSS, fonts, etc cannot connect to outside sources unless they are specified as ok by your CSP.&lt;/p&gt;
&lt;p&gt;In short, you can grab the CSP below if you&#39;d like to just move right along. It should allow everything you need to get Google Analytics working.&lt;/p&gt;
&lt;p&gt;One final note is that Google Analytics, be default, enables DoubeClick ad tracking. If you aren&#39;t making active use of that you should just disable it. More on that later!&lt;/p&gt;
&lt;p&gt;A working CSP:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;  Content-Security-Policy: default-src &lt;span class=&quot;token string&quot;&gt;&#39;self&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; script-src &lt;span class=&quot;token string&quot;&gt;&#39;self&#39;&lt;/span&gt; https://www.google-analytics.com https://ssl.google-analytics.com https://www.googletagmanager.com &lt;span class=&quot;token string&quot;&gt;&#39;unsafe-inline&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; img-src &lt;span class=&quot;token string&quot;&gt;&#39;self&#39;&lt;/span&gt; https://www.google-analytics.com&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; connect-src https://www.google-analytics.com&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;a-frustrating-evening&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/google-analytics-csp/#a-frustrating-evening&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; A frustrating evening&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/github-history-csp-google-analytics.png&quot; alt=&quot;My GitHub history getting angry while I work on this CSP project&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The main problems here are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Google Analytics has scripts that call other scripts, add tracking pixels (images) and make connections.&lt;/li&gt;
&lt;li&gt;Every time you add a new CSP category (default-src, script-src, etc) it will break all your current requests unless you remember to add &lt;code&gt;self&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;It&#39;s kind of annoying to test CSPs without building and deploying your site each time.&lt;/li&gt;
&lt;li&gt;You can&#39;t have whitespace within a CSP line so they get really, REALLY long.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;breaking-down-the-csp&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/google-analytics-csp/#breaking-down-the-csp&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Breaking down the CSP&lt;/h2&gt;
&lt;p&gt;Even though you&#39;ll have to copy and paste the snippet above to get it to work, let&#39;s add some whitespace just so we can read through it together.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;Content-Security-Policy:
    default-src &lt;span class=&quot;token string&quot;&gt;&#39;self&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    img-src &lt;span class=&quot;token string&quot;&gt;&#39;self&#39;&lt;/span&gt; https://www.google-analytics.com&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    connect-src https://www.google-analytics.com&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    script-src &lt;span class=&quot;token string&quot;&gt;&#39;self&#39;&lt;/span&gt; https://www.google-analytics.com https://ssl.google-analytics.com https://www.googletagmanager.com &lt;span class=&quot;token string&quot;&gt;&#39;unsafe-inline&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;default-src&lt;/code&gt; policy is a fallback. It says that if you don&#39;t specify a policy, in this case we don&#39;t have one for &lt;code&gt;font-src&lt;/code&gt;, it will inherit the behavior of the &lt;code&gt;default-src&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Images are allowed to come from the self host or Google Analytics.&lt;/li&gt;
&lt;li&gt;Connections can come from Google Analytics.&lt;/li&gt;
&lt;li&gt;Scripts can come from the self host, Google Analytics, the ssl Google Analytics domain and the Google Tag Manager domain.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;removing-doubleclick&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/google-analytics-csp/#removing-doubleclick&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Removing DoubleClick&lt;/h2&gt;
&lt;p&gt;If you get this working, you should be able to deploy your site with Google Analytics and see only one remaining error in the console. It&#39;s complaining about DoubleClick.&lt;/p&gt;
&lt;p&gt;Go into your GA dashboard and click &lt;strong&gt;Admin&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Tracking Info&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Data Collection&lt;/strong&gt; and toggle the &amp;quot;Advertising Reporting Features&amp;quot; to &amp;quot;off&amp;quot;.&lt;/p&gt;
&lt;p&gt;You should be good to go!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>How to add custom headers to Eleventy with Cloudflare Pages</title>
		<link href="https://jonkuperman.com/custom-headers-eleventy-cloudflare-pages/"/>
		<updated>2021-10-27T00:00:00Z</updated>
		<id>https://jonkuperman.com/custom-headers-eleventy-cloudflare-pages/</id>
		<content type="html">&lt;p&gt;&lt;a href=&quot;https://twitter.com/jkup/status/1453410224119898123&quot;&gt;https://twitter.com/jkup/status/1453410224119898123&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I&#39;m obsessed with &lt;a href=&quot;https://www.webpagetest.org/&quot;&gt;WebPageTest&lt;/a&gt;. It&#39;s such an amazing free resource and I use it to measure every project I build. When I first moved this website over to Cloudflare Pages (literally my first day at Cloudflare) I was sad to see it get a FAILING grade on WebPageTest.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/jkup/status/1424916560980979728&quot;&gt;https://twitter.com/jkup/status/1424916560980979728&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It was getting A&#39;s across the board except for the security audit. Digging a bit deeper, it was unhappy that my site was missing a few important security headers.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/webpagetest-security-failing.png&quot; alt=&quot;WebPageTest Security Failing&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/webpagetest-security-reasons.png&quot; alt=&quot;WebPageTest Security Details Page&quot; /&gt;&lt;/p&gt;
&lt;p&gt;At the time, it wasn&#39;t super easy to add custom headers to a Cloudflare Pages project. It was definitely doable! But you needed to build a Cloudflare Worker to sit in front of the site and add response headers. That all changed today!&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://blog.cloudflare.com/custom-headers-for-pages/&quot;&gt;Cloudflare adds custom headers for Pages&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now you can simply add a &lt;code&gt;_headers&lt;/code&gt; file to your Pages project and Cloudflare will add them to the responses!&lt;/p&gt;
&lt;p&gt;So I went to my website, adding a &lt;code&gt;_headers&lt;/code&gt; file in the root directory with the security headers in it and deployed!&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;/*
  Content-Security-Policy: default-src &lt;span class=&quot;token string&quot;&gt;&#39;self&#39;&lt;/span&gt;
  X-Frame-Options: DENY
  X-XSS-Protection: &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;
  X-Content-Type-Options: nosniff&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I raced over to check my WebPageTest score and...&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/webpagetest-security-failing.png&quot; alt=&quot;WebPageTest Security Failing&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Dangit. I checked my &lt;code&gt;_site&lt;/code&gt; directory and sure enough, there was no &lt;code&gt;_headers&lt;/code&gt; file in there.&lt;/p&gt;
&lt;h2 id=&quot;adding-the-headers-file-to-eleventy&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/custom-headers-eleventy-cloudflare-pages/#adding-the-headers-file-to-eleventy&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Adding the headers file to Eleventy&lt;/h2&gt;
&lt;p&gt;Then I remembered something about static assets on Eleventy. I did a quick search and found this lovely documentation page (their docs are so good) &lt;a href=&quot;https://www.11ty.dev/docs/copy/&quot;&gt;Passthrough file copy&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So I added this line of code to my &lt;code&gt;eleventy.js&lt;/code&gt; file:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;eleventyConfig&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addPassthroughCopy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;static&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;/&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, any files I stick in my &lt;code&gt;/static/&lt;/code&gt; directory will be directly copied over to the root of my &lt;code&gt;_site&lt;/code&gt; folder on build! So &lt;code&gt;/static/_headers&lt;/code&gt; becomes &lt;code&gt;/_site/_headers&lt;/code&gt; when you run &lt;code&gt;eleventy&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Deployed it again and BOOM, A+ city.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/webpagetest-cloudflare-pages.png&quot; alt=&quot;WebPageTest All A&#39;s&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;and-then-everything-broke...&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/custom-headers-eleventy-cloudflare-pages/#and-then-everything-broke...&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; And then everything broke...&lt;/h2&gt;
&lt;p&gt;I was so pumped! I wrote this blog post and Tweeted it! But then when I went to view it, I noticed that my Tweet embeds weren&#39;t working. I looked in the console and my Google Fonts and inline scripts stopped working too!&lt;/p&gt;
&lt;p&gt;Dang you, CSP!&lt;/p&gt;
&lt;p&gt;Ok so I found this awesome website on &lt;a href=&quot;https://content-security-policy.com/&quot;&gt;content security policies&lt;/a&gt; and scraped together some allowed domains to get my Google Fonts and Twitter embeds working again.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;Content-Security-Policy: default-src &lt;span class=&quot;token string&quot;&gt;&#39;self&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;font-src fonts.gstatic.com&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;style-src &lt;span class=&quot;token string&quot;&gt;&#39;self&#39;&lt;/span&gt; fonts.googleapis.com &lt;span class=&quot;token string&quot;&gt;&#39;sha256-5g0QXxO6NfvHJ6Uf5BK/hqQHtso8ZOdjlnbyKtYLvwc=&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; script-src &lt;span class=&quot;token string&quot;&gt;&#39;self&#39;&lt;/span&gt; platform.twitter.com syndication.twitter.com&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; frame-src &lt;span class=&quot;token string&quot;&gt;&#39;self&#39;&lt;/span&gt; platform.twitter.com&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But what about my sweet dark mode toggle which is some inline JavaScript?&lt;/p&gt;
&lt;p&gt;It turns out you have three choices:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Use a &lt;a href=&quot;https://content-security-policy.com/nonce/&quot;&gt;nonce&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Use the &#39;unsafe-inline&#39; &lt;a href=&quot;https://content-security-policy.com/unsafe-inline/&quot;&gt;option&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Generate a SHA hash and allow that.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I like pain so I chose option #3. I minified all of my inline JS into a single line&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;script&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;toggle_light_mode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;dark&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;localStorage&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getItem&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;theme&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;localStorage&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setItem&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;theme&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;light&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;documentElement&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;data-theme&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;light&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;localStorage&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setItem&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;theme&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;dark&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;documentElement&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;data-theme&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;dark&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;dark&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt;localStorage&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getItem&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;theme&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;documentElement&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;data-theme&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;dark&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;documentElement&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;data-theme&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;light&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;script&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then I ran&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-n&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;that single line of js above&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; openssl sha256 &lt;span class=&quot;token parameter variable&quot;&gt;-binary&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; openssl base64&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And that generated a unique hash, &lt;code&gt;8ZCTxR11UEYhveA/O/iAlHa4qNfBXa9oH8mU57KOrps=&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Finally, I added &lt;code&gt;sha256-that_hash_above&lt;/code&gt; to the &lt;code&gt;script-src&lt;/code&gt; section of my &lt;code&gt;_header&lt;/code&gt; file. So now it looks like&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;/*
Content-Security-Policy: default-src &lt;span class=&quot;token string&quot;&gt;&#39;self&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;font-src fonts.gstatic.com&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;style-src &lt;span class=&quot;token string&quot;&gt;&#39;self&#39;&lt;/span&gt; fonts.googleapis.com &lt;span class=&quot;token string&quot;&gt;&#39;sha256-5g0QXxO6NfvHJ6Uf5BK/hqQHtso8ZOdjlnbyKtYLvwc=&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; script-src &lt;span class=&quot;token string&quot;&gt;&#39;self&#39;&lt;/span&gt; platform.twitter.com syndication.twitter.com &lt;span class=&quot;token string&quot;&gt;&#39;sha256-8ZCTxR11UEYhveA/O/iAlHa4qNfBXa9oH8mU57KOrps=&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; frame-src &lt;span class=&quot;token string&quot;&gt;&#39;self&#39;&lt;/span&gt; platform.twitter.com&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I really need to get back to work 😅&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>I minted (and sold) my first NFT</title>
		<link href="https://jonkuperman.com/my-first-nft/"/>
		<updated>2021-10-03T00:00:00Z</updated>
		<id>https://jonkuperman.com/my-first-nft/</id>
		<content type="html">&lt;p&gt;It&#39;s pretty hard to miss the news on NFTs these days. They are a polarizing trend. Every day, it seems like there is an article of someone spending &lt;a href=&quot;https://hypebeast.com/2021/10/solana-monkey-business-nft-record-breaking-two-million-usd-sale&quot;&gt;2 million dollars&lt;/a&gt; on a pixelated monkey with a crown.&lt;/p&gt;
&lt;p&gt;Knowing so little about them, I had a million questions. Are they a scam? Are people seriously paying that much money for some pixelated art? Can&#39;t you just right-click and Save As? What about the environmental impact?&lt;/p&gt;
&lt;p&gt;It seems like half my Twitter timeline is &amp;quot;NFTs are the future,&amp;quot; and the other half is &amp;quot;NFTs are a scam.&amp;quot; Honestly, I didn&#39;t know what to think.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;environmental-cost&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-nft/#environmental-cost&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Environmental cost&lt;/h2&gt;
&lt;p&gt;I care a lot about the environment. At first, I thought all crypto transactions were &lt;a href=&quot;https://www.investopedia.com/tech/whats-environmental-impact-cryptocurrency/&quot;&gt;killing the planet&lt;/a&gt;, so I stayed out of them entirely. But then I read about some of the newer currencies like &lt;a href=&quot;https://solana.com/&quot;&gt;Solana&lt;/a&gt; and saw they use a super-efficient &lt;a href=&quot;https://medium.com/solana-labs/proof-of-history-a-clock-for-blockchain-cf47a61a9274&quot;&gt;Proof of History&lt;/a&gt; model.&lt;/p&gt;
&lt;h3 id=&quot;ethereum-is-also-migrating&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-nft/#ethereum-is-also-migrating&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Ethereum is also migrating&lt;/h3&gt;
&lt;p&gt;It&#39;s worth noting that the most popular NFT currency, &lt;a href=&quot;https://ethereum.org/en/&quot;&gt;Ethereum&lt;/a&gt;, is supposed to move away from Proof of Work by the end of the year. Some people are skeptical this will happen, but that would be a huge win if it does! Until then, I&#39;m not going to be messing around with any Ethereum NFTs. Back to the article!&lt;/p&gt;
&lt;p&gt;Ok, if it&#39;s not harming the planet, I can at least check it out!&lt;/p&gt;
&lt;h2 id=&quot;it&#39;s-not-about-the-art&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-nft/#it&#39;s-not-about-the-art&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; It&#39;s not about the art&lt;/h2&gt;
&lt;p&gt;One of the first things I learned was that it isn&#39;t about the artwork at the end of the day. It&#39;s a lot more like buying Pokemon / Magic the gathering cards than purchasing art.&lt;/p&gt;
&lt;p&gt;If you were ever into playing card games, you&#39;re probably familiar with booster packs. You can spend $5 on a sealed foil pack of 15-30 cards. The cards are random, but there are usually some guarantees. For example, some will say you get &amp;quot;at least&amp;quot; one rare in each pack.&lt;/p&gt;
&lt;p&gt;So you spend the $5 and excitedly open your pack! You pull out all the rares and look them up online to see if they are worth anything. It&#39;s a lot like gambling. But the cards have other uses, too, like adding to your playable collection or looking cool.&lt;/p&gt;
&lt;p&gt;This is how NFTs work too. Before the launch, you get some data like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;There will be 10,000 total.&lt;/li&gt;
&lt;li&gt;Each one will have a head, eyes, hat, shirt and background.&lt;/li&gt;
&lt;li&gt;You can see a chart listing the rarities of each trait. Like only 1 in 10,000 will generate a Darth Vader helmet.&lt;/li&gt;
&lt;li&gt;They will cost $100 to generate.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, you pay $100 to generate an NFT randomly, and you hope it comes with some super rare traits so you can sell it back for a lot more!&lt;/p&gt;
&lt;h3 id=&quot;minting-vs.-buying&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-nft/#minting-vs.-buying&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; minting vs. buying&lt;/h3&gt;
&lt;p&gt;There are so many new words to learn in the crypto space. One thing I did not understand was the difference between &amp;quot;minting&amp;quot; and &amp;quot;buying&amp;quot; NFTs. On the day an NFT launches, people race to &amp;quot;mint&amp;quot; or generate NFTs. Most launches will include a maximum number of NFTs that can be generated and often a maximum number of NFTs any wallet can generate. The minting process involves:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Going to the website.&lt;/li&gt;
&lt;li&gt;Waiting for the countdown to finish.&lt;/li&gt;
&lt;li&gt;Generating as many NFTs as possible before they are all minted.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As soon as the minting process finishes, the secondary market begins! This is largely up to the NFT creators and can be a sticking point for bad launches. Essentially, the creators of the NFT need to go to the popular markets and verify the collection. You get a dedicated page for buying and selling NFTs from that collection as soon as this happens.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/meerkat-digital-eyes.png&quot; alt=&quot;Meerkat market page&quot; /&gt;&lt;/p&gt;
&lt;p&gt;One thing that makes them cooler than playing cards is that they instantly turn into a secondary market. As soon as the 10,000 are generated, decentralized marketplaces like &lt;a href=&quot;https://digitaleyes.market/&quot;&gt;Digital Eyes&lt;/a&gt; and &lt;a href=&quot;https://solanart.io/&quot;&gt;Solanart&lt;/a&gt; will verify the NFT collection, and you can list yours for any amount you want. They also track total sales and the fluctuating floor price. This is to say that even if you get an NFT with no rare traits, odds are you can sell it back for the amount it cost you to generate it.&lt;/p&gt;
&lt;h2 id=&quot;additional-benefits&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-nft/#additional-benefits&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Additional benefits&lt;/h2&gt;
&lt;p&gt;On top of the rarity and resale value, NFTs these days are focusing on adding value. For example, &lt;a href=&quot;https://meerkatmillionaires.club/&quot;&gt;Meerkat Millionaires&lt;/a&gt; launched a set of NFTs where 100% of royalties go back to the original minters and people currently holding them. This means that if you mint one, you can collect monthly dividends based on how many sold that month forever.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/meerkats.gif&quot; alt=&quot;Meerkat Millionaires&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Others have more artistic or fun benefits. I saw one where the 6 rarest NFT owners get their names in a book and another where you get to vote on a storyline for a game. Others still get some swag for rare NFTs.&lt;/p&gt;
&lt;h2 id=&quot;picking-an-nft&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-nft/#picking-an-nft&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Picking an NFT&lt;/h2&gt;
&lt;p&gt;There are &lt;strong&gt;a lot&lt;/strong&gt; of NFTs launching. It&#39;s really tricky to find &amp;quot;good&amp;quot; ones. Some of the things to consider:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How many total NFTs can be minted?&lt;/li&gt;
&lt;li&gt;Are there any additional benefits for minting?&lt;/li&gt;
&lt;li&gt;How popular does the launch seem to be? (Twitter followers, Discord users)&lt;/li&gt;
&lt;li&gt;Is it a scam? (More on this below)&lt;/li&gt;
&lt;li&gt;How much does it cost to mint?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the end, I decided on &lt;a href=&quot;https://meerkatmillionaires.club/&quot;&gt;the Meerkats&lt;/a&gt; because:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://twitter.com/kng&quot;&gt;@kng&lt;/a&gt; told me to, and she knows way more about this stuff than I do.&lt;/li&gt;
&lt;li&gt;They look super cute.&lt;/li&gt;
&lt;li&gt;Big following on social media.&lt;/li&gt;
&lt;li&gt;Low&#39;ish cost to mint.&lt;/li&gt;
&lt;li&gt;People I trust were talking about them, so hopefully not a scam.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;scams-galore&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-nft/#scams-galore&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Scams galore&lt;/h2&gt;
&lt;p&gt;Ok, at this point, it probably sounds pretty awesome. There&#39;s potential to make big money; the environmental impact is tiny; in the worst case, you still probably make your initial money back; cute meerkats!&lt;/p&gt;
&lt;p&gt;There are a lot of scams in the NFT launch market. While buying and selling on official sites like Solanart and Digital Eyes is entirely safe, the minting process can be dangerous.&lt;/p&gt;
&lt;h3 id=&quot;types-of-scams&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-nft/#types-of-scams&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Types of scams&lt;/h3&gt;
&lt;p&gt;There are two types of scams I&#39;ve seen so far:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;There is no NFT. You visit a cool site, wait for the launch, you spend your $150, and nothing goes into your wallet.&lt;/li&gt;
&lt;li&gt;The art is not as advertised. Either you get a piece of art that looks nothing like you expected (with none of the rarity attributes).&lt;/li&gt;
&lt;li&gt;They are trying to deplete your wallet. Since these launches are so time-sensitive, people often connect their wallet to the site and turn on the setting to &amp;quot;auto-approve all transactions.&amp;quot; Then they click the button to spend $150 on a token, and the website code tries to make dozens of $1,000 transactions and deplete your funds.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Unfortunately, there &lt;strong&gt;is no way to stay completely safe minting NFTs&lt;/strong&gt;. There are, however, things you can do to significantly mitigate risk.&lt;/p&gt;
&lt;p&gt;Make a burner wallet. Creating a wallet in an app like &lt;a href=&quot;https://phantom.app/&quot;&gt;Phantom&lt;/a&gt; is as simple as two clicks! If the NFT you want to mint costs 1 Solana, make a burner account and transfer only 1.05 Solana into it (1 to mint and 0.05 to cover fees). This way, the worst that happens is you are out one coin.&lt;br /&gt;
Never click auto-approve. I know it sounds like it will save time but just don&#39;t click it. Try to mint the NFT, look at the request when it pops up and make sure it&#39;s for the amount you expect.&lt;br /&gt;
Be skeptical about launches. I try to look at who&#39;s following the Twitter account, if that company has done a launch before, etc. Is there anything tying them to the community?&lt;/p&gt;
&lt;p&gt;Honestly, these scams seem like the #1 issue that needs to be fixed in the community. I&#39;m sure there is some cool solution that doesn&#39;t involve some centralized authority running launches. It&#39;s tough to navigate because a well-funded and popular launch means it will be tough to mint one before they sell out, but otherwise, you risk a scam.&lt;/p&gt;
&lt;h2 id=&quot;my-experience&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-nft/#my-experience&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; My experience&lt;/h2&gt;
&lt;p&gt;So I went with the Meerkats! I made a Phantom burner account and put just 1 Solana in there. I connected it to the website and made sure auto-approve was not selected. I waited for the timer to count down, and as soon as it did, I clicked mint! I got this awesome dude:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/meerkat.png&quot; alt=&quot;My meerkat&quot; /&gt;&lt;/p&gt;
&lt;p&gt;One weird thing about buying stuff with crypto is that not only can the value of the asset go up and down, but the dollar value of the currency can go up and down at the same time! So I minted my dude for 1 Solana, which at the time was worth $150.&lt;/p&gt;
&lt;p&gt;They sold out instantly. The secondary markets were a bit slower to fill up than I expected. I held on to my lazer boi for a couple days, and when the floor (lowest token currently for sale) went to 22 Solana, I listed mine, and it sold! Not only did I spend 1 Solana and make 22, but Solana itself went up from $150 to $170 in that time. So I spent $150 and made about $3200 after all the fees and royalties.&lt;/p&gt;
&lt;p&gt;Now the floor is up to 26 Solana, and I wish I held. Isn&#39;t that always the way?&lt;/p&gt;
&lt;p&gt;That was a fun weekend.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Chrome DevTools Console Drawer</title>
		<link href="https://jonkuperman.com/chrome-console-drawer/"/>
		<updated>2021-09-26T00:00:00Z</updated>
		<id>https://jonkuperman.com/chrome-console-drawer/</id>
		<content type="html">&lt;h1 id=&quot;chrome-devtools-console-drawer&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chrome-console-drawer/#chrome-devtools-console-drawer&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Chrome DevTools Console Drawer&lt;/h1&gt;
&lt;p&gt;Have you ever accidentally hit the escape key while using the Chrome DevTools? And that little bottom drawer pops up with another console. And you&#39;re like, what the heck is this thing?&lt;/p&gt;
&lt;p&gt;If so, then you&#39;ve encountered the &amp;quot;Console Drawer.&amp;quot; But, what exactly is it? And what secrets does it hold!? Here is a list of 6 things you can do with the Console Drawer.&lt;/p&gt;
&lt;h2 id=&quot;1.-view-unused-css-and-js&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chrome-console-drawer/#1.-view-unused-css-and-js&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 1. View unused CSS &amp;amp; JS&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/jkup/status/1442207564876374022&quot;&gt;https://twitter.com/jkup/status/1442207564876374022&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can open the Coverage panel inside the Console drawer and generate a code coverage report for your website! This is super helpful if you want to catch any unused CSS that might be lingering around, bloating your bundle size!&lt;/p&gt;
&lt;p&gt;It&#39;s worth noting that while identifying unused code for a specific page is easy, it&#39;s much more difficult to configure your build not to serve specific CSS or JS per page. So take this with a grain of salt!&lt;/p&gt;
&lt;h2 id=&quot;2.-monitor-cpu-and-memory-in-real-time&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chrome-console-drawer/#2.-monitor-cpu-and-memory-in-real-time&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 2. Monitor CPU and Memory in real-time&lt;/h2&gt;
&lt;p&gt;Although the DevTools have multiple places to get profiling data, the real-time performance monitor is a great place to start!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/performance-monitor.gif&quot; alt=&quot;Realtime performance monitor&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;3.-inspect-web-audio&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chrome-console-drawer/#3.-inspect-web-audio&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 3. Inspect Web Audio&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/web-audio.png&quot; alt=&quot;Web audio inspector&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;4.-inspect-animations&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chrome-console-drawer/#4.-inspect-animations&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 4. Inspect Animations&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/animations.gif&quot; alt=&quot;Animation inspector&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;5.-block-network-requests&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chrome-console-drawer/#5.-block-network-requests&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 5. Block Network Requests&lt;/h2&gt;
&lt;p&gt;You can build your own ad blocker! Or test your application... Enter any URL you&#39;d like to block (using * as a wildcard), and Chrome won&#39;t load those requests.&lt;/p&gt;
&lt;p&gt;Nailed it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/network-blocking.png&quot; alt=&quot;Network blocker&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;6.-override-location-touch-or-idle-state&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/chrome-console-drawer/#6.-override-location-touch-or-idle-state&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 6. Override Location, Touch or Idle State&lt;/h2&gt;
&lt;p&gt;You can manually set your country of origin. Override your mouse clicks to be touch events or event simulate a mobile device idle state! All from the DevTools!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/devtools-sensors.png&quot; alt=&quot;DevTools sensors&quot; /&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>JavaScript math methods I never knew existed</title>
		<link href="https://jonkuperman.com/weird-javascript-math-methods/"/>
		<updated>2021-09-07T00:00:00Z</updated>
		<id>https://jonkuperman.com/weird-javascript-math-methods/</id>
		<content type="html">&lt;p&gt;I was trying to break Cloudflare Workers tonight and did a search for &amp;quot;CPU intensive JavaScript&amp;quot; because I&#39;m really good at my job.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://gist.github.com/sqren/5083d73f184acae0c5b7&quot;&gt;This gist&lt;/a&gt; popped up with the following code:&lt;/p&gt;
&lt;hr /&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;mySlowFunction&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;baseNumber&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;mySlowFunction&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;pow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;baseNumber&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;token operator&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    result &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;atan&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;tan&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;timeEnd&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;mySlowFunction&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;mySlowFunction&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// higher number =&gt; more iterations =&gt; slower&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Cool, cool. It&#39;s some loop that does something and returns a... wait a minute what the heck is &lt;code&gt;Math.atan&lt;/code&gt;!?&lt;/p&gt;
&lt;p&gt;According to &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan&quot;&gt;MDN&lt;/a&gt; it&#39;s:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The Math.atan() function returns the arctangent (in radians) of a number&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I don&#39;t know anything about math so I&#39;m not even going to pretend to understand actangents but it led me to wondering what other math methods I never heard of. Here&#39;s a list:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Math.acos(): The Math.acos() function returns the arccosine (in radians) of a number.&lt;/li&gt;
&lt;li&gt;Math.acosh(): The Math.acosh() function returns the hyperbolic arc-cosine of a number.&lt;/li&gt;
&lt;li&gt;Math.asin(): The Math.asin() function returns the arcsine (in radians) of a number.&lt;/li&gt;
&lt;li&gt;Math.asinh(): The Math.asinh() function returns the hyperbolic arcsine of a number.&lt;/li&gt;
&lt;li&gt;Math.atan2(): The Math.atan2() function returns the angle in the plane (in radians) between the positive x-axis and the ray from (0,0) to the point (x,y), for Math.atan2(y,x).&lt;/li&gt;
&lt;li&gt;Math.atanh(): The Math.atanh() function returns the hyperbolic arctangent of a number.&lt;/li&gt;
&lt;li&gt;Math.cbrt(): The Math.cbrt() function returns the cube root of a number.&lt;/li&gt;
&lt;li&gt;Math.clz32(): The Math.clz32() function returns the number of leading zero bits in the 32-bit binary representation of a number.&lt;/li&gt;
&lt;li&gt;Math.cosh(): The Math.cosh() function returns the hyperbolic cosine of a number, that can be expressed using the constant e.&lt;/li&gt;
&lt;li&gt;Math.expm1(): The Math.expm1() function returns e^x - 1, where x is the argument, and e the base of the natural logarithms.&lt;/li&gt;
&lt;li&gt;Math.fround(): The Math.fround() function returns the nearest 32-bit single precision float representation of a Number.&lt;/li&gt;
&lt;li&gt;Math.hypot(): The Math.hypot() function returns the square root of the sum of squares of its arguments.&lt;/li&gt;
&lt;li&gt;Math.imul(): The Math.imul() function returns the result of the C-like 32-bit multiplication of the two parameters.&lt;/li&gt;
&lt;li&gt;Math.log10(): The Math.log10() function returns the base 10 logarithm of a number.&lt;/li&gt;
&lt;li&gt;Math.log1p(): The Math.log1p() function returns the natural logarithm (base e) of 1 + a number.&lt;/li&gt;
&lt;li&gt;Math.log2(): The Math.log2() function returns the base 2 logarithm of a number.&lt;/li&gt;
&lt;li&gt;Math.sin(): The Math.sin() function returns the sine of a number.&lt;/li&gt;
&lt;li&gt;Math.sinh(): The Math.sinh() function returns the hyperbolic sine of a number, that can be expressed using the constant e.&lt;/li&gt;
&lt;li&gt;Math.tan(): The Math.tan() function returns the tangent of a number.&lt;/li&gt;
&lt;li&gt;Math.tanh(): The Math.tanh() function returns the hyperbolic tangent of a number.&lt;/li&gt;
&lt;li&gt;Math.trunc(): The Math.trunc() function returns the integer part of a number by removing any fractional digits.&lt;/li&gt;
&lt;/ul&gt;
</content>
	</entry>
	
	<entry>
		<title>Introduction to cryptocurrencies</title>
		<link href="https://jonkuperman.com/introduction-to-cryptocurrencies/"/>
		<updated>2021-09-04T00:00:00Z</updated>
		<id>https://jonkuperman.com/introduction-to-cryptocurrencies/</id>
		<content type="html">&lt;p&gt;Introduction to cryptocurrencies&lt;/p&gt;
&lt;p&gt;I recently went down a bit of a crypto rabbit hole. I&#39;ve been aware of Bitcoin since 2014, but I didn&#39;t truly understand it, and I had no idea about all the newer things in the space. Some questions I had when starting:&lt;/p&gt;
&lt;hr /&gt;
&lt;ol&gt;
&lt;li&gt;What are exchanges?&lt;/li&gt;
&lt;li&gt;What is a wallet?&lt;/li&gt;
&lt;li&gt;What is mining?&lt;/li&gt;
&lt;li&gt;Are all cryptocurrencies terrible for the environment?&lt;/li&gt;
&lt;li&gt;How do taxes on crypto work?&lt;/li&gt;
&lt;li&gt;What is a DAO?&lt;/li&gt;
&lt;li&gt;What is the deal with NFTs?&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;how-i-got-started&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/introduction-to-cryptocurrencies/#how-i-got-started&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; How I got started&lt;/h2&gt;
&lt;p&gt;First things first, I watched a few free documentaries on the history of Bitcoin.&lt;/p&gt;
&lt;h3 id=&quot;crypto-documentaries-i-watched&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/introduction-to-cryptocurrencies/#crypto-documentaries-i-watched&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Crypto Documentaries I Watched&lt;/h3&gt;
&lt;h3 id=&quot;first-up-banking-on-bitcoin&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/introduction-to-cryptocurrencies/#first-up-banking-on-bitcoin&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; First up, Banking on Bitcoin&lt;/h3&gt;
&lt;p&gt;Free on YouTube, Banking on Bitcoin makes a great introduction. It starts with the 2008 financial crisis and follows along with Bitcoin&#39;s creation and early history.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=6jSm9vTBGKU&quot;&gt;https://www.youtube.com/watch?v=6jSm9vTBGKU&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;next-cryptopia&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/introduction-to-cryptocurrencies/#next-cryptopia&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Next, Cryptopia&lt;/h3&gt;
&lt;p&gt;Free with an Amazon Prime subscription, &lt;a href=&quot;https://www.amazon.com/Cryptopia-Bitcoin-Blockchains-Future-Internet/dp/B08HSLGR29&quot;&gt;Cryptopia&lt;/a&gt; covers the good, the bad and the ugly of crypto.&lt;/p&gt;
&lt;h3 id=&quot;short-and-sweet-netflix-explained:-cryptocurrency&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/introduction-to-cryptocurrencies/#short-and-sweet-netflix-explained:-cryptocurrency&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Short and sweet, Netflix Explained: Cryptocurrency&lt;/h3&gt;
&lt;p&gt;Season 1 of &lt;a href=&quot;https://www.netflix.com/title/80216752&quot;&gt;Netflix Explained&lt;/a&gt; has a &amp;quot;Cryptocurrency&amp;quot; episode that is very good! It&#39;s only 19 minutes long, but it covers a lot.&lt;/p&gt;
&lt;h2 id=&quot;great-youtube-channels&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/introduction-to-cryptocurrencies/#great-youtube-channels&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Great YouTube Channels&lt;/h2&gt;
&lt;h3 id=&quot;99bitcoins&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/introduction-to-cryptocurrencies/#99bitcoins&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 99Bitcoins&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/c/Bitcoinwithpaypal&quot;&gt;https://www.youtube.com/c/Bitcoinwithpaypal&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;coin-bureau&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/introduction-to-cryptocurrencies/#coin-bureau&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Coin Bureau&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCqK_GSMbpiV8spgD3ZGloSw&quot;&gt;https://www.youtube.com/channel/UCqK_GSMbpiV8spgD3ZGloSw&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;crypto-lark&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/introduction-to-cryptocurrencies/#crypto-lark&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Crypto Lark&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/channel/UCl2oCaw8hdR_kbqyqd2klIA&quot;&gt;https://www.youtube.com/channel/UCl2oCaw8hdR_kbqyqd2klIA&lt;/a&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>How to join Developer DAO</title>
		<link href="https://jonkuperman.com/how-to-join-developer-dao/"/>
		<updated>2021-09-04T00:00:00Z</updated>
		<id>https://jonkuperman.com/how-to-join-developer-dao/</id>
		<content type="html">&lt;p&gt;I saw a tweet from &lt;a href=&quot;https://twitter.com/dabit3&quot;&gt;@nader&lt;/a&gt; about him creating Developer DAO yesterday. I don&#39;t know much about them, but it sounded interesting. Here&#39;s how I joined and what I learned so far!&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/dabit3/status/1433879106119208966&quot;&gt;https://twitter.com/dabit3/status/1433879106119208966&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;joining-developer-dao&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/how-to-join-developer-dao/#joining-developer-dao&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Joining Developer DAO&lt;/h2&gt;
&lt;p&gt;In his tweet, he links to an &lt;a href=&quot;https://etherscan.io/token/0x25ed58c027921E14D86380eA2646E3a1B5C55A8b&quot;&gt;etherscan URL&lt;/a&gt; which shows all of the tokens for this DAO. To &amp;quot;join&amp;quot; the DAO, you need to purchase a token. Sounds easy, right?&lt;/p&gt;
&lt;p&gt;This crypto stuff is super cool, but they are sorely missing UI designers and developers.&lt;/p&gt;
&lt;p&gt;The TL;DR is you need to click a few buttons in the Etherscan site and &amp;quot;buy&amp;quot; a token. The tokens are free, but there is a hefty (and constantly changing fee called a gas price needed to make any purchase). Also, you&#39;ll need an Ethereum wallet to be able to make the purchase! Let&#39;s start there.&lt;/p&gt;
&lt;h2 id=&quot;creating-a-wallet&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/how-to-join-developer-dao/#creating-a-wallet&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Creating a wallet&lt;/h2&gt;
&lt;p&gt;I went to &lt;a href=&quot;https://metamask.io/&quot;&gt;metamask.io&lt;/a&gt; and created a wallet. I wrote down my secret key phrase thing and then added the Chrome extension.&lt;/p&gt;
&lt;p&gt;I have some Ethereum that I bought using &lt;a href=&quot;https://www.coinbase.com/&quot;&gt;Coinbase&lt;/a&gt;. I copied my Metamask wallet address from the Chrome extension, then I went to my Coinbase account and withdrew 0.03 (what I estimated the gas fee would be at the time) Ethereum (needed to cover the transaction fee mentioned above).&lt;/p&gt;
&lt;h2 id=&quot;connecting-your-wallet-to-etherscan&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/how-to-join-developer-dao/#connecting-your-wallet-to-etherscan&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Connecting your wallet to Etherscan&lt;/h2&gt;
&lt;p&gt;BOOM. I now have money (or rather Ethereum) in my Metamask wallet. Then, with the Chrome extension installed, I made an Etherscan account and went back to the &lt;a href=&quot;https://etherscan.io/token/0x25ed58c027921E14D86380eA2646E3a1B5C55A8b&quot;&gt;url&lt;/a&gt; mentioned above. I clicked on &lt;strong&gt;Contract&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Write contract&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Connect to Web3&lt;/strong&gt; and clicked accept on all the thingies to connect my Metamask wallet to my Etherscan account.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/etherscan-purchase.png&quot; alt=&quot;Connecting to Web3 on Etherscan&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;finding-an-available-token&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/how-to-join-developer-dao/#finding-an-available-token&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Finding an available token&lt;/h2&gt;
&lt;p&gt;Another weird part. There are 8000 total tokens for this DAO, and you want to buy one. It sure would be nice if you could just click a &amp;quot;give me one&amp;quot; button and get one. But things aren&#39;t that easy. You&#39;ll need to find the ID of an available token. I&#39;m sure there is a better way, but here&#39;s what I did:&lt;/p&gt;
&lt;p&gt;Click on &lt;strong&gt;Inventory&lt;/strong&gt; and look for any id not showing up in sequential order. At the time of this writing, I see 1005, 1006 and 1007 but not 1008. So I think 1008 is available to purchase?&lt;/p&gt;
&lt;p&gt;Take that ID and go back to &lt;strong&gt;Contract&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Write contract&lt;/strong&gt;. Click the &amp;quot;claim&amp;quot; dropdown and enter that ID. Then click &amp;quot;Write.&amp;quot; It should open the Metamask extension and give you a button to approve the transaction. The price varies minute by minute. It seems like it&#39;s fluctuating between $45 and $400 right now. So if it&#39;s higher than $100 you should just wait and try again later!&lt;/p&gt;
&lt;p&gt;Hopefully that worked, and now you are an official member of the DAO!&lt;/p&gt;
&lt;h2 id=&quot;joining-the-discord&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/how-to-join-developer-dao/#joining-the-discord&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Joining the Discord&lt;/h2&gt;
&lt;p&gt;First, you can join the Discord without joining the DAO by following &lt;a href=&quot;https://discord.gg/Aa4NBSuW&quot;&gt;this link&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To &amp;quot;join&amp;quot; the DAO part of the Discord you have to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Enter the &amp;quot;public&amp;quot; voice channel. Don&#39;t worry, you don&#39;t need to talk or have audio. You just need to be in there.&lt;/li&gt;
&lt;li&gt;Go to any one of the text channels under &amp;quot;INFO&amp;quot; and type &amp;quot;!join&amp;quot;. You will get a DM from a bot called &amp;quot;Collab.land&amp;quot;, and it will give you a link. You follow that link and enter your Metamask wallet address, and you&#39;re done!&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;come-say-hi!&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/how-to-join-developer-dao/#come-say-hi!&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Come say hi!&lt;/h2&gt;
&lt;p&gt;I hope this helped. If you get stuck, message me on &lt;a href=&quot;https://twitter.com/jkup&quot;&gt;Twitter&lt;/a&gt;, and I&#39;ll do my best to help you!&lt;/p&gt;
&lt;p&gt;Also, you should follow &lt;a href=&quot;https://twitter.com/developer_dao&quot;&gt;@developer_dao&lt;/a&gt; on Twitter!&lt;/p&gt;
&lt;h3 id=&quot;a-note-about-gas-prices&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/how-to-join-developer-dao/#a-note-about-gas-prices&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; A note about gas prices&lt;/h3&gt;
&lt;p&gt;I&#39;m pretty new to Ethereum, but the gas price is a fee for &lt;strong&gt;any&lt;/strong&gt; transaction. They fluctuate wildly! They were like $400 last night, $40 this morning and $80 when I purchased. My best advice is to keep this &lt;a href=&quot;https://etherscan.io/gastracker&quot;&gt;gas tracker&lt;/a&gt; open and when you see it drop low, go do the steps above!&lt;/p&gt;
&lt;p&gt;Good luck out there.&lt;/p&gt;
&lt;h3 id=&quot;what-the-heck-is-a-dao!&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/how-to-join-developer-dao/#what-the-heck-is-a-dao!&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What the heck is a DAO!?&lt;/h3&gt;
&lt;p&gt;A DAO is a Decentralized Autonomous Organization. Basically a community where we can make &lt;a href=&quot;https://www.ibm.com/topics/smart-contracts&quot;&gt;Smart contracts&lt;/a&gt; and all vote on the direction the community takes. Honestly if this sounds confusing it&#39;s because I have no idea what they really are. The gas prices are a huge issue but otherwise this DAO is free to join. It&#39;s a fun Discord of developers who are interested in Crypto!&lt;/p&gt;
&lt;p&gt;Here&#39;s mine 😎&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/my-developer-dao-token.png&quot; alt=&quot;My Developer DAO token&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;what-does-my-token-look-like&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/how-to-join-developer-dao/#what-does-my-token-look-like&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What does my token look like?&lt;/h3&gt;
&lt;p&gt;After you purchase your token, you can go to &lt;a href=&quot;https://opensea.io/collection/devs-for-revolution&quot;&gt;OpenSea&lt;/a&gt; and type in your ID number! It&#39;ll show you this funny list of things. That image represents your token. Post it in the #show-your-dev channel in Discord!&lt;/p&gt;
&lt;h3 id=&quot;what-should-i-do-if-the-collab.land-message-is-blank&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/how-to-join-developer-dao/#what-should-i-do-if-the-collab.land-message-is-blank&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What should I do if the Collab.Land message is blank?&lt;/h3&gt;
&lt;p&gt;If you are entering the !join command and the bot is replying with a blank message, you likely have Link Preview turned off in your user settings.&lt;/p&gt;
&lt;p&gt;User Settings &amp;gt; Text &amp;amp; Images &amp;gt; Link Preview and enable it&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Switching to DevRel from Engineering</title>
		<link href="https://jonkuperman.com/switching-devrel-from-engineering/"/>
		<updated>2021-08-31T00:00:00Z</updated>
		<id>https://jonkuperman.com/switching-devrel-from-engineering/</id>
		<content type="html">&lt;p&gt;I&#39;m finishing up my 4th week at Cloudflare and my 4th week as a Developer Advocate.&lt;/p&gt;
&lt;p&gt;Cloudflare has been amazing! I&#39;m working with one of the friendliest and most excited groups of people ever. We have excellent products, an ambitious roadmap, a healthy culture, and I couldn&#39;t be more excited for the next year!&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Developer advocacy has also been amazing. It&#39;s quite a bit different than I expected it to be. Mostly in positive ways! I&#39;ve been struggling to process my thoughts on the subject so writing them down seemed like an easy way to go.&lt;/p&gt;
&lt;p&gt;Here are some of the main points I&#39;ve noticed switching from Engineering to Developer Relations.&lt;/p&gt;
&lt;h2 id=&quot;working-on-multiple-projects&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/switching-devrel-from-engineering/#working-on-multiple-projects&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Working on multiple projects&lt;/h2&gt;
&lt;p&gt;As an engineer, you typically get assigned to a team. That team typically owns one product or part of a product, and that&#39;s where you spend your time. Companies will often have all hands or demo hours where you can see what the other teams are working on, but most of the time, you are heads down.&lt;/p&gt;
&lt;p&gt;As a Developer Advocate, you get to work with &lt;strong&gt;a lot&lt;/strong&gt; of teams. I work with my team (other DevRel folks), product engineering teams (&lt;a href=&quot;https://workers.cloudflare.com/&quot;&gt;Workers&lt;/a&gt;, &lt;a href=&quot;https://pages.cloudflare.com/&quot;&gt;Pages&lt;/a&gt;, &lt;a href=&quot;https://github.com/cloudflare/wrangler&quot;&gt;Wrangler&lt;/a&gt;), content writers, product managers, social media folks and event organizers! It&#39;s really fun, and I feel way more connected to the company than I usually do. It also can be super overwhelming.&lt;/p&gt;
&lt;h2 id=&quot;consumption-vs.-production&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/switching-devrel-from-engineering/#consumption-vs.-production&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Consumption vs. Production&lt;/h2&gt;
&lt;p&gt;As an engineer, your job is to &amp;quot;produce.&amp;quot; A team typically has some amount of work that needs doing, and that work gets divided by the number of engineers. Sometimes you&#39;ll get to learn something (consumption) like ramping up on a new technology stack or integrating with another team. But for the most part, your job is to write code (produce).&lt;/p&gt;
&lt;p&gt;DevRel feels different. There is value in you learning the roadmaps. For all of the teams, you are working with. You still do a good amount of producing (writing docs, blog posts, making videos, giving talks, etc.). But, I spend a lot of my day consuming (attending meetings, reading docs, listening to customers, reading PRs, chatting with folks in the community).&lt;/p&gt;
&lt;h2 id=&quot;i-miss-coding&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/switching-devrel-from-engineering/#i-miss-coding&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; I miss coding&lt;/h2&gt;
&lt;p&gt;Sitting in on a lot of these product engineering meetings, I get &lt;strong&gt;super&lt;/strong&gt; excited for what they are building. My instinct is to jump in and help. Need a PR reviewed? I&#39;m on it! Want to whiteboard your approach? Let&#39;s do a video call! It isn&#39;t easy knowing that I need to add my value in a different way and miss out on the coding party.&lt;/p&gt;
&lt;h2 id=&quot;i-never-want-to-code-again&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/switching-devrel-from-engineering/#i-never-want-to-code-again&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; I never want to code again&lt;/h2&gt;
&lt;p&gt;Five minutes later, I get a ping from someone wanting me to check out a new feature someone shipped, make a fun demo app with it and write a blog post about it! Like, on work time? Am I gonna get paid to do that? No way!&lt;/p&gt;
&lt;h2 id=&quot;a-dog-chasing-cars&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/switching-devrel-from-engineering/#a-dog-chasing-cars&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; A dog chasing cars&lt;/h2&gt;
&lt;p&gt;My first week here, I had a meeting with my teammate &lt;a href=&quot;https://twitter.com/lukeed05&quot;&gt;Luke&lt;/a&gt;. He talked to me about how overwhelming the job can be and the importance of picking some areas to focus on and do well and letting others go. It&#39;s impossible to keep up with all of the stuff the org is building. He said to do otherwise would be like a dog chasing cars, and that stuck with me.&lt;/p&gt;
&lt;h2 id=&quot;creative-work-is-exhausting&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/switching-devrel-from-engineering/#creative-work-is-exhausting&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Creative work is exhausting&lt;/h2&gt;
&lt;p&gt;I started this job thinking that I&#39;d be able to sit down and pump out blog posts and videos 8 hours a day. I don&#39;t know why I ever thought that. It&#39;s amazing how tired I feel after a few meetings learning about all sorts of cool new stuff. Some days I sit down with my editor open in focus mode to work on a blog post, and my eyes just blur. I need to pick and protect some focus time, set a reasonable expectation for hours per week spent creating content and add some mentally refreshing activities to my day like walking.&lt;/p&gt;
&lt;h2 id=&quot;engaging-with-the-community&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/switching-devrel-from-engineering/#engaging-with-the-community&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Engaging with the community&lt;/h2&gt;
&lt;p&gt;We have a &lt;strong&gt;really cool&lt;/strong&gt; &lt;a href=&quot;https://discord.gg/cloudflaredev&quot;&gt;Discord community&lt;/a&gt;. I always enjoyed engaging with customers/users at my other jobs but just couldn&#39;t find the time. I love being able to spend part of my day reading all the neat things folks are building. I like seeing how they use the products, where we could improve and where we are excelling. I did my first community call last week, and it was awesome.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>On Interviewing...</title>
		<link href="https://jonkuperman.com/on-interviewing/"/>
		<updated>2021-07-15T00:00:00Z</updated>
		<id>https://jonkuperman.com/on-interviewing/</id>
		<content type="html">&lt;p&gt;Ah, the dreaded coding interview. Hated by so many, and with good reason! I&#39;ve been working in tech for 12 years, so I&#39;ve been both the interviewer and interviewee many times.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/on-interviewing.jpg&quot; alt=&quot;Two interview chairs&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Honestly, I think the tech interview process has significantly improved in the past few years, but it still has a long way to go. I&#39;ve also come to terms with the fact that interviewing is seriously difficult. At different points in my career, I thought I had the answer to making interviewing better, but every option has its drawbacks.&lt;/p&gt;
&lt;p&gt;Let&#39;s talk about a few common interviewing strategies and where they succeed and fail.&lt;/p&gt;
&lt;h2 id=&quot;interviewing-strategies&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#interviewing-strategies&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Interviewing Strategies&lt;/h2&gt;
&lt;p&gt;I&#39;ve seen 3 schools of tech interviewing over the years. A full day of on-site interviews, a take-home with a few follow-up interviews, and contract-to-hire.&lt;/p&gt;
&lt;h3 id=&quot;full-day-on-site&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#full-day-on-site&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Full day on-site&lt;/h3&gt;
&lt;p&gt;This was the &amp;quot;standard&amp;quot; tech interview for many years. It typically consists of a recruiter call followed by 1-2 technical phone screens. These usually involve pair programming but often are &amp;quot;easier&amp;quot; questions than you&#39;re likely to face later on. If those go well, companies will often fly you to their office for an on-site or (in COVID times) set up a full-day interview panel over Zoom or Google Meet. If these go well, you get an offer!&lt;/p&gt;
&lt;h3 id=&quot;things-i-like&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#things-i-like&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Things I like&lt;/h3&gt;
&lt;p&gt;I like that the interview is extremely time-boxed. If you&#39;re busy with a current job, family obligations, etc. -- it&#39;s nice to have a maximum number of hours spent interviewing. This is even more true if you&#39;re interviewing at multiple places.&lt;/p&gt;
&lt;p&gt;Years ago, it was common to be asked completely unrelated compsci questions no matter your skillset or what position you were interviewing for. I &amp;quot;think&amp;quot; this has changed in recent years. Many interviews I do as a JavaScript developer focus much more on web development than more &amp;quot;back end&amp;quot; concepts like advanced data structures and algorithms.&lt;/p&gt;
&lt;h4 id=&quot;things-i-dislike&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#things-i-dislike&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Things I dislike&lt;/h4&gt;
&lt;p&gt;Having 5-7 strangers come up with random questions and ask them to you on the spot is stressful! You can study for hundreds of hours but forget to study a concept like &amp;quot;radix sort&amp;quot; and get asked to implement one first question! Some places offset this by sending you a list of possible topics beforehand. Other companies insist that you use Google or StackOverflow whenever you need them during the process. It&#39;s still stressful going into a panel where any subject in computer science is on the table.&lt;/p&gt;
&lt;p&gt;Full-day on-site interviews bias towards folks who perform well on the spot. I can&#39;t count the times I forgot how to spell a word or forgot the name of a common JavaScript method when in a small room with a stranger, marker in my hand.&lt;/p&gt;
&lt;h3 id=&quot;take-home-interviews&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#take-home-interviews&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Take home interviews&lt;/h3&gt;
&lt;p&gt;A few years ago, take-home interviews became very popular. Typically you&#39;ll still have an initial call with a recruiter or hiring manager, but then, instead of a phone screen, you&#39;ll be sent a take-home project to complete on your own time. Sometimes these are vague (a writing prompt like &amp;quot;build an image carousel&amp;quot;), and other times they are very specific (a HackerRank link that tracks time spent or a partially complete project for you to work on).&lt;/p&gt;
&lt;p&gt;Typically, companies that do take-home challenges structure the follow-up &amp;quot;on-site&amp;quot; interviews around the completed project. Maybe they&#39;ll ask you to add more features, walk through the code you wrote or discuss trade-offs you made along the way.&lt;/p&gt;
&lt;h3 id=&quot;things-i-like-1&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#things-i-like-1&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Things I like&lt;/h3&gt;
&lt;p&gt;Take homes result in way less performance anxiety. You can sit down in the comfort of your own home with a nice cup of coffee and work at your own pace. No one is watching, so you can use Google or look up &amp;quot;silly&amp;quot; things at your leisure. It simulates real programming work much more closely.&lt;/p&gt;
&lt;h3 id=&quot;things-i-dislike-1&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#things-i-dislike-1&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Things I dislike&lt;/h3&gt;
&lt;p&gt;Unless the question is strictly time-boxed, you are essentially competing for a job against the person who spent the most time on the project. Once I had a company send me a prompt, and in the email, they said, &amp;quot;You should spend no more than 4 hours on this project.&amp;quot; I finished and sent it in. Later, I received a rejection during which they told me all about the incredible submissions they had received with complete documentation, 100% test coverage, or extra features added on top of the prompt. I felt so foolish for only spending 4 hours on mine.&lt;/p&gt;
&lt;h3 id=&quot;contract-to-hire&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#contract-to-hire&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Contract-to-hire&lt;/h3&gt;
&lt;p&gt;Contract-to-hire has been around for a long time but has made a recent resurgence in the tech industry. The idea is that after passing an initial phone screen with a recruiter or hiring manager, you&#39;re brought on to do real work for which you receive real compensation. Some places offer full-time employment for a month or two. Others just ask for a few hours a week, which you can do on top of your current job.&lt;/p&gt;
&lt;h3 id=&quot;things-i-like-2&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#things-i-like-2&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Things I like&lt;/h3&gt;
&lt;p&gt;Contract-to-hire probably gives the best signal of how you work. You don&#39;t need to study or perform well under pressure. It also is a two-way street! You get a chance to see how the company really works and how well you fit in. Also, money is nice!&lt;/p&gt;
&lt;h3 id=&quot;things-i-dislike-2&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#things-i-dislike-2&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Things I dislike&lt;/h3&gt;
&lt;p&gt;Contract-to-hire has the highest time commitment by far. It&#39;s just not an option for folks who:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Are on visas&lt;/li&gt;
&lt;li&gt;Are already stretched too thin&lt;/li&gt;
&lt;li&gt;Don&#39;t have a current job and need health insurance&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;they-all-sound-bad-what-should-we-do&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#they-all-sound-bad-what-should-we-do&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; They all sound bad; what should we do?&lt;/h2&gt;
&lt;p&gt;I think switching up the format is the wrong approach. Switching from an on-site to a take-home feels like a lateral move. Instead, companies should focus a lot more on giving candidates the best experience possible. This includes:&lt;/p&gt;
&lt;p&gt;Unconscious bias training.&lt;br /&gt;
Lists of approved questions.&lt;br /&gt;
Asking candidates for feedback on the process.&lt;br /&gt;
Creating an interview rubric.&lt;br /&gt;
Analyze interviewer feedback.&lt;/p&gt;
&lt;p&gt;Let&#39;s dive into a few of these things!&lt;/p&gt;
&lt;h3 id=&quot;unconscious-bias-training&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#unconscious-bias-training&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Unconscious bias training&lt;/h3&gt;
&lt;p&gt;What are unconscious biases?&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Unconscious biases&lt;/strong&gt; are social stereotypes about certain groups of people that individuals form outside their own conscious awareness. Everyone holds unconscious beliefs about various social and identity groups, and these biases stem from one&#39;s tendency to organize social worlds by categorizing.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I&#39;ve worked at a few places that offered bias training for new interviewers, and I found it excellent. A lot of easy tips for helping create a more fair and equitable interview process. I think some sort of &amp;quot;Interviewer training&amp;quot; should be mandatory at medium to large companies. Making sure everyone is representing the company well and helping create a diverse and successful workforce.&lt;/p&gt;
&lt;h3 id=&quot;lists-of-approved-questions&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#lists-of-approved-questions&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Lists of approved questions&lt;/h3&gt;
&lt;p&gt;I could go either way on this one. Lists of coding challenges leak out, end up on Leetcode, and can be a pain to maintain. I still think it&#39;s essential to make sure each question asked is fair and appropriate for the candidate based on the role.&lt;/p&gt;
&lt;h3 id=&quot;asking-candidates-for-feedback&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#asking-candidates-for-feedback&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Asking candidates for feedback&lt;/h3&gt;
&lt;p&gt;This one can be a bit tricky. Candidates are unlikely to give you honest feedback while still waiting for a potential job offer. I&#39;ve seen this done well a few times when companies send out an anonymous survey after the on-site site. Other times recruiters can do a good job convincing you that whatever you say will have no bearing on the interview outcome.&lt;/p&gt;
&lt;p&gt;You could also do this by making sure someone at your company spends time on sites like &lt;a href=&quot;https://glassdoor.com/&quot;&gt;Glassdoor&lt;/a&gt; reading the anonymous feedback.&lt;/p&gt;
&lt;h3 id=&quot;creating-an-interview-rubric&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#creating-an-interview-rubric&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Creating an interview rubric&lt;/h3&gt;
&lt;p&gt;So much can happen in a 45-minute interview. It&#39;s difficult to distill it all down into a &amp;quot;hire&amp;quot; or &amp;quot;no hire&amp;quot; result. I think companies must spend time devising a rubric to help interviewers evaluate candidates. Things like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Did the candidate figure out a brute force solution?&lt;/li&gt;
&lt;li&gt;Was the candidate able to talk through their approach?&lt;/li&gt;
&lt;li&gt;Did the candidate receive feedback well when prompted?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This way, you can collect lots of data and use it to improve your hiring pipeline, interview questions, and expectations.&lt;/p&gt;
&lt;h3 id=&quot;analyze-interviewer-feedback&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#analyze-interviewer-feedback&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Analyze interviewer feedback&lt;/h3&gt;
&lt;p&gt;One of the best parts of devising a rubric and having a list of approved questions is getting a lot of data to learn from! It&#39;s nice to see things like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Average score given by each interviewer (Maybe a 4/5 from one person is the same as a 5/5 from another!)&lt;/li&gt;
&lt;li&gt;Questions that candidates often do poorly on.&lt;/li&gt;
&lt;li&gt;Interviewers candidates enjoy talking to.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;a-note-on-kindness&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-interviewing/#a-note-on-kindness&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; A note on kindness&lt;/h2&gt;
&lt;p&gt;I&#39;ve had the privilege in my career to end up with competing job offers multiple times. While I&#39;d be lying to say that salary and perks didn&#39;t play a role in my decision-making process, I think it&#39;s important to note how important kindness is for me.&lt;/p&gt;
&lt;p&gt;Every time I&#39;ve had a tough decision to make, I&#39;ve chosen to go with the kinder company. A transparent recruiter. A hiring manager who is easy to talk to. A friendly interview panel where it felt like they wanted me to succeed. That makes a huge difference, and so far, I&#39;ve had no regrets about my strategy.&lt;/p&gt;
&lt;p&gt;Be kind!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>The age of the devtool startup</title>
		<link href="https://jonkuperman.com/age-of-the-devtool-startup/"/>
		<updated>2021-06-12T00:00:00Z</updated>
		<id>https://jonkuperman.com/age-of-the-devtool-startup/</id>
		<content type="html">&lt;p&gt;Lately, there has been a trend of brand new startups in the developer tooling space, and I couldn&#39;t be more excited.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;funding-open-source-is-hard&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/age-of-the-devtool-startup/#funding-open-source-is-hard&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Funding open source is hard&lt;/h2&gt;
&lt;p&gt;For years folks have been struggling to get funding for even the most foundational of projects. A few projects like &lt;a href=&quot;https://opencollective.com/webpack&quot;&gt;webpack&lt;/a&gt; and &lt;a href=&quot;https://www.patreon.com/evanyou&quot;&gt;vue.js&lt;/a&gt; have managed to get some recurring money, but most projects struggle.&lt;/p&gt;
&lt;p&gt;Recently a few projects have secured VC funding to continue building their open source dev tools. I know folks are often nervous about VC backed projects, but being able to secure &lt;a href=&quot;https://rome.tools/blog/announcing-rome-tools-inc/&quot;&gt;4.5 million dollars&lt;/a&gt; when historically getting $100k a year has been impossible has me excited.&lt;/p&gt;
&lt;h2 id=&quot;some-examples&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/age-of-the-devtool-startup/#some-examples&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Some examples&lt;/h2&gt;
&lt;p&gt;A few companies I&#39;m particularly excited about:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Replay&lt;/strong&gt; (&lt;a href=&quot;https://replay.io/&quot;&gt;replay.io&lt;/a&gt;) - Replay is a browser that records an entire interaction on your site and produces an artifact that you can debug, share, and comment on. Think of recording a bug on your website and uploading the entire artifact to a GitHub issue for one of your dependencies. Then they can click around, time travel debug, check your source code, and comment to you with their findings!&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Replit&lt;/strong&gt; (&lt;a href=&quot;https://replit.com/&quot;&gt;replit.com&lt;/a&gt;) - Replit started as a collaborative IDE for many different languages but has become so much more. Recently they announced their startup incubator, &lt;a href=&quot;https://blog.replit.com/ventures&quot;&gt;Replit Ventures&lt;/a&gt;, and released their game programming environment &lt;a href=&quot;https://replit.com/kaboom&quot;&gt;Kaboom&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Rome&lt;/strong&gt; (&lt;a href=&quot;https://rome.tools/&quot;&gt;rome.tools&lt;/a&gt;) - Rome is a brand new tool designed to replace Babel, ESLint, webpack, Prettier, and Jest. Instead of each tool bringing its own compiler and requiring swaths of configuration files to glue together, Rome aims to be a single compiler you can use for linting, formatting, compiling, and bundling.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Vercel&lt;/strong&gt; (&lt;a href=&quot;https://vercel.com/&quot;&gt;vercel.com&lt;/a&gt;) - Vercel has been around for a while, but their continued commitment to awesome developer tooling always impresses me. They offer both a place to deploy frontend apps (Vercel), and an open sourced framework for building optimized React applications (&lt;a href=&quot;https://nextjs.org/&quot;&gt;Next.js&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Supabase&lt;/strong&gt; (&lt;a href=&quot;https://supabase.io/&quot;&gt;supabase.io&lt;/a&gt;) - Supabase is an open source alternative to Google&#39;s &lt;a href=&quot;https://firebase.google.com/&quot;&gt;firebase&lt;/a&gt;. It allows you to instantly spin up a backend, giving your project databases, authentication, and realtime APIs.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;i-couldn&#39;t-be-more-excited&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/age-of-the-devtool-startup/#i-couldn&#39;t-be-more-excited&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; I couldn&#39;t be more excited&lt;/h2&gt;
&lt;p&gt;I hope all these great companies bring a considerable improvement in developer tooling and quality of life for working on web engineering projects. I love seeing a wave of free, open source, developer tools, and I especially love the folks behind these tools finding a way to get themselves paid for the great work they do.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>React Aria - A better approach to design systems</title>
		<link href="https://jonkuperman.com/better-approach-design-systems/"/>
		<updated>2021-05-06T00:00:00Z</updated>
		<id>https://jonkuperman.com/better-approach-design-systems/</id>
		<content type="html">&lt;p&gt;Design systems are great. Working at large companies like Adobe, it&#39;s easy to quickly build functional UIs using a robust design system and component library like &lt;a href=&quot;https://react-spectrum.adobe.com/react-spectrum/&quot;&gt;React-Spectrum&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/react-aria.png&quot; alt=&quot;React Aria logo&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;terminology&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/better-approach-design-systems/#terminology&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Terminology&lt;/h2&gt;
&lt;p&gt;For this post, I&#39;ll be referring to the collection of icons, images, fonts, color schemes, and general guidelines as a &lt;strong&gt;design system&lt;/strong&gt; and the actual collection of JavaScript, HTML, and CSS as a &lt;strong&gt;component library&lt;/strong&gt;. Component libraries implement design systems.&lt;/p&gt;
&lt;h2 id=&quot;the-problem-with-component-libraries&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/better-approach-design-systems/#the-problem-with-component-libraries&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The problem with component libraries&lt;/h2&gt;
&lt;p&gt;One issue with most design system component libraries is that they offer two different things in one &amp;quot;take-all or none&amp;quot; package. Component libraries offer:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;A rich UI for elements helping them seamlessly blend in with the design system.&lt;/li&gt;
&lt;li&gt;A lot of functionality to help manage user interactions and normalize browser quirks.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The first offering is great if you&#39;re building something that needs to look like the design system you&#39;re using. For example, if you&#39;re building a mobile web app for Android, then using &lt;a href=&quot;https://material-ui.com/&quot;&gt;Material UI&lt;/a&gt; might be a great library to use. It will make everything look like Google&#39;s &lt;a href=&quot;https://material.io/design&quot;&gt;Material Design&lt;/a&gt;, and you&#39;ll get a ton of free functionality. If you&#39;re building a product that you hope to monetize, maybe having it look like a Google app isn&#39;t what you want.&lt;/p&gt;
&lt;p&gt;This is what makes so many folks unable to use component libraries. Small teams building new products would &lt;strong&gt;love&lt;/strong&gt; to quickly develop their app with all the functionality that a component library like Material UI or React Spectrum provides. But they don&#39;t want their apps looking like an Adobe product.&lt;/p&gt;
&lt;h2 id=&quot;introducing-react-aria&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/better-approach-design-systems/#introducing-react-aria&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Introducing React-ARIA&lt;/h2&gt;
&lt;p&gt;The team behind React Spectrum has been hard at work rewriting their component library over the last few years. One of the coolest things that came of the rewrite is they broke each component out into three pieces—the component&#39;s state, functionality, and rendering logic. They released three separate packages on npm for just this purpose.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/adobe/react-spectrum/tree/main/packages/%40react-spectrum&quot;&gt;@react-spectrum&lt;/a&gt; - The full component. Adobe UI, functionality and state.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/adobe/react-spectrum/tree/main/packages/%40react-stately&quot;&gt;@react-stately&lt;/a&gt; - State management for the component.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/adobe/react-spectrum/tree/main/packages/%40react-aria&quot;&gt;@react-aria&lt;/a&gt; - Accessibility and behavior for the component.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;One of the creators, &lt;a href=&quot;https://twitter.com/devongovett&quot;&gt;Devon Govett&lt;/a&gt; gave a great talk about React Spectrum at React Europe.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=dxDcBB7Xoxs&quot;&gt;https://www.youtube.com/watch?v=dxDcBB7Xoxs&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;prior-art&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/better-approach-design-systems/#prior-art&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Prior art&lt;/h2&gt;
&lt;p&gt;This project reminds me a lot of &lt;a href=&quot;https://github.com/downshift-js/downshift&quot;&gt;Downshift&lt;/a&gt; by &lt;a href=&quot;https://twitter.com/kentcdodds&quot;&gt;Kent C. Dodds&lt;/a&gt;. Downshift provides a set of hooks for Combobox, Select and MultipleSelect.&lt;/p&gt;
&lt;h2 id=&quot;an-example&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/better-approach-design-systems/#an-example&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; An example&lt;/h2&gt;
&lt;p&gt;Let&#39;s check out how these libraries work together using a listbox as an example!&lt;/p&gt;
&lt;p&gt;A listbox is a list of options where a user can select one or more. Here&#39;s what one looks like:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/listbox.gif&quot; alt=&quot;listbox example&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;react-stately&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/better-approach-design-systems/#react-stately&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; React Stately&lt;/h2&gt;
&lt;p&gt;Not incredibly useful on its own, but the @react-stately selection component will return all the props needed to pass into the listbox component so that it can maintain its own state.&lt;/p&gt;
&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; type &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;AriaListBoxProps&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;react-aria&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;Item&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; useListState&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;react-stately&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;mergeProps&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; useFocusRing&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; useListBox&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; useOption&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;react-aria&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; ListBox&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;T&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;(props: AriaListBoxProps&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;T&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Create state based on the incoming props&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; state &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useListState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;props&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// Get props for the listbox element&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; ref &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;useRef&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; listBoxProps&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; labelProps &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useListBox&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;props&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; state&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; ref&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token spread&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;labelProps&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;props&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;label&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt;
        &lt;span class=&quot;token spread&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;listBoxProps&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;ref&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;ref&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token attr-name&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;token literal-property property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token literal-property property&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;5px 0&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token literal-property property&quot;&gt;listStyle&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;none&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token literal-property property&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;1px solid gray&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token literal-property property&quot;&gt;maxWidth&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;250&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token literal-property property&quot;&gt;maxHeight&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token literal-property property&quot;&gt;overflow&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;auto&#39;&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;collection&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
          item&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;section&#39;&lt;/span&gt;
            &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ListBoxSection&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;key&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;section&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
            &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Option&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;key&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;

function Option({ item, state }) &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Get props for the option element&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; ref &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;useRef&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; optionProps&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; isSelected&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; isDisabled &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useOption&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; item&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;key &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    state&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    ref
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// Determine whether we should show a keyboard&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// focus ring for accessibility&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; isFocusVisible&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; focusProps &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useFocusRing&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;
      &lt;span class=&quot;token spread&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;mergeProps&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;optionProps&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; focusProps&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token attr-name&quot;&gt;ref&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;ref&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token attr-name&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; isSelected &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;blueviolet&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;transparent&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; isDisabled &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;#aaa&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; isSelected &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;white&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;2px 5px&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;outline&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; isFocusVisible &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;2px solid orange&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;none&#39;&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;rendered&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ListBox&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Alignment&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;selectionMode&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;single&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Item&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;Left&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Item&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Item&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;Middle&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Item&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Item&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;Right&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Item&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ListBox&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;react-spectrum&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/better-approach-design-systems/#react-spectrum&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; React Spectrum&lt;/h2&gt;
&lt;p&gt;Putting it all together, we could use the top level @react-spectrum library to render a button with all its state and functionality!&lt;/p&gt;
&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; Button &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;@adobe/react-spectrum&quot;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Button&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;variant&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;cta&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;Save&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Button&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;the-great-thing-about-react-aria&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/better-approach-design-systems/#the-great-thing-about-react-aria&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The great thing about React Aria&lt;/h2&gt;
&lt;p&gt;Imagine you&#39;re in the situation described above. You&#39;re building a web application, and you want to make sure it&#39;s robust and accessible, but you don&#39;t want it to look like a Google product.&lt;/p&gt;
&lt;p&gt;React Aria gives you the power to build your custom UI while still getting all of the browser support, accessibility, and functionality of a component library. Imagine building your own custom checkbox and not having to worry about making it accessible because you can simply &lt;code&gt;import {useCheckbox} from &#39;@react-aria/checkbox&#39;&lt;/code&gt; and add the resulting props to your custom element!&lt;/p&gt;
&lt;p&gt;Imagine building a custom button element and not having to worry about a proper focus ring because you can just:&lt;/p&gt;
&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; useFocusRing &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;@react-aria/focus&quot;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Example&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; isFocusVisible&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; focusProps &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useFocusRing&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;
      &lt;span class=&quot;token spread&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;focusProps&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token attr-name&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;WebkitAppearance&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;none&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;appearance&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;none&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;green&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;none&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;white&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;fontSize&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;4px 8px&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;outline&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; isFocusVisible &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;2px solid dodgerblue&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;none&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;outlineOffset&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      Test
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;should-you-use-react-aria&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/better-approach-design-systems/#should-you-use-react-aria&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Should you use React Aria?&lt;/h2&gt;
&lt;p&gt;If you are building a design system, and are not willing to put in the work to make your custom components fully accessible, you should use React Aria! Do you have a custom select component? Does it support browser autocomplete? No? Check out React Aria!&lt;/p&gt;
&lt;h2 id=&quot;the-tldr&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/better-approach-design-systems/#the-tldr&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The TL;DR&lt;/h2&gt;
&lt;p&gt;I look at React Aria, and I think:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Finally, I can bootstrap my app with a component library and not have it look like a Google product!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Are you using React Aria for your component library?&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Exciting movement in JavaScript tooling</title>
		<link href="https://jonkuperman.com/exciting-movement-js-tooling/"/>
		<updated>2021-05-04T00:00:00Z</updated>
		<id>https://jonkuperman.com/exciting-movement-js-tooling/</id>
		<content type="html">&lt;p&gt;It&#39;s been an exciting few months for the JavaScript tooling ecosystem. I&#39;ve never been much good at guessing what&#39;s coming next, but there are a lot of projects that have me very excited.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;First, &lt;a href=&quot;https://www.snowpack.dev/&quot;&gt;Snowpack&lt;/a&gt; launched. Now that JS has a proper &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules&quot;&gt;module system&lt;/a&gt;, you can literally just export and import components with no need for a bundler in modern browsers. Snowpack takes advantage of this by skipping the &amp;quot;bundle&amp;quot; step entirely and just letting you serve your ESM (JS module) components natively.&lt;/p&gt;
&lt;p&gt;Then, &lt;a href=&quot;https://esbuild.github.io/&quot;&gt;esbuild&lt;/a&gt; hit the scene. A JavaScript bundler written in Go that produces bundles at 10x-100x the speed of tools like webpack, Rollup, and parcel. It&#39;s still in the early stages, but playing around with it, it&#39;s a game-changer.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/esbuild.png&quot; alt=&quot;Esbuild states&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Then, the team behind Vue.js came out with an exciting project called &lt;a href=&quot;http://vitejs.dev/&quot;&gt;vite&lt;/a&gt;. You can think of vite like using Snowpack for dev mode and Rollup for production. Vite lets you have lightning-fast rebuilds (no bundling needed) while you&#39;re working and then deploy a proper bundled app to production.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/vite.png&quot; alt=&quot;Vite logo&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As if this week couldn&#39;t get more exciting, the Parcel team &lt;a href=&quot;https://github.com/parcel-bundler/parcel/pull/6230&quot;&gt;rewrote the transformer in Rust&lt;/a&gt;. They are seeing a 10x improvement in speed with the new Rust PR. It looks like it wasn&#39;t just changing languages but a more efficient transform algorithm that helped speed things up!&lt;/p&gt;
&lt;p&gt;But wait, there&#39;s more! Sebastian and Jamie, the team behind Babel and Rome, announced today that they have secured VC funding and are building a company around Rome, their new all-in-one linter/compiler/bundler for JavaScript!&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/sebmck/status/1389609712220528643&quot;&gt;https://twitter.com/sebmck/status/1389609712220528643&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I hope my apps get faster soon. So many amazing people doing amazing work.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Wasted real estate: Blog homepage design</title>
		<link href="https://jonkuperman.com/wasted-real-estate-blog-homepage-design/"/>
		<updated>2021-03-11T00:00:00Z</updated>
		<id>https://jonkuperman.com/wasted-real-estate-blog-homepage-design/</id>
		<content type="html">&lt;p&gt;I&#39;ve started &lt;strong&gt;a lot&lt;/strong&gt; of blogs. Like, a lot. For myself, for friends and family, for companies.&lt;/p&gt;
&lt;p&gt;Most of the time, the analytics for these blogs look something like this:&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/blog-homepage-design.png&quot; alt=&quot;blog homepage design&quot; /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, the large majority of the traffic only ever visits your homepage. So why is it that we fill our homepage with generated content? Think about a generic WordPress theme.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/wordpress-homepage-design.png&quot; alt=&quot;WordPress homepage design&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The main section of the homepage is populated with... a generic list of your most recent posts!? Really? What if your most recent article was a bad one? Just kidding, I&#39;m sure your blog posts are all bangers!&lt;/p&gt;
&lt;p&gt;And then we have the sidebar, more prime real estate! We use that to... display a generated list of categories? I mean, I guess that&#39;s helpful, but it&#39;s hardly the most important thing.&lt;/p&gt;
&lt;p&gt;Seriously though, this is your one shot at wowing your visitor. If your blog was a business and someone walked in and asked what you do there, would you tell them all about the literal last thing you did? Or would you tell them about the coolest and most fun thing your company does? Would you ask for their contact info so maybe you can send them more information?&lt;/p&gt;
&lt;h2 id=&quot;examples-of-great-homepage-designs&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/wasted-real-estate-blog-homepage-design/#examples-of-great-homepage-designs&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Examples of great homepage designs&lt;/h2&gt;
&lt;h3 id=&quot;kalzumeus.com&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/wasted-real-estate-blog-homepage-design/#kalzumeus.com&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; &lt;a href=&quot;http://kalzumeus.com/&quot;&gt;kalzumeus.com&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Someone sent me a link to a blog post on &lt;a href=&quot;https://www.kalzumeus.com/&quot;&gt;kalzumeus.com&lt;/a&gt; the other day, and I was so impressed with their home page.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/amazing-blog-homepage.jpg&quot; alt=&quot;Kalzumeus amazing homepage screenshot&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It starts with a well-written introduction, explaining who they are, how you might know them, and what they are up to. The next thing it does is introduce a curated (again, not generated!) list of their best work.&lt;/p&gt;
&lt;p&gt;It goes on to list their accomplishments and finally, at the very bottom, a list of their most recent articles!&lt;/p&gt;
&lt;h3 id=&quot;theworst.dev&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/wasted-real-estate-blog-homepage-design/#theworst.dev&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; theworst.dev&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/theworstdev&quot;&gt;Kurt&lt;/a&gt; recently redesigned his homepage and I just love it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/theworst-dev-homepage.jpg&quot; alt=&quot;Kurt&#39;s homepage redesign&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Kurt&#39;s blog starts with another heartfelt and well-written introduction. Who he is, what he plans on blogging about, what he&#39;s passionate about, how to find him on social media, etc.&lt;/p&gt;
&lt;p&gt;The next section is my absolute favorite. He literally writes, &amp;quot;If you only read one post, you should read this one.&amp;quot; and then manually (NOT auto-generated) picks his favorite blog post and highlights it front and center.&lt;/p&gt;
&lt;p&gt;Then it goes on to highlight all of the things he is working on. At the time of this writing, it shows two podcasts he was recently on and an interview.&lt;/p&gt;
&lt;h3 id=&quot;christopherbiscardi.com&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/wasted-real-estate-blog-homepage-design/#christopherbiscardi.com&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; &lt;a href=&quot;http://christopherbiscardi.com/&quot;&gt;christopherbiscardi.com&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Another one of my absolute favorites is &lt;a href=&quot;https://www.christopherbiscardi.com/&quot;&gt;christopherbiscardi.com&lt;/a&gt;. Christopher is a master at information architecture and telling a story with his homepage design. First of all, just look at it!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/christopherbiscardi-blog-homepage-design.jpg&quot; alt=&quot;Christopher&#39;s blog homepage&quot; /&gt;&lt;/p&gt;
&lt;p&gt;No wasted space here!&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;✅ Well-written introduction&lt;/li&gt;
&lt;li&gt;✅ Social media links&lt;/li&gt;
&lt;li&gt;✅ Hand made content groupings (his field guides)&lt;/li&gt;
&lt;li&gt;✅ Check out a cool framework he made&lt;/li&gt;
&lt;li&gt;✅ Sign up for his newsletter&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Boom.&lt;/p&gt;
&lt;h2 id=&quot;what-does-your-homepage-say-about-you&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/wasted-real-estate-blog-homepage-design/#what-does-your-homepage-say-about-you&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What does your homepage say about you?&lt;/h2&gt;
&lt;p&gt;Have you spent time configuring your homepage? Or do you let your blogging engine dictate what shows up on there? Do you think it would be a good spend of time to configure it yourself?&lt;/p&gt;
&lt;p&gt;Want to get early access to all of my posts? Sign up for the newsletter below and never miss an update! 😅👇&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>On leaving a great job</title>
		<link href="https://jonkuperman.com/on-leaving-a-great-job/"/>
		<updated>2021-02-26T00:00:00Z</updated>
		<id>https://jonkuperman.com/on-leaving-a-great-job/</id>
		<content type="html">&lt;p&gt;A bit of personal news, today is my last day at Adobe.&lt;/p&gt;
&lt;p&gt;I&#39;ve had such a fantastic run at Adobe. The people are just incredible. I got to work on so many cool products across the Creative Cloud. I worked on web apps, desktop apps, services, shared components, contributed to our design system and helped lead three amazing projects.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;So, why am I leaving?&lt;/p&gt;
&lt;p&gt;For the first time in my career, I&#39;m struggling with burnout. Really struggling.&lt;/p&gt;
&lt;h2 id=&quot;one-heck-of-a-year&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-leaving-a-great-job/#one-heck-of-a-year&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; One heck of a year&lt;/h2&gt;
&lt;p&gt;2020 was rough for so many people. I moved from San Francisco to Florida at the end of 2019. I hardly knew anyone in my new state but had an enjoyable few months exploring before the coronavirus hit. The lockdowns, anxiety about loved ones catching the virus and social and political unrest have all been taking their toll. I&#39;ve always struggled with anxiety, but this last year it has been a constant burden.&lt;/p&gt;
&lt;p&gt;On top of that, my team took on an ambitious project at the beginning of 2020. We are building something brand new on a stack that&#39;s never been used before. Scoping the work, building up a team, and struggling to hit a deadline have also taken their toll.&lt;/p&gt;
&lt;p&gt;The last year has left me struggling to be productive. My team has been great about supporting me through a tough time, but I can sometimes be my own harshest critic, and this year has left me feeling upset and disappointed with myself.&lt;/p&gt;
&lt;h2 id=&quot;the-goodbyes-have-been-hard&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-leaving-a-great-job/#the-goodbyes-have-been-hard&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The goodbyes have been hard&lt;/h2&gt;
&lt;p&gt;I decided to leave a few months ago and began working on an exit plan with my manager. Since deciding to go, I haven&#39;t questioned whether it was the correct choice, but saying goodbye has been more difficult than anticipated. It&#39;s a special place, and the Creative Cloud org is full of incredible people.&lt;/p&gt;
&lt;h2 id=&quot;what&#39;s-next-(short-term)&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-leaving-a-great-job/#what&#39;s-next-(short-term)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What&#39;s next (short term)&lt;/h2&gt;
&lt;p&gt;I haven&#39;t dealt with burnout before. Fortunately, moving to a low cost of living city last year, I&#39;m able to take some time off. I will work on my mental health, physical health, and finding some technologies that get me motivated again!&lt;/p&gt;
&lt;p&gt;I&#39;m going to try hard not to work on anything serious for the first few weeks. I want to catch up on sleep and get into a better exercise routine.&lt;/p&gt;
&lt;h2 id=&quot;what&#39;s-next-(medium-term)&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-leaving-a-great-job/#what&#39;s-next-(medium-term)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What&#39;s next (medium term)&lt;/h2&gt;
&lt;p&gt;After taking a few weeks off, I&#39;d like to find some open source projects to contribute to. I&#39;m particularly interested in:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Compilers&lt;/li&gt;
&lt;li&gt;Bundlers&lt;/li&gt;
&lt;li&gt;Type Systems&lt;/li&gt;
&lt;li&gt;Programming Languages&lt;/li&gt;
&lt;li&gt;Web Performance&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you work on something like that and would be down to trade my time for your mentorship, hit me up!&lt;/p&gt;
&lt;h2 id=&quot;what&#39;s-next-(long-term)&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-leaving-a-great-job/#what&#39;s-next-(long-term)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What&#39;s next (long term)&lt;/h2&gt;
&lt;p&gt;While I&#39;m not looking for work right now, if you&#39;re doing something awesome and you think I&#39;d make a good fit, I&#39;d love to chat about it! COVID has been difficult socially, so even if you&#39;re not doing something awesome and think I&#39;d be a terrible fit; I&#39;d still love to chat sometime 😅. I really miss hanging out with people.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/on-leaving-a-great-job/#conclusion&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Conclusion&lt;/h2&gt;
&lt;p&gt;I&#39;m extremely sad to be leaving what is probably the best job I&#39;ve ever had. I&#39;ve grown so much at Adobe and could not have asked for a better team. If you&#39;re looking for a great place to work on a unique set of products, I highly recommend applying at Adobe.&lt;/p&gt;
&lt;p&gt;That&#39;s all for now. Going to take some time to work on being healthier. Hopefully, I&#39;ll have some success and be back doing fun tech stuff soon!&lt;/p&gt;
&lt;p&gt;♥️&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Best online node js editor</title>
		<link href="https://jonkuperman.com/best-online-node-js-editor/"/>
		<updated>2021-02-24T00:00:00Z</updated>
		<id>https://jonkuperman.com/best-online-node-js-editor/</id>
		<content type="html">&lt;p&gt;Online node js editors have come a long way in the last few years! A few years ago, I would have recommended against using an online editor. I would have said you should install Node js locally instead. But that&#39;s no longer true.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Out of all the node js editors, there are two clear standouts.&lt;/p&gt;
&lt;h2 id=&quot;replit&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-online-node-js-editor/#replit&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Replit&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/replit-node-js-editor.png&quot; alt=&quot;Replit online editor&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;replit-is:&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-online-node-js-editor/#replit-is:&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Replit is:&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A free, collaborative, in-browser IDE to code in 50+ languages — without spending a second on setup.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href=&quot;https://repl.it/&quot;&gt;Replit&lt;/a&gt; is my go-to for any online server-side language editor. The interface is clean, the UI is snappy, and it supports so many languages. The online node js support is top-notch, and you can easily collaborate with friends! You can even deploy your node js app via Replit and share it with the world!&lt;/p&gt;
&lt;h2 id=&quot;codesandbox&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-online-node-js-editor/#codesandbox&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; CodeSandbox&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/codesandbox-node-js-editor.png&quot; alt=&quot;CodeSandbox best online node js editor&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;codesandbox-is:&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-online-node-js-editor/#codesandbox-is:&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; CodeSandBox is:&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Where teams build faster, together. Create, share, and get feedback with collaborative sandboxes for rapid web development.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I still remember what a gamechanger it was when &lt;a href=&quot;https://codesandbox.io/&quot;&gt;CodeSandbox&lt;/a&gt; came on the scene. It allows you to instantly create React, Angular, Vue, Svelte, and Vanilla JS apps.&lt;/p&gt;
&lt;p&gt;You can add &lt;a href=&quot;https://www.npmjs.com/&quot;&gt;npm&lt;/a&gt; packages (even private ones). You can whip up a React project with all your actual dependencies and share an idea with the world!&lt;/p&gt;
&lt;p&gt;They also have great support for node js editing. Quickly create a Node js HTTP server and share it with friends or use it for a demo!&lt;/p&gt;
&lt;h2 id=&quot;which-online-editor-is-best&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-online-node-js-editor/#which-online-editor-is-best&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Which online editor is best?&lt;/h2&gt;
&lt;p&gt;If I had to choose, I&#39;d say the best currently online node js editor is Replit. It&#39;s free, fast, and accessible. You can build or prototype anything you want and easily share it. Plus it offers support for so many languages.&lt;/p&gt;
&lt;p&gt;Some other apps offer a Node js repl, but none have the quality or accessibility of Replit and CodeSandbox.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>jquery vs node.js</title>
		<link href="https://jonkuperman.com/jquery-vs-node-js/"/>
		<updated>2021-02-23T00:00:00Z</updated>
		<id>https://jonkuperman.com/jquery-vs-node-js/</id>
		<content type="html">&lt;p&gt;JavaScript has a vast ecosystem. Someone asked me on Twitter yesterday, what is the difference between jquery vs. node.js? They are very different technologies! It helps to take a step back and look at the entire JS ecosystem to explain the difference.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;To make things even more complicated, JavaScript can run in the browser, on the server, or even on embedded devices! Running in so many different environments confuses people because it&#39;s challenging to separate JavaScript the language from a JavaScript platform.&lt;/p&gt;
&lt;h2 id=&quot;javascript-the-language&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/jquery-vs-node-js/#javascript-the-language&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; JavaScript the language&lt;/h2&gt;
&lt;p&gt;JavaScript, the language, came from humble origins. It was created in 1995 by Netscape and was initially named &amp;quot;Mocha.&amp;quot; It saw rapid adoption in the first few years and was in clear need of management!&lt;/p&gt;
&lt;h2 id=&quot;ecmascript&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/jquery-vs-node-js/#ecmascript&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; ECMAScript&lt;/h2&gt;
&lt;p&gt;There is this incredible group called &lt;a href=&quot;https://www.ecma-international.org/&quot;&gt;Ecma International&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Ecma International is an industry association dedicated to the standardization of information and communication systems.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;They help you form a standards body around a technology so members and vendors can join and help shape its future.&lt;/p&gt;
&lt;p&gt;In 1997, two years after Netscape created the language, they partnered with ECMA. They formed ECMAScript, an official body of language contributors and vendors (like web browsers) who meet and decide on JavaScript&#39;s future together.&lt;/p&gt;
&lt;h2 id=&quot;jquery&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/jquery-vs-node-js/#jquery&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; jQuery&lt;/h2&gt;
&lt;p&gt;Flash forward ten years. ECMAScript is &lt;a href=&quot;https://auth0.com/blog/the-real-story-behind-es4/&quot;&gt;struggling&lt;/a&gt; to launch a new release of the language. Many of the browsers have given up and started creating their own, non-standard APIs. Web development is becoming increasingly difficult.&lt;/p&gt;
&lt;p&gt;An engineer named &lt;a href=&quot;https://twitter.com/jeresig&quot;&gt;John Resig&lt;/a&gt; creates a JavaScript framework called &lt;a href=&quot;https://jquery.com/&quot;&gt;jQuery&lt;/a&gt;. At its core, it&#39;s a bunch of JavaScript helper functions that hide away all the if/else checks web developers have to do between the browsers. It lets us add events, grab DOM elements, and make AJAX calls.&lt;/p&gt;
&lt;p&gt;jQuery becomes ubiquitous for web development. Over the next ten years, it remains the gold standard for doing JavaScript work!&lt;/p&gt;
&lt;h2 id=&quot;node.js&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/jquery-vs-node-js/#node.js&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Node.js&lt;/h2&gt;
&lt;p&gt;Around the same time, an engineer named Ryan Dahl announced an exciting project he had been working on. He called it &lt;a href=&quot;https://nodejs.org/en/&quot;&gt;Node.js&lt;/a&gt; and it is a:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;To simplify, it allowed you to run JavaScript on the server! Previously JavaScript had only ever been used for front-end applications. Node.js took &lt;a href=&quot;https://v8.dev/&quot;&gt;v8&lt;/a&gt;, Chrome&#39;s JavaScript engine out of Chrome, and turned it into a fast and exciting web server.&lt;/p&gt;
&lt;h2 id=&quot;jquery-vs-node.js&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/jquery-vs-node-js/#jquery-vs-node.js&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; jQuery vs node.js&lt;/h2&gt;
&lt;p&gt;While both technically use the JavaScript language. While jQuery is a front-end library that makes writing DOM selectors, event handlers, and AJAX easier to write cross-browser, node.js is a back-end runtime that lets you replace your Python, Ruby, or Java server with JavaScript!&lt;/p&gt;
&lt;p&gt;The cool thing is that getting good with the JavaScript syntax will make you extra powerful now that you can use it for your back-end server and your front-end application!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Stable Node Versions</title>
		<link href="https://jonkuperman.com/stable-node/"/>
		<updated>2021-02-22T00:00:00Z</updated>
		<id>https://jonkuperman.com/stable-node/</id>
		<content type="html">&lt;p&gt;If you&#39;re looking to find stable node versions, head over to &lt;a href=&quot;https://nodejs.org/en/&quot;&gt;nodejs.org&lt;/a&gt; and look for the button on the left side. That will always point to the current LTS (Long Term Support) version which you can download.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/stable-node-versions.png&quot; alt=&quot;node stable version website&quot; /&gt;&lt;/p&gt;
&lt;p&gt;LTS versions of stable node mean they will get critical bug fixes for &lt;strong&gt;30 months&lt;/strong&gt;. You can read more on the &lt;a href=&quot;https://nodejs.org/en/about/releases/&quot;&gt;node.js releases page&lt;/a&gt; which says:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Major Node.js versions enter Current release status for six months, which gives library authors time to add support for them. After six months, odd-numbered releases (9, 11, etc.) become unsupported, and even-numbered releases (10, 12, etc.) move to Active LTS status and are ready for general use. LTS release status is &amp;quot;long-term support&amp;quot;, which typically guarantees that critical bugs will be fixed for a total of 30 months. Production applications should only use Active LTS or Maintenance LTS releases.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;using-the-&amp;quot;n&amp;quot;-node-module-for-stable-node-versions&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/stable-node/#using-the-%22n%22-node-module-for-stable-node-versions&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Using the &amp;quot;n&amp;quot; node module for stable node versions&lt;/h2&gt;
&lt;p&gt;Another approach you could take is to install the &lt;a href=&quot;https://www.npmjs.com/package/n&quot;&gt;n module&lt;/a&gt; which helps you &amp;quot;Interactively Manage Your Node.js Versions&amp;quot;. It also comes with a stable command so you can simply run:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-g&lt;/span&gt; n
n stable&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	<entry>
		<title>Get React Version</title>
		<link href="https://jonkuperman.com/get-react-version/"/>
		<updated>2021-02-22T00:00:00Z</updated>
		<id>https://jonkuperman.com/get-react-version/</id>
		<content type="html">&lt;p&gt;Looking to get react version from one of your apps? You have a few different options!&lt;/p&gt;
&lt;h2 id=&quot;get-react-version-in-code&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/get-react-version/#get-react-version-in-code&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Get React Version in code&lt;/h2&gt;
&lt;p&gt;If you&#39;re already in the JavaScript, you can print the current React version by doing:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; version &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;react&quot;&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;version&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;This also works with the require syntax:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; React &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;react&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; version &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;version

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;version&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can also check your &lt;code&gt;package-lock.json&lt;/code&gt; or &lt;code&gt;yarn.lock&lt;/code&gt; file!&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;cat&lt;/span&gt; package-lock.json &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;&quot;react&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;&quot; &lt;span class=&quot;token parameter variable&quot;&gt;-A&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or, if you are using Yarn:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;cat&lt;/span&gt; yarn.lock &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;&quot;react&lt;span class=&quot;token punctuation&quot;&gt;&#92;&lt;/span&gt;&quot; &lt;span class=&quot;token parameter variable&quot;&gt;-A&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	<entry>
		<title>How to update node js</title>
		<link href="https://jonkuperman.com/how-to-update-node-js/"/>
		<updated>2021-02-21T00:00:00Z</updated>
		<id>https://jonkuperman.com/how-to-update-node-js/</id>
		<content type="html">&lt;p&gt;Want to learn how to update node js? It really depends on &lt;strong&gt;how&lt;/strong&gt; you installed it in the first place! Let&#39;s look at your options:&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;option-1-(recommended)-nvm&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/how-to-update-node-js/#option-1-(recommended)-nvm&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Option 1 (recommended) - NVM&lt;/h2&gt;
&lt;p&gt;The absolutely best way to install node js (and update node js later) is to use the &lt;a href=&quot;https://github.com/nvm-sh/nvm&quot;&gt;Node Version Manager&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This will work even if you already have Node js installed some other way. You can just open up a terminal and run:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;bash&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note: For any installation help, check out their &lt;a href=&quot;https://github.com/nvm-sh/nvm/blob/master/README.md&quot;&gt;official README&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And then run `nvm install YOUR-VERSION-OF-NODE. For example:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;nvm &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; v15.9.0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then set it to default by using:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;nvm &lt;span class=&quot;token builtin class-name&quot;&gt;alias&lt;/span&gt; default v15.9.0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And you are good to go!&lt;/p&gt;
&lt;h2 id=&quot;option-2-official-installer&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/how-to-update-node-js/#option-2-official-installer&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Option 2 - Official Installer&lt;/h2&gt;
&lt;p&gt;You can head over to the &lt;a href=&quot;https://nodejs.org/en/&quot;&gt;Node js website&lt;/a&gt; and grab either the latest LTS (Long Term Support) build or the absolutely latest release. If the version you want to update to is not on there you can view their &lt;a href=&quot;https://nodejs.org/en/about/releases/&quot;&gt;releases page&lt;/a&gt; and if you have a different operating system you can find the download you need on their &lt;a href=&quot;https://nodejs.org/en/download/&quot;&gt;download page&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/how-to-update-node-js/#conclusion&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Conclusion&lt;/h2&gt;
&lt;p&gt;If you are looking for how to update node js, I really recommend taking a few minutes out of your day and moving over to the Node Version Manager. That way future updates will be a breeze! But if you need a specific binary version and don&#39;t want to use NVM. Feel free to check out the releases page above!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>JavaScript if else syntax</title>
		<link href="https://jonkuperman.com/javascript-if-else/"/>
		<updated>2021-02-20T00:00:00Z</updated>
		<id>https://jonkuperman.com/javascript-if-else/</id>
		<content type="html">&lt;p&gt;If you&#39;re looking for the JavaScript if else or if, else, else-if syntax - look no further!&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/javascript-if-else.png&quot; alt=&quot;JavaScript If Else Logo&quot; /&gt;&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// This one will log&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Inside the if condition&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Inside the else condition&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want an if, else, else-if condition in JavaScript it looks like:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Inside the if condition&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// This one will log&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Inside the else-if condition&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Inside the else condition&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	<entry>
		<title>Increase Gatsby performance with Webpack Bundle Analyzer</title>
		<link href="https://jonkuperman.com/increase-gatsby-performance-webpack-bundle-analyzer/"/>
		<updated>2021-02-16T00:00:00Z</updated>
		<id>https://jonkuperman.com/increase-gatsby-performance-webpack-bundle-analyzer/</id>
		<content type="html">&lt;p&gt;I&#39;ve been using webpack bundle analyzer a lot lately.&lt;/p&gt;
&lt;p&gt;Over the past few days, it started to feel a little sluggish when I would refresh. I remember when I first launched this version of the site on &lt;a href=&quot;https://www.gatsbyjs.com/&quot;&gt;Gatsby&lt;/a&gt; and &lt;a href=&quot;https://www.netlify.com/&quot;&gt;Netlify&lt;/a&gt; it felt lightning fast!&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;measuring-gatsby-page-performance-with-webpack-bundle-analyzer&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/increase-gatsby-performance-webpack-bundle-analyzer/#measuring-gatsby-page-performance-with-webpack-bundle-analyzer&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Measuring Gatsby Page Performance with Webpack bundle analyzer&lt;/h2&gt;
&lt;p&gt;Before I started diving in, I just wanted to see if I was correct that it had slowed down. I started up a production build on my local machine by running:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;gatsby build
gatsby serve&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next I went to &lt;code&gt;https://localhost:9000&lt;/code&gt; (my gatsby dev server running in prod mode) and opened it in an Incognito* tab.&lt;/p&gt;
&lt;p&gt;* This is important because browser extensions can really mess with the DevTools. If you want to get a fair audit, disable all your extensions or open the page in an Incognito window.&lt;/p&gt;
&lt;p&gt;I went to the Network tab and did a refresh. Here&#39;s what I saw:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/gatsby-performance-before.png&quot; alt=&quot;Gatsby site performance before fix&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Really not great. I mean, not bad for a big feature rich application but this is just a simple blog. I swear it wasn&#39;t taking that long to load a few days ago!&lt;/p&gt;
&lt;h2 id=&quot;analyzing-your-webpack-bundle&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/increase-gatsby-performance-webpack-bundle-analyzer/#analyzing-your-webpack-bundle&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Analyzing your Webpack bundle&lt;/h2&gt;
&lt;p&gt;I knew my site was loading slow. And I knew that the culprit must be too much JavaScript. But what was causing it? Where was all that JS coming from?&lt;/p&gt;
&lt;p&gt;There is this amazing tool called &lt;a href=&quot;https://www.npmjs.com/package/webpack-bundle-analyzer&quot;&gt;Webpack Bundle Analyzer&lt;/a&gt;. It hooks into your Webpack build and displays a really nice UI showing you all the stuff inside your bundle and how big it is!&lt;/p&gt;
&lt;p&gt;Luckily for me, someone already made a &lt;a href=&quot;https://www.gatsbyjs.com/plugins/gatsby-plugin-webpack-bundle-analyser-v2/&quot;&gt;Gatsby plugin&lt;/a&gt; that sets Webpack Bundle Analyzer up for me! So all I had to do was&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; i gatsby-plugin-webpack-bundle-analyser-v2 &lt;span class=&quot;token parameter variable&quot;&gt;-D&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then add it to my plugins list in my &lt;code&gt;gatsby-config.js&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;exports &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;plugins&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;gatsby-plugin-webpack-bundle-analyser-v2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I ran &lt;code&gt;gatsby build&lt;/code&gt; again and this is what I saw:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/webpack-bundle-analyzer.png&quot; alt=&quot;Webpack bundle analyzer output&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Yikes. What is Lottie!? It&#39;s taking up so much space and I don&#39;t remember installing anything by that name.&lt;/p&gt;
&lt;h3 id=&quot;npm-ls&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/increase-gatsby-performance-webpack-bundle-analyzer/#npm-ls&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; npm ls&lt;/h3&gt;
&lt;p&gt;Fortunately again, npm provides an awesome tool where you can give it a package name and it will tell you why that package is in your &lt;code&gt;node_modules&lt;/code&gt;. So, for Lottie which we can see in the image above has a package name of &amp;quot;lottie-web&amp;quot;, you can type:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; lottie-web&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And I got:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;☁  jonkuperman.com &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;master&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; ⚡ &lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ls&lt;/span&gt; lottie-web
jonkuperman@0.1.0 /Users/kuperman/workspace/jonkuperman.com
└─┬ react-dark-mode-toggle@0.0.10
  └─┬ lottie-react-web@2.2.2
    └── lottie-web@5.7.6&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Oh no! My favorite new &lt;a href=&quot;https://www.npmjs.com/package/react-dark-mode-toggle&quot;&gt;React component&lt;/a&gt; is slowing down my website with it&#39;s amazing animations and beautiful icons.&lt;/p&gt;
&lt;p&gt;I could remove it. Replace it with a simple button like I used to have. But I really like it.&lt;/p&gt;
&lt;h2 id=&quot;gatsby-code-splitting&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/increase-gatsby-performance-webpack-bundle-analyzer/#gatsby-code-splitting&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Gatsby Code Splitting&lt;/h2&gt;
&lt;p&gt;Gatsby uses React and Webpack. Webpack supports a feature called &lt;a href=&quot;https://webpack.js.org/guides/code-splitting/&quot;&gt;code splitting&lt;/a&gt; which is, according to their site:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Code splitting is one of the most compelling features of webpack. This feature allows you to split your code into various bundles which can then be loaded on demand or in parallel. It can be used to achieve smaller bundles and control resource load prioritization which, if used correctly, can have a major impact on load time.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That sounds like exactly what we need. Fortunately for us, the React team has already worked with the Webpack team and come up with a syntax that tells the bundler to split out an import and load it asynchronously. It&#39;s called &lt;a href=&quot;https://reactjs.org/docs/code-splitting.html&quot;&gt;React.lazy&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I went to my Header component, which contains the dark mode toggle (which contains lottie!) and it looked like this (simplified):&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; React &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;react&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; DarkModeToggle &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;react-dark-mode-toggle&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;Header&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;props&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
      &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;div className&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;navigation&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
        &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;DarkModeToggle &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
      &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;div&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
    &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;All I had to do was switch it to the &lt;code&gt;React.lazy&lt;/code&gt; syntax and Gatsby/React/Webpack would take care of the rest! The new syntax looks like:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; Suspense &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;react&quot;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// React.lazy syntax for importing&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; DarkModeToggle &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;lazy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;react-dark-mode-toggle&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;Header&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;props&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
      &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;div className&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;navigation&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;/* a cool syntax for specifying what HTML to display
                while the component is loading*/&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Suspense fallback&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;Loading&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;div&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
          &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;DarkModeToggle &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
        &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;Suspense&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
      &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;div&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
    &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now if we load our site again we should see 1 more Network request than we had before and for a split second we should see &amp;quot;Loading...&amp;quot; before the DarkModeToggle comes into view.&lt;/p&gt;
&lt;p&gt;The upside though is that our site loads quite a bit faster!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/gatsby-performance-after.png&quot; alt=&quot;Gatsby site performance after fix&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Looks like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The Finish time went from 772ms to 236ms.&lt;/li&gt;
&lt;li&gt;DOMContentLoaded went from 222ms to 36ms!&lt;/li&gt;
&lt;li&gt;The Load time went from 530ms to 193ms.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;conclusion&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/increase-gatsby-performance-webpack-bundle-analyzer/#conclusion&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Conclusion&lt;/h2&gt;
&lt;p&gt;If you&#39;re adding a bunch of dependencies and your Gatsby site gets slow:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Check the Network tab in the DevTools to make sure it&#39;s actually slow.&lt;/li&gt;
&lt;li&gt;Install webpack-bundle-analyzer and run it against your site.&lt;/li&gt;
&lt;li&gt;Run npm ls package-name to figure out where any surprise packages are coming from.&lt;/li&gt;
&lt;li&gt;Wrap any big React Components that you don&#39;t need on page load in &lt;code&gt;React.lazy&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
</content>
	</entry>
	
	<entry>
		<title>Setting up Gatsby Webmentions on your site</title>
		<link href="https://jonkuperman.com/gatsby-webmentions/"/>
		<updated>2021-02-14T00:00:00Z</updated>
		<id>https://jonkuperman.com/gatsby-webmentions/</id>
		<content type="html">&lt;p&gt;I spent a lot of Sunday... ok pretty much &lt;strong&gt;all&lt;/strong&gt; of Sunday setting up Webmentions on my Gatsby site so when people Tweet about my blog posts they show up like comments!&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/jkup/status/1360786533280800775&quot;&gt;https://twitter.com/jkup/status/1360786533280800775&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;There are already quite a few articles on how to do this but I still got pretty stuck along the way so I figured I&#39;d write another one.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;tldr&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-webmentions/#tldr&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; TL;DR&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Make an account at &lt;a href=&quot;https://webmention.io/&quot;&gt;webmention.io&lt;/a&gt;. Link it to your Twitter account. This means making one of those &lt;code&gt;rel=&amp;quot;me&amp;quot;&lt;/code&gt; links like they suggest!&lt;/li&gt;
&lt;li&gt;Make a &lt;a href=&quot;https://brid.gy/&quot;&gt;Bridgy&lt;/a&gt; account. Link it to your Twitter as well.&lt;/li&gt;
&lt;li&gt;Install this awesome &lt;a href=&quot;https://github.com/ChristopherBiscardi/gatsby-plugin-webmention&quot;&gt;Gatsby Plugin&lt;/a&gt;. Follow the instructions in the README and get your &amp;quot;token&amp;quot; from the &lt;a href=&quot;http://webmention.io/&quot;&gt;webmention.io&lt;/a&gt; page above.&lt;/li&gt;
&lt;li&gt;Copy literally all of my code from &lt;a href=&quot;https://github.com/jkup/jonkuperman.com/blob/a3b7417af6b3db4197eba3d85efc6c381327b9f0/src/utils/webmentions.js&quot;&gt;this file&lt;/a&gt;. Don&#39;t feel bad! I stole most of it from &lt;a href=&quot;https://twitter.com/mxstbr&quot;&gt;Max Stoiber&lt;/a&gt;. DO NOT TELL MAX.&lt;/li&gt;
&lt;li&gt;In your &lt;code&gt;blog-post.js&lt;/code&gt; file, import the util you just copy/pasted and call it (example below).&lt;/li&gt;
&lt;li&gt;Copy &lt;a href=&quot;https://github.com/jkup/jonkuperman.com/blob/a3b7417af6b3db4197eba3d85efc6c381327b9f0/src/components/global.css#L446&quot;&gt;my CSS&lt;/a&gt; too if you want! I stole that from a &lt;strong&gt;different&lt;/strong&gt; person named &lt;a href=&quot;https://twitter.com/mxbck&quot;&gt;Max&lt;/a&gt;!&lt;/li&gt;
&lt;li&gt;Instead of running &lt;code&gt;yarn develop&lt;/code&gt; or &lt;code&gt;npm run develop&lt;/code&gt; you now have to run &lt;code&gt;WEBMENTIONS_TOKEN=YOUR_TOKEN npm run develop&lt;/code&gt;. This is your life now. Update your deploy target too like your Netlify ENV variables or whatever.&lt;/li&gt;
&lt;li&gt;Profit.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// blog-post.js&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; WebMentions &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;../utils/webmentions.js&quot;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;WebMentions url&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;location&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;href&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;prior-art&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-webmentions/#prior-art&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Prior art&lt;/h2&gt;
&lt;p&gt;I was only able to figure this out because of some amazing blog posts. I&#39;m only writing this post because I still managed to struggle to get things working so I&#39;m hoping this might be helpful to someone.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;This &lt;a href=&quot;https://github.com/aarongustafson/jekyll-webmention_io&quot;&gt;Jekyll Webmention Plugin&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;This &lt;a href=&quot;https://mxb.dev/blog/using-webmentions-on-static-sites/&quot;&gt;post&lt;/a&gt; on setting up Webmentions with Eleventy&lt;/li&gt;
&lt;li&gt;This &lt;a href=&quot;https://www.swyx.io/clientside-webmentions/&quot;&gt;post&lt;/a&gt; on setting up Webmentions with Svelte&lt;/li&gt;
&lt;li&gt;Some &lt;a href=&quot;https://github.com/mxstbr/mxstbr.com/blob/49aceb93a43d1e87736f204f26c07e203cb2a0e1/components/WebMentions/WebMentionCounts.js&quot;&gt;code&lt;/a&gt; I stole from Max Stoiber that no longer works but is super close to working!&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://www.w3.org/TR/webmention/&quot;&gt;Webmention Spec&lt;/a&gt; haha jk I didn&#39;t read the spec&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;tools-we&#39;ll-need&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-webmentions/#tools-we&#39;ll-need&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Tools we&#39;ll need&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://brid.gy/&quot;&gt;brid.gy&lt;/a&gt;. This site uses social network APIs to find all mentions of your site and generate Webmentions for each mention.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://webmention.io/&quot;&gt;webmention.io&lt;/a&gt;. A free, hosted service that receives and stores all the Webmentions Bridgy sends. This will also act as the API for our static Gatsby site!&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/ChristopherBiscardi/gatsby-plugin-webmention&quot;&gt;gatsby-plugin-webmention&lt;/a&gt;. You can totally configure Webmentions yourself. You have to add some &amp;lt;link&amp;gt;`s to the &amp;lt;head&amp;gt; and configure your social network handles but &lt;strong&gt;also&lt;/strong&gt; you can just install this handy plugin by &lt;a href=&quot;https://twitter.com/chrisbiscardi&quot;&gt;Chris&lt;/a&gt; and save yourself the trouble!&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;the-basic-idea&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-webmentions/#the-basic-idea&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The basic idea&lt;/h2&gt;
&lt;p&gt;At a high level, we want to set up &lt;a href=&quot;https://brid.gy/&quot;&gt;brid.gy&lt;/a&gt; to watch Twitter for any tweets that mention our blog! When it finds one, it will send a Webmention to our site which &lt;a href=&quot;https://webmention.io/&quot;&gt;webmention.io&lt;/a&gt; will see and add to it&#39;s database! That way, in client-side JavaScript we can hit &lt;a href=&quot;https://webmention.io/&quot;&gt;webmention.io&lt;/a&gt; and give it a certain post and it will return to us all of the &amp;quot;likes&amp;quot; and &amp;quot;mentions&amp;quot; for that post which we can display however we want!&lt;/p&gt;
&lt;h2 id=&quot;the-implementation&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-webmentions/#the-implementation&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The implementation&lt;/h2&gt;
&lt;h3 id=&quot;1.-setting-up-third-party-services&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-webmentions/#1.-setting-up-third-party-services&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 1. Setting up third party services&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Register our &lt;a href=&quot;https://brid.gy/&quot;&gt;brid.gy&lt;/a&gt; and &lt;a href=&quot;https://webmention.io/&quot;&gt;webmention.io&lt;/a&gt; accounts. For &lt;a href=&quot;http://webmention.io/&quot;&gt;webmention.io&lt;/a&gt; you have to add a twitter link to your site with the &lt;code&gt;rel=&amp;quot;me&amp;quot;&lt;/code&gt; attribute.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you get stuck on setting these up please &lt;a href=&quot;https://twitter.com/intent/tweet/?text=@jkup%20how%20could%20you&quot;&gt;holler at me!&lt;/a&gt; and I&#39;ll update this post.&lt;/p&gt;
&lt;h3 id=&quot;2.-configuring-our-gatsby-site&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-webmentions/#2.-configuring-our-gatsby-site&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 2. Configuring our Gatsby site&lt;/h3&gt;
&lt;p&gt;The easiest way to do this is to copy your auth token from &lt;a href=&quot;https://webmention.io/&quot;&gt;webmention.io&lt;/a&gt;, install &lt;a href=&quot;https://github.com/ChristopherBiscardi/gatsby-plugin-webmention&quot;&gt;gatsby-plugin-webmention&lt;/a&gt; and then copy paste the config file from the README and add it to your &lt;strong&gt;gatsby-config.js&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The other option is you can log into &lt;a href=&quot;http://webmention.io/&quot;&gt;webmention.io&lt;/a&gt; and go to &lt;a href=&quot;https://webmention.io/settings&quot;&gt;settings&lt;/a&gt; where you&#39;ll get 2 links to copy/paste into your site&#39;s head tag. For example, mine look like:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;link rel&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;webmention&quot;&lt;/span&gt; href&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;https://webmention.io/jonkuperman.com/webmention&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;link rel&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;pingback&quot;&lt;/span&gt; href&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;https://webmention.io/jonkuperman.com/xmlrpc&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add those to the head by using &lt;code&gt;react-helmet&lt;/code&gt; and you should be good to go!&lt;/p&gt;
&lt;h3 id=&quot;fetching-the-mentions&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-webmentions/#fetching-the-mentions&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Fetching the mentions&lt;/h3&gt;
&lt;p&gt;I took a lot of liberties here. Essentially, we&#39;ll want to hit two different &lt;a href=&quot;http://webmention.io/&quot;&gt;webmention.io&lt;/a&gt; endpoints.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;You&#39;ll want to load the count for your post. This is how many likes/retweets/mentions/replies your post got!&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A few things to note here:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The api endpoint looks like &lt;code&gt;https://webmention.io/api/count.json?target=${target}&lt;/code&gt; where &lt;code&gt;target&lt;/code&gt; is the full URL of your blog post. I pass &lt;code&gt;location.href&lt;/code&gt; into my &lt;code&gt;&amp;lt;Webmentions&amp;gt;&lt;/code&gt; component from &lt;code&gt;blog-post.js&lt;/code&gt; and then use that as the target.&lt;/li&gt;
&lt;li&gt;As &lt;a href=&quot;https://twitter.com/swyx&quot;&gt;@swyx&lt;/a&gt; says in his blog post, make sure whatever you do, the target ends with a trailing slash or it won&#39;t work!&lt;/li&gt;
&lt;li&gt;I smoosh all my likes and reposts together and also my mentions and replies (code below). That way I can show a nice heart icon followed by the total count of likes and reposts and then a nice message icon followed by mentions plus replies.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Heart&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;#e0245e&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;like &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; type&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;repost &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;MessageCircle&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;#17bf63&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;mention &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; type&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;reply &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;
&lt;p&gt;You&#39;ll want to load all the mentions so you can display them like comments!&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The api endpoint for mentions is paginated and looks like &lt;code&gt;https://webmention.io/api/mentions?page=${page}&amp;amp;per-page=20&amp;amp;sort-dir=up&amp;amp;sort-by=published&amp;amp;target=${target}&lt;/code&gt; where &lt;code&gt;target&lt;/code&gt; is the full URL of your blog post and &lt;code&gt;page&lt;/code&gt; is the current page (starting at 0) of the paginated api.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;REMINDER: You can skip reading all of this and copy/paste the code directly from &lt;a href=&quot;https://github.com/jkup/jonkuperman.com/blob/a3b7417af6b3db4197eba3d85efc6c381327b9f0/src/utils/webmentions.js&quot;&gt;my repo&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;I made one function for fetching the count and one for fetching the mentions themselves:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;loadWebMentionCounts&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;target&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;https://webmention.io/api/count.json?target=&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;target&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;res&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;res&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;loadWebMentions&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;target&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; page &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;https://webmention.io/api/mentions?page=&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;page&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&amp;amp;per-page=20&amp;amp;sort-dir=up&amp;amp;sort-by=published&amp;amp;target=&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;target&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;res&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; res&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;json&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Array&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isArray&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;json&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;links&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; json&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;links &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then I made my &lt;code&gt;&amp;lt;Webmentions&amp;gt;&lt;/code&gt; component have a &lt;code&gt;useEffect&lt;/code&gt; hook for each:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;WebMentions&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; url &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; setType&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;page&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; setPage&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;links&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; setLinks&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;loading&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; setLoading&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;useEffect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;loadPage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;loadWebMentions&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;url&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;returnedLinks&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;setLoading&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;setLinks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;links&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; links&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;returnedLinks&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;returnedLinks&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;token function&quot;&gt;setPage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;page &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;token function&quot;&gt;loadPage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;url&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;useEffect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;loadWebMentionCounts&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;url&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;setType&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;url&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;faq&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-webmentions/#faq&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; FAQ&lt;/h2&gt;
&lt;h3 id=&quot;i&#39;m-stuck&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-webmentions/#i&#39;m-stuck&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; I&#39;m stuck&lt;/h3&gt;
&lt;p&gt;Please please please @mention me on Twitter! I&#39;ll do my best to help you out and then update this post!&lt;/p&gt;
&lt;h3 id=&quot;someone-else-wrote-this-better&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-webmentions/#someone-else-wrote-this-better&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Someone else wrote this better&lt;/h3&gt;
&lt;p&gt;Totally.&lt;/p&gt;
&lt;h3 id=&quot;some-of-my-webmentions-aren&#39;t-making-it-to-my-site&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-webmentions/#some-of-my-webmentions-aren&#39;t-making-it-to-my-site&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Some of my Webmentions aren&#39;t making it to my site&lt;/h3&gt;
&lt;p&gt;I&#39;m seeing that too. For me at least they are picked up by Bridgy and it says they are &amp;quot;sent&amp;quot; but &lt;a href=&quot;http://webmention.io/&quot;&gt;webmention.io&lt;/a&gt; never gets them. You can manually re-send them via Bridgy but I don&#39;t know why that happens.&lt;/p&gt;
&lt;h3 id=&quot;your-code-is-bad&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-webmentions/#your-code-is-bad&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Your code is bad&lt;/h3&gt;
&lt;p&gt;You sound like my manager.&lt;/p&gt;
&lt;h3 id=&quot;some-of-the-build-time-examples-like-the-eleventy-one-have-a-fancy-cache-and-make-things-faster&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-webmentions/#some-of-the-build-time-examples-like-the-eleventy-one-have-a-fancy-cache-and-make-things-faster&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Some of the build time examples like the Eleventy one have a fancy cache and make things faster&lt;/h3&gt;
&lt;p&gt;Yep.&lt;/p&gt;
&lt;h3 id=&quot;i-tweeted-my-site-link-and-it&#39;s-not-showing-up&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-webmentions/#i-tweeted-my-site-link-and-it&#39;s-not-showing-up&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; I Tweeted my site link and it&#39;s not showing up&lt;/h3&gt;
&lt;p&gt;They take a while. Bridgy seems to poll Twitter every hour. If you&#39;re in a real hurry you can log in and force a re-poll but yeah it&#39;s a bit slow.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Webmention playground</title>
		<link href="https://jonkuperman.com/webmention-playground/"/>
		<updated>2021-02-13T00:00:00Z</updated>
		<id>https://jonkuperman.com/webmention-playground/</id>
		<content type="html">&lt;p&gt;I added Webmentions to my site today! If you tweet about &lt;a href=&quot;https://jonkuperman.com/webmention-playground/&quot;&gt;this page&lt;/a&gt; or reply to my tweet about it, you should show up in the comments section!&lt;/p&gt;
&lt;p&gt;Everything might be broken so bear with me 😅&lt;/p&gt;
&lt;hr /&gt;
</content>
	</entry>
	
	<entry>
		<title>Introduction to async JavaScript</title>
		<link href="https://jonkuperman.com/introduction-to-async-javascript/"/>
		<updated>2021-02-10T00:00:00Z</updated>
		<id>https://jonkuperman.com/introduction-to-async-javascript/</id>
		<content type="html">&lt;p&gt;I had an awesome meeting with my mentee today and we covered a lot of great stuff!&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;My awesome mentee&lt;/strong&gt;: Can we go over async await tomorrow?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Me&lt;/strong&gt;: Absolutely!&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;My awesome mentee&lt;/strong&gt;: Actually, maybe asynchronous code in general?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Me&lt;/strong&gt;: Let&#39;s do it!&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;a-need-for-async&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/introduction-to-async-javascript/#a-need-for-async&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; A need for async&lt;/h2&gt;
&lt;p&gt;A situation a lot of new devs find themselves in is something like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I have two things. I want the second one to start only after the first one is finished! How can I do that?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;three-options&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/introduction-to-async-javascript/#three-options&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Three options&lt;/h2&gt;
&lt;p&gt;When working with asynchronous code, you essentially have three architectural patterns you can choose from. We&#39;re going to cover all three. They are &lt;strong&gt;callbacks&lt;/strong&gt;, &lt;strong&gt;Promises&lt;/strong&gt; and &lt;strong&gt;async/await&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id=&quot;example-code&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/introduction-to-async-javascript/#example-code&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Example code&lt;/h3&gt;
&lt;p&gt;Let&#39;s make a contrived example (but not too contrived!) so we can repeat it with all three approaches.&lt;/p&gt;
&lt;p&gt;Let&#39;s say we&#39;re going to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Animate a list populating it one item at a time.&lt;/li&gt;
&lt;li&gt;When that&#39;s finished, animate it again by flashing the results on and off.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We&#39;ll start with some very basic HTML.&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;list&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we&#39;ll make each task a function like so:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Select the &amp;lt;ul&gt; we made above&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; list &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;list&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Make a list of some data. In this case, animals!&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; animals &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;cat&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;dog&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;bird&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;fish&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;cow&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;sheep&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// This function will go through the animals list and add a new item&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// to the &amp;lt;ul&gt; every 1 second.&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;setTimeout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; animal &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;li&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    animal&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;innerText &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; animals&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;index&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
    list&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animal&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;index &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; animals&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;animateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// This function will toggle the visibility of the &amp;lt;ul&gt; on and off&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// creating a flashing animation!&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;animateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; isVisible &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;setInterval&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    list&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;style&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;visibility &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; isVisible &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;hidden&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;visible&quot;&lt;/span&gt;
    isVisible &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; isVisible &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The problem here is the same as the one we defined above. Both &lt;code&gt;populateList&lt;/code&gt; and &lt;code&gt;animateList&lt;/code&gt; are working great. But we don&#39;t want the list to start animating until we are finished populating it!&lt;/p&gt;
&lt;p&gt;Currently this isn&#39;t quite right. As you can see, we start flashing the list before it&#39;s fully populated!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/broken-async-javascript.gif&quot; alt=&quot;broken async javascript code&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;option-1-callbacks&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/introduction-to-async-javascript/#option-1-callbacks&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Option 1, callbacks&lt;/h3&gt;
&lt;p&gt;The first approach we can take is passing &lt;code&gt;populateList&lt;/code&gt; a callback function. We can make sure the callback function does not get called until the list is fully populated. That way we can write some code like:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; callbackFunction&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;callbackFunction&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Now it&#39;s safe to call&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;animateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can even tidy it up a bit by making the callback function inline. This is the exact same code only inlined.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Now it&#39;s safe to call&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;animateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So with callbacks, our final code would look like:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; list &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;list&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; animals &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;cat&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;dog&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;bird&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;fish&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;cow&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;sheep&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; callback&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;setTimeout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; animal &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;li&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    animal&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;innerText &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; animals&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;index&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
    list&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animal&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;index &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; animals&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token comment&quot;&gt;// Notice we have to pass callback in each time we&lt;/span&gt;
      &lt;span class=&quot;token comment&quot;&gt;// call populateList&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; callback&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token comment&quot;&gt;// When we have no more populateList calls to make&lt;/span&gt;
      &lt;span class=&quot;token comment&quot;&gt;// Then we let the callback know we&#39;re finished!&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;animateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; isVisible &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;setInterval&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    list&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;style&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;visibility &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; isVisible &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;hidden&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;visible&quot;&lt;/span&gt;
    isVisible &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; isVisible &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;animateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And it&#39;s working!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/async-javascript-code.gif&quot; alt=&quot;async javascript code&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;option-2-promises&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/introduction-to-async-javascript/#option-2-promises&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Option 2, Promises&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise&quot;&gt;Promise API&lt;/a&gt; allows us to wrap async code in a &lt;code&gt;new Promise()&lt;/code&gt; and then we can call &lt;code&gt;Promise.then&lt;/code&gt; on it, passing in a function which will be executed only when the Promise is finished.&lt;/p&gt;
&lt;p&gt;A simple example:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; promise &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Promise&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;resolve&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; reject&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;setTimeout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

promise&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// This code will only run when the setTimeout is finished&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;we finished!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With Promises, instead of passing in a custom callback function, we can just wrap the setTimeout in a Promise and call &lt;code&gt;resolve&lt;/code&gt; when it&#39;s complete. This is very similar but it makes the execution cleaner. We go from:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;animateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;animateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We&#39;ll still have to wrap the setTimeout in a Promise though for this to work. And then we have to extract the list updating functionality to a separate function so we can call it over and over without invoking a new Promise each time. So our full example becomes:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; list &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;list&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; animals &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;cat&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;dog&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;bird&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;fish&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;cow&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;sheep&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Promise&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;resolve&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;updateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;setTimeout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; animal &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;li&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        animal&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;innerText &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; animals&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;index&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
        list&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animal&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;index &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; animals&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;token function&quot;&gt;updateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;token comment&quot;&gt;// When we have no more populateList calls to make&lt;/span&gt;
          &lt;span class=&quot;token comment&quot;&gt;// Then we let the Promise know we&#39;re finished!&lt;/span&gt;
          &lt;span class=&quot;token function&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;token function&quot;&gt;updateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;animateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; isVisible &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;setInterval&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    list&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;style&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;visibility &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; isVisible &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;hidden&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;visible&quot;&lt;/span&gt;
    isVisible &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; isVisible &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;yay?&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It works again!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/async-javascript-code.gif&quot; alt=&quot;async javascript code&quot; /&gt;&lt;/p&gt;
&lt;p&gt;So, a little more heavy lifting up front but it does result in a nice clean API.&lt;/p&gt;
&lt;h3 id=&quot;option-3-asyncawait&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/introduction-to-async-javascript/#option-3-asyncawait&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Option 3, async/await&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function&quot;&gt;Async functions&lt;/a&gt; are a great way to work with asynchronous code in JavaScript! They allow you to &amp;quot;flatten&amp;quot; out your code so you aren&#39;t dealing with inline callback functions or &lt;code&gt;Promise.then&lt;/code&gt; blocks! They make the callsite so nice and clean. It will look like:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;animateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It couldn&#39;t get cleaner than that! There&#39;s just one tiny caveat 😬&lt;/p&gt;
&lt;p&gt;You can&#39;t call await without wrapping it in an async function. This means we&#39;ll have to wrap our previously &amp;quot;global&amp;quot; code in some kind of initialize function. Something like this will do.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;animateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And we&#39;re in business!&lt;/p&gt;
&lt;p&gt;The final code looks like:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; list &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;list&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; animals &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;cat&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;dog&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;bird&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;fish&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;cow&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;sheep&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Promise&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;resolve&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;updateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;setTimeout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; animal &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;li&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        animal&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;innerText &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; animals&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;index&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
        list&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animal&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;index &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; animals&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;token function&quot;&gt;updateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;token comment&quot;&gt;// When we have no more populateList calls to make&lt;/span&gt;
          &lt;span class=&quot;token comment&quot;&gt;// Then we let the Promise know we&#39;re finished!&lt;/span&gt;
          &lt;span class=&quot;token function&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;token function&quot;&gt;updateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;animateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; isVisible &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;setInterval&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    list&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;style&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;visibility &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; isVisible &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;hidden&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;visible&quot;&lt;/span&gt;
    isVisible &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; isVisible &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;animateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;getting-fancier&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/introduction-to-async-javascript/#getting-fancier&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Getting fancier&lt;/h3&gt;
&lt;p&gt;If we wanted to get super fancy we could abstract the &lt;code&gt;setTimeout&lt;/code&gt; itself to a function.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;timeout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;ms&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Promise&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;resolve&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;setTimeout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;resolve&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; ms&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then we could &lt;code&gt;await&lt;/code&gt; inside &lt;code&gt;populateList&lt;/code&gt; itself like this!&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; list &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;list&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; animals &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;cat&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;dog&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;bird&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;fish&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;cow&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;sheep&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;timeout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;ms&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Promise&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;resolve&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;setTimeout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;resolve&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; ms&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Now we can await the entire timeout, no more nested inline functions!&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;timeout&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; animal &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;li&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  animal&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;innerText &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; animals&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;index&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
  list&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animal&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;index &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; animals&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; index &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;animateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; isVisible &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;setInterval&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    list&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;style&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;visibility &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; isVisible &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;hidden&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;visible&quot;&lt;/span&gt;
    isVisible &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; isVisible &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;populateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;animals&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;animateList&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	<entry>
		<title>All I wanted was pretty links</title>
		<link href="https://jonkuperman.com/pretty-links/"/>
		<updated>2021-01-26T00:00:00Z</updated>
		<id>https://jonkuperman.com/pretty-links/</id>
		<content type="html">&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/pretty-links.jpeg&quot; alt=&quot;All I wanted was pretty links&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Before we get started, give this bad boy a hover. &lt;Anchor title=&quot;BEHOLD&quot; url=&quot;#&quot;&gt;&lt;/Anchor&gt;&lt;/p&gt;
&lt;p&gt;It all started 8 months ago...&lt;/p&gt;
&lt;p&gt;I was re-designing my website and found this page with a bunch of amazing CSS hover effects for links. &lt;Anchor title=&quot;Check it out!&quot; url=&quot;https://tympanus.net/Development/CreativeLinkEffects/&quot;&gt;&lt;/Anchor&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;the-problem&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/pretty-links/#the-problem&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Problem&lt;/h2&gt;
&lt;p&gt;I started looking into them and they all have one thing in common. They all require multiple elements to animate. This is unfortunate because I use &lt;Anchor title=&quot;Gatsby&quot; url=&quot;https://www.gatsbyjs.com/&quot;&gt; which renders &lt;Anchor title=&quot;Markdown&quot; url=&quot;https://daringfireball.net/projects/markdown/&quot;&gt; documents. So I author my pages like:&lt;/Anchor&gt;&lt;/Anchor&gt;&lt;/p&gt;
&lt;pre class=&quot;language-markdown&quot;&gt;&lt;code class=&quot;language-markdown&quot;&gt;&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; Title&lt;/span&gt;

Some paragraph of text.

Another paragraph of text but this one has &lt;span class=&quot;token url&quot;&gt;[&lt;span class=&quot;token content&quot;&gt;a link&lt;/span&gt;](&lt;span class=&quot;token url&quot;&gt;https://jonkuperman.com&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I really wanted pretty links but I did not want to wrap every link I write in a span by hand.&lt;/p&gt;
&lt;p&gt;So I did what I normally do, I tweeted out a question to the universe and hoped for a response!&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/jkup/status/1252781941264392193&quot;&gt;https://twitter.com/jkup/status/1252781941264392193&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As luck would have it, the CEO of Gatsby saw my Tweet and replied:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/kylemathews/status/1252793979319365633&quot;&gt;https://twitter.com/kylemathews/status/1252793979319365633&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;enter-mdx&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/pretty-links/#enter-mdx&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Enter MDX&lt;/h2&gt;
&lt;p&gt;If you&#39;re not familiar, &lt;Anchor title=&quot;MDX&quot; url=&quot;https://mdxjs.com/&quot;&gt; is a format that is similar to Markdown but it allows you to add JSX to your documents! This means that I would be able to make a React component like &lt;code&gt;Anchor&lt;/code&gt; and then update my Markdown like so:&lt;/Anchor&gt;&lt;/p&gt;
&lt;pre class=&quot;language-markdown&quot;&gt;&lt;code class=&quot;language-markdown&quot;&gt;&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; Title&lt;/span&gt;

Some paragraph of text.

Another paragraph of text but this one has &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Anchor&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;a link&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://jonkuperman.com&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;farewell-remark&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/pretty-links/#farewell-remark&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Farewell, Remark&lt;/h2&gt;
&lt;p&gt;Unfortunately for me, I wasn&#39;t starting with a fresh Gatsby project. I&#39;ve had this blog for a while and I&#39;m using &lt;strong&gt;a lot&lt;/strong&gt; of plugins that require Remark. The very format I&#39;m trying to move away from!&lt;/p&gt;
&lt;p&gt;Fortunately, the Gatsby docs are pretty great. This page on &lt;Anchor title=&quot;Migrating Remark to MDX&quot; url=&quot;https://www.gatsbyjs.com/docs/how-to/routing/migrate-remark-to-mdx/&quot;&gt; got me most of the way there! The &lt;Anchor title=&quot;MDX plugin for Gatsby&quot; url=&quot;https://www.npmjs.com/package/gatsby-plugin-mdx&quot;&gt; allows you to still run most of your Remark plugins. There were a few that didn&#39;t work (like my automatic Tweet embeds!) but most of them had MDX alternatives like &lt;Anchor title=&quot;mdx-embed&quot; url=&quot;https://www.mdx-embed.com/?path=/docs/introduction--page&quot;&gt;.&lt;/Anchor&gt;&lt;/Anchor&gt;&lt;/Anchor&gt;&lt;/p&gt;
&lt;h2 id=&quot;no-small-change&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/pretty-links/#no-small-change&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; No small change&lt;/h2&gt;
&lt;p&gt;In the end, I ended up getting rid of &lt;strong&gt;a lot&lt;/strong&gt; of Remark plugins. Partly this is due to the flexibility of MDX, but partly I was just using way too many plugins. Anyway the PR turned into a bit of a monster.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/pretty-links-pr.png&quot; alt=&quot;Pretty links PR&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;making-the-anchor&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/pretty-links/#making-the-anchor&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Making the anchor&lt;/h2&gt;
&lt;p&gt;I&#39;ll probably play with this more but as soon as I finished the upgrade I made a new file &lt;code&gt;utils/mdx.js&lt;/code&gt; and created an &lt;code&gt;Anchor&lt;/code&gt; component.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; React &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;react&quot;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Anchor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; url&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; title &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;span className&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;cl-effect-5&quot;&lt;/span&gt; id&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;cl-effect-5&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
      &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;a href&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;url&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
        &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;span data&lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;hover&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;title&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;title&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;span&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
      &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;a&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
    &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;span&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then, in &lt;code&gt;layout.js&lt;/code&gt; I passed the component in as a shortcode.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; Anchor &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;../utils/mdx&quot;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; shortcodes &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; Anchor &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;MDXEmbedProvider&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
  &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;MDXProvider components&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;shortcodes&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;children&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;MDXProvider&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;MDXEmbedProvider&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, in my blog posts like &lt;code&gt;pretty-links.md&lt;/code&gt; I can just do&lt;/p&gt;
&lt;pre class=&quot;language-markdown&quot;&gt;&lt;code class=&quot;language-markdown&quot;&gt;&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; Title&lt;/span&gt;

Some paragraph of text.

Another paragraph of text but this one has &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;Anchor&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;a link&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://jonkuperman.com&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And now I have awesome links. &lt;Anchor title=&quot;JUST LIKE I ALWAYS WANTED&quot; url=&quot;#&quot;&gt; The end.&lt;/Anchor&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Improving my content diet</title>
		<link href="https://jonkuperman.com/content-diet/"/>
		<updated>2021-01-23T00:00:00Z</updated>
		<id>https://jonkuperman.com/content-diet/</id>
		<content type="html">&lt;p&gt;A few days before Christmas I found this amazing Twitter thread:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/polina_marinova/status/1342213858795118592&quot;&gt;https://twitter.com/polina_marinova/status/1342213858795118592&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It&#39;s a list of 10 questions that did, in fact, spark interesting dinner conversation! We had a few family members over (our quarantine pod during COVID) and we went through the list together!&lt;/p&gt;
&lt;p&gt;One of the questions that stood out to me was:&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/polina_marinova/status/1342213859818557441&quot;&gt;https://twitter.com/polina_marinova/status/1342213859818557441&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This was the first time I ever heard the phrase &amp;quot;content diet&amp;quot;. The question sort of had me spinning at first. I read a lot. But I don&#39;t read a lot that I would consider &amp;quot;upper limit&amp;quot; content. I read blog posts, news articles, a few books and every once in a long while I read something that blows my mind. If David Brooks is right, I&#39;m not doing myself enough favors!&lt;/p&gt;
&lt;h2 id=&quot;adding-an-upper-limit-book&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/content-diet/#adding-an-upper-limit-book&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Adding an upper limit book&lt;/h2&gt;
&lt;p&gt;I decided that I should, at any given time, be consuming some content that feels upper limit. I enjoy reading blog posts and news articles, so I&#39;m not going to cut down on them. But I do want to always be reading one thing that is dramatically improving my content diet.&lt;/p&gt;
&lt;p&gt;What upper limit content am I reading right now? &lt;Anchor title=&quot;The Jakarta Method&quot; url=&quot;https://www.goodreads.com/en/book/show/53054943-the-jakarta-method&quot;&gt; by &lt;Anchor title=&quot;Vincent Bevins&quot; url=&quot;https://twitter.com/Vinncent&quot;&gt;!&lt;/Anchor&gt;&lt;/Anchor&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/jakarta_method_content_diet.jpg&quot; alt=&quot;The Jakarta Method&quot; /&gt;&lt;/p&gt;
&lt;p&gt;I figured working through a great book at all times would give me a constant upper limit and would therefore improve my mind! 😅&lt;/p&gt;
&lt;h2 id=&quot;never-far-from-a-great-idea&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/content-diet/#never-far-from-a-great-idea&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Never far from a great idea&lt;/h2&gt;
&lt;p&gt;I followed &lt;Anchor title=&quot;Polina Marinova&quot; url=&quot;https://twitter.com/polina_marinova&quot;&gt; on Twitter when I found the original thread. A few weeks later I saw a YouTube clip in my Twitter timeline. A preview for an interview with an author. In the clip he talks about keeping piles of books in his office, his living room and his bedroom. He says he&#39;s not reading them all, but he loves surrounding himself with great books. He says that makes is so:&lt;/Anchor&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I&#39;m never far from a good idea.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The entire interview is great. He talks about building a platform, the power of good habits and finding your own voice.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=rC13mXUORBs&quot;&gt;https://www.youtube.com/watch?v=rC13mXUORBs&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;what-is-your-upper-limit&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/content-diet/#what-is-your-upper-limit&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What is your upper limit?&lt;/h2&gt;
&lt;p&gt;I&#39;m not a huge fan of life hacking or self help content. But, the theory of maximum taste resonated with me. Also, surrounding myself with amazing books sounds like a fun idea! What do you all think? Do you believe in David&#39;s theory? What do you to do improve your content diet? Message me on &lt;Anchor title=&quot;Twitter&quot; url=&quot;https://twitter.com/jkup&quot;&gt;, I&#39;d love to hear your thoughts!&lt;/Anchor&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>I made a political twitter account for a week</title>
		<link href="https://jonkuperman.com/political-twitter-account-for-a-week/"/>
		<updated>2020-11-24T00:00:00Z</updated>
		<id>https://jonkuperman.com/political-twitter-account-for-a-week/</id>
		<content type="html">&lt;p&gt;I&#39;ve always been interested in political Twitter. At the time of this writing, the Twitter account with the most followers is &lt;a href=&quot;https://twitter.com/BarackObama&quot;&gt;President Barack Obama&lt;/a&gt;&#39;s with a staggering 126.6 &lt;strong&gt;million&lt;/strong&gt; followers.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;With the 2020 election being dramatic and so drawn out, I found myself wanting to Tweet a lot and I&#39;m always terrified of losing followers so I decided to make a brand new account just to Tweet about politics.&lt;/p&gt;
&lt;p&gt;Enter &lt;a href=&quot;https://twitter.com/politikup&quot;&gt;@politikup&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/politikup.png&quot; alt=&quot;My New Twitter account @politikup&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;the-beginning&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/political-twitter-account-for-a-week/#the-beginning&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Beginning&lt;/h2&gt;
&lt;p&gt;So I made the account (which was an entire blog post of a process itself!). Then I went and followed a bunch of political accounts I like and some I hate and was off to the races!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/following.png&quot; alt=&quot;My following list&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;stage-1-shouting-into-the-abyss&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/political-twitter-account-for-a-week/#stage-1-shouting-into-the-abyss&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Stage 1, Shouting into the abyss&lt;/h3&gt;
&lt;p&gt;I don&#39;t have a ton of followers on my main account. But, at the time of this writing &lt;a href=&quot;https://twitter.com/jkup&quot;&gt;@jkup&lt;/a&gt; has just over 9,000. I was pretty surprised with my new account how little interaction I&#39;d get! To this day, I think my standalone Tweets have gotten 0 interactions. My replies have done pretty well but more on that later!&lt;/p&gt;
&lt;p&gt;Twitter is a pretty lonely place for new signups. I kept getting kicked out of my account and having to do a Google reCAPTCHA to get back in. But I was pretty happy just liking and ReTweeting as much as I wanted with no fear of being judged!&lt;/p&gt;
&lt;h3 id=&quot;stage-2-political-tweets-go-viral&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/political-twitter-account-for-a-week/#stage-2-political-tweets-go-viral&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Stage 2, Political Tweets go viral&lt;/h3&gt;
&lt;p&gt;On the flip side, early replies to Twitter accounts with many followers can get a LOT of traction. A few innocuous replies got hundreds of likes, dozens of retweets, and quite a few threats from (hopefully) spam #MAGA accounts. Here are a few examples:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/politikup/status/1328503923989241857&quot;&gt;https://twitter.com/politikup/status/1328503923989241857&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/politikup/status/1331310057569611779&quot;&gt;https://twitter.com/politikup/status/1331310057569611779&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;stage-3-i-am-drained&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/political-twitter-account-for-a-week/#stage-3-i-am-drained&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Stage 3, I am drained&lt;/h3&gt;
&lt;p&gt;I think I noticed a feeling of fatigue on the first day. The news cycle is endless, there is a lot to be anxious about and replying to accounts just begets more replies. I did have a couple of positive conversations with hardcore Trumpers where I feel like we honestly came to some common grounds. I got blocked by quite a few accounts (including 2 senators!).&lt;/p&gt;
&lt;p&gt;I&#39;m going to stop using the account. It was an enjoyable outlet for a few days but something about Political Twitter is so noise heavy, so angry, so never ending that it&#39;s had a significant effect on me.&lt;/p&gt;
&lt;h3 id=&quot;stage-4-i-want-to-help-build-not-critique-or-convince&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/political-twitter-account-for-a-week/#stage-4-i-want-to-help-build-not-critique-or-convince&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Stage 4, I want to help build, not critique or convince&lt;/h3&gt;
&lt;p&gt;Ever since Georgia went blue in this latest election, I&#39;ve been reading a lot about &lt;a href=&quot;https://twitter.com/staceyabrams&quot;&gt;Stacey Abrams&lt;/a&gt;. She served in the House of Representatives for 10 years and then in 2018 she ran for Governor of Georgia. After a highly contested election, she lost. And instead of wallowing in defeat she immediately went to work. She started organizations like &lt;a href=&quot;https://fairfight.com/&quot;&gt;Fair Fight&lt;/a&gt; and has devoted her life to fighting for Americans (Georgians in particular) to make sure they have a right to vote.&lt;/p&gt;
&lt;p&gt;After all the major news networks called Georgia for President-elect Joe Biden, I began seeing all of these Tweets attributing the win got Stacey. Her tireless work fighting for voter rights paid off in a big way.&lt;/p&gt;
&lt;p&gt;That got me thinking about how we spend our time. There is, without doubt, a big problem in America right now. As politicians attempt to subvert democracy and disenfranchise people in every state. One way of fighting against it is to call out this behavior! Another way to fight it is simply to vote for a better alternative. But the more I think about it, the more I want to spend my time building something amazing and inspiring like Stacey has. I don&#39;t want to waste my time quibbling with folks I disagree with. I want to help build something great and help folks I believe in!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Compiler Resources</title>
		<link href="https://jonkuperman.com/compiler-resources/"/>
		<updated>2020-10-26T00:00:00Z</updated>
		<id>https://jonkuperman.com/compiler-resources/</id>
		<content type="html">&lt;p&gt;This is mostly a list for myself, but I thought it might be fun to share. I want to learn a lot more about parsers and compilers. Here is my current &amp;quot;To Learn&amp;quot; list with courses, videos and books (in no particular order)!&lt;/p&gt;
&lt;hr /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.amazon.com/Compilers-Principles-Techniques-Tools-2nd/dp/0321486811&quot;&gt;Compilers: Principles, Techniques, and Tools&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.amazon.com/Language-Implementation-Patterns-Domain-Specific-Programming/dp/193435645X&quot;&gt;Language Implementation Patterns&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://interpreterbook.com/&quot;&gt;Writing An Interpreter in Go&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://compilerbook.com/&quot;&gt;Writing A Compiler In Go&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://craftinginterpreters.com/&quot;&gt;Crafting Interpreters&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://gameprogrammingpatterns.com/&quot;&gt;Game Programming Patterns&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.dmitrysoshnikov.education/p/essentials-of-parsing&quot;&gt;Parsing Algorithms&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://increment.com/programming-languages/crash-course-in-compilers/&quot;&gt;A crash course in compilers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://tiarkrompf.github.io/notes/?/just-write-the-parser/&quot;&gt;Just write the #!%/* parser&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://hacks.mozilla.org/2020/06/compiler-compiler-working-on-a-javascript-engine/&quot;&gt;Compiler Compiler: A Twitch series about working on a JavaScript engine&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/mozilla-spidermonkey/jsparagus/blob/master/js-quirks.md#readme&quot;&gt;Why JavaScript syntax is hard to parse&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://dmitrysoshnikov.com/courses/essentials-of-interpretation/&quot;&gt;Essentials of Interpretation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
	</entry>
	
	<entry>
		<title>Best blog designs I want to steal everything from</title>
		<link href="https://jonkuperman.com/best-blog-designs-2020/"/>
		<updated>2020-05-01T00:00:00Z</updated>
		<id>https://jonkuperman.com/best-blog-designs-2020/</id>
		<content type="html">&lt;p&gt;As I was going through rebuilding &lt;a href=&quot;https://jonkuperman.com/&quot;&gt;my blog&lt;/a&gt;, I spent a lot of time looking at other people&#39;s sites trying to get inspiration. Below is a list of my absolute favorite blog designs and my favorite thing about them.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;1.-joshwcomeau.com&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-blog-designs-2020/#1.-joshwcomeau.com&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 1. &lt;a href=&quot;http://joshwcomeau.com/&quot;&gt;joshwcomeau.com&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;What&#39;s not to love about this website? It might be my favorite personal blog design of all time.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/joshwcomeau.jpg&quot; alt=&quot;Josh W Comeau&#39;s website&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;things-i-love-about-joshwcomeau.com&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-blog-designs-2020/#things-i-love-about-joshwcomeau.com&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Things I love about &lt;a href=&quot;http://joshwcomeau.com/&quot;&gt;joshwcomeau.com&lt;/a&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Light / Dark mode toggle&lt;/li&gt;
&lt;li&gt;Amazing illustrated image of the author&lt;/li&gt;
&lt;li&gt;Fun sounds!&lt;/li&gt;
&lt;li&gt;Little interactive heart to click on each post&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;my-favorite-thing-about-it:&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-blog-designs-2020/#my-favorite-thing-about-it:&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; My favorite thing about it:&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;The links!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Seriously, look at what happens when you hover over one of these links:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/joshwcomeau-links.gif&quot; alt=&quot;Josh W Comeau&#39;s website&quot; /&gt;&lt;/p&gt;
&lt;p&gt;I tried figuring out how these work. If you open the network panel in your devtools you&#39;ll see it doesn&#39;t make a request on hover. I think he must have some sort of build task that crawls his pages, finds links, takes screenshots of each link and then saves them to the post.&lt;/p&gt;
&lt;p&gt;I&#39;ve been thinking about recreating this just for fun but reading Josh&#39;s blog is always such a great experience!&lt;/p&gt;
&lt;h2 id=&quot;2.-wesbos.com&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-blog-designs-2020/#2.-wesbos.com&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 2. &lt;a href=&quot;http://wesbos.com/&quot;&gt;wesbos.com&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Wes &lt;strong&gt;literally&lt;/strong&gt; just finished rebuilding his blog!&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/wesbos/status/1252618566139928576&quot;&gt;https://twitter.com/wesbos/status/1252618566139928576&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Check out how amazing it looks:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/wesbos.jpg&quot; alt=&quot;Wes Bos&#39;s website&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;things-i-love-about-wesbos.com&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-blog-designs-2020/#things-i-love-about-wesbos.com&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Things I love about &lt;a href=&quot;http://wesbos.com/&quot;&gt;wesbos.com&lt;/a&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;The typography&lt;/li&gt;
&lt;li&gt;The amazing breakpoints&lt;/li&gt;
&lt;li&gt;The content! Free courses, premium courses, a podcast!&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;my-favorite-thing-about-it:-1&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-blog-designs-2020/#my-favorite-thing-about-it:-1&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; My favorite thing about it:&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;The open graph images&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you link to any of Wes&#39; posts on Twitter or Facebook, you&#39;ll notice that the embedded image is actually a screenshot of the post you are linking to! You might be wondering:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Does Wes write a post, screenshot it and then save the file to his blog before publishing?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;No, he doesn&#39;t! He has a Netlify function that runs on deploy that does this automatically for him! Check it out &lt;a href=&quot;https://github.com/wesbos/wesbos/blob/master/functions/ogimage/ogimage.js&quot;&gt;here&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;Here is an example post:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/wesbos/status/1252619804994703361&quot;&gt;https://twitter.com/wesbos/status/1252619804994703361&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;3.-christopherbiscardi.com&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-blog-designs-2020/#3.-christopherbiscardi.com&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 3. &lt;a href=&quot;http://christopherbiscardi.com/&quot;&gt;christopherbiscardi.com&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Chris writes so much great content on his blog! It&#39;s full of amazing posts on JAMstack, MDX, Gatsby and more! And just look at it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/christopherbiscardi.jpg&quot; alt=&quot;Christopher Biscardi&#39;s website&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;things-i-love-about-christopherbiscardi.com&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-blog-designs-2020/#things-i-love-about-christopherbiscardi.com&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Things I love about &lt;a href=&quot;http://christopherbiscardi.com/&quot;&gt;christopherbiscardi.com&lt;/a&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;The rainbows!&lt;/li&gt;
&lt;li&gt;It&#39;s so clean. Great use of space&lt;/li&gt;
&lt;li&gt;This little guy&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/christopherbiscardi.gif&quot; alt=&quot;Christopher Biscardi&#39;s website&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;my-favorite-thing-about-it:-2&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-blog-designs-2020/#my-favorite-thing-about-it:-2&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; My favorite thing about it:&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;The Rainbows&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Seriously, they are everywhere and I love them. Check out this little animation at the top as you scroll through an article.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/christopherbiscardi2.gif&quot; alt=&quot;Christopher Biscardi&#39;s website&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;4.-chriscoyier.net&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-blog-designs-2020/#4.-chriscoyier.net&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 4. &lt;a href=&quot;http://chriscoyier.net/&quot;&gt;chriscoyier.net&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Chris is the owner of the amazing &lt;a href=&quot;https://css-tricks.com/&quot;&gt;css-tricks&lt;/a&gt; website, but it&#39;s actually his personal site that I found inspiring!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/chriscoyier.jpg&quot; alt=&quot;Chris Coyier&#39;s website&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;things-i-love-about-chriscoyier.net&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-blog-designs-2020/#things-i-love-about-chriscoyier.net&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Things I love about &lt;a href=&quot;http://chriscoyier.net/&quot;&gt;chriscoyier.net&lt;/a&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;It&#39;s so personal. I feel like I know a bit about him just from viewing his page.&lt;/li&gt;
&lt;li&gt;It&#39;s right to the point. Need to contact? Write a guest post? Whatever it is, there&#39;s a link for that.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;my-favorite-thing-about-it:-3&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/best-blog-designs-2020/#my-favorite-thing-about-it:-3&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; My favorite thing about it:&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;This form&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Check this out!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/chriscoyier.gif&quot; alt=&quot;Chris Coyier&#39;s website form&quot; /&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Choosing a blogging platform: Gatsby vs. Wordpress vs. 11ty</title>
		<link href="https://jonkuperman.com/gatsby-vs-wordpress-vs-11ty/"/>
		<updated>2020-04-23T00:00:00Z</updated>
		<id>https://jonkuperman.com/gatsby-vs-wordpress-vs-11ty/</id>
		<content type="html">&lt;p&gt;I have a little bit of a problem.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/jkup/status/1252322493072920577&quot;&gt;https://twitter.com/jkup/status/1252322493072920577&lt;/a&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;my-problem&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-vs-wordpress-vs-11ty/#my-problem&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; My Problem&lt;/h2&gt;
&lt;p&gt;There are really two parts to my problem. On the one hand, I love new technologies, blogging platforms are getting better at such an exciting pace and it&#39;s so much fun to explore them! On the other hand, I want to be blogging more and I &lt;strong&gt;love&lt;/strong&gt; to procrastinate by redesigning my blog.&lt;/p&gt;
&lt;h2 id=&quot;the-contenders&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-vs-wordpress-vs-11ty/#the-contenders&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Contenders&lt;/h2&gt;
&lt;p&gt;I&#39;ve played with a lot of frameworks, but my main 3 favorites are &lt;a href=&quot;https://wordpress.org/&quot;&gt;WordPress&lt;/a&gt;, &lt;a href=&quot;https://www.11ty.dev/&quot;&gt;11ty&lt;/a&gt;, and &lt;a href=&quot;https://www.gatsbyjs.org/&quot;&gt;Gatsby&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;wordpress&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-vs-wordpress-vs-11ty/#wordpress&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; WordPress&lt;/h3&gt;
&lt;p&gt;Founded in 2003, WordPress has been a fundamental part of the web for almost two decades! It&#39;s a full-fledged Content Management System that offers a great editing experience.&lt;/p&gt;
&lt;h4 id=&quot;pros&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-vs-wordpress-vs-11ty/#pros&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Pros&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Beautiful WYSIWYG editor&lt;/li&gt;
&lt;li&gt;A huge community of themes and plugins&lt;/li&gt;
&lt;li&gt;Great security and caching plugins&lt;/li&gt;
&lt;li&gt;Easily connects to any popular third-party services&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;cons&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-vs-wordpress-vs-11ty/#cons&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Cons&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Requires a server (more on this later)&lt;/li&gt;
&lt;li&gt;Requires a database&lt;/li&gt;
&lt;li&gt;Must be kept up to date or face security issues&lt;/li&gt;
&lt;li&gt;Most hosts struggle to keep up with increased traffic (more on this later as well)&lt;/li&gt;
&lt;li&gt;Being the most popular blogging platform, it&#39;s the most commonly targeted by attackers&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The big problem that I have with WordPress is that it&#39;s a dynamic application. You need to get a web host running PHP and MySQL and you need to keep WordPress up to date as well as all of your plugins and themes.&lt;/p&gt;
&lt;p&gt;If you forget to update, you are susceptible to any number of common attacks. I&#39;ve had WordPress sites hacked many times when I forget to check-in and update them.&lt;/p&gt;
&lt;p&gt;My last problem is also related to its dynamic nature. Since each visitor requires the server to make a MySQL connection, and MySQL has a limit to the number of concurrent connections so if you have an article get popular on Reddit or Hacker News your users may start seeing MySQL errors. This can be mostly avoided by using a good caching plugin.&lt;/p&gt;
&lt;h3 id=&quot;11ty&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-vs-wordpress-vs-11ty/#11ty&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 11ty&lt;/h3&gt;
&lt;p&gt;11ty is a simplified take on static site generators. I&#39;ve been a huge fan of static sites since Jekyll first came out in 2008. There&#39;s something so nice about your website consisting of &lt;strong&gt;only&lt;/strong&gt; HTML and CSS.&lt;/p&gt;
&lt;h4 id=&quot;pros-1&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-vs-wordpress-vs-11ty/#pros-1&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Pros&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Completely secure&lt;/li&gt;
&lt;li&gt;Lighting fast page loads&lt;/li&gt;
&lt;li&gt;Easy to find a host&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;cons-1&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-vs-wordpress-vs-11ty/#cons-1&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Cons&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;No WYSIWYG. You have to edit your posts locally in a text editor with markdown&lt;/li&gt;
&lt;li&gt;Although JavaScript is often seen as the enemy to web performance, there are some really neat things you can do to improve performance with JS.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;gatsby&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-vs-wordpress-vs-11ty/#gatsby&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Gatsby&lt;/h3&gt;
&lt;p&gt;A relatively new player on the scene, Gatsby takes an innovative approach to generating static sites. It comes with a rich plugin ecosystem that provides out of the box support for really cool things.&lt;/p&gt;
&lt;h4 id=&quot;pros-2&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-vs-wordpress-vs-11ty/#pros-2&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Pros&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Progressively loading images&lt;/li&gt;
&lt;li&gt;Offline page access&lt;/li&gt;
&lt;li&gt;Prefetching linked pages&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;cons-2&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-vs-wordpress-vs-11ty/#cons-2&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Cons&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Slow build times (it&#39;s doing a lot of work!)&lt;/li&gt;
&lt;li&gt;Slower initial page load (with faster consecutive loads)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;my-conclusion&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/gatsby-vs-wordpress-vs-11ty/#my-conclusion&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; My conclusion&lt;/h2&gt;
&lt;p&gt;After a lot of thought and experimentation, I decided to go with Gatsby and host my site on &lt;a href=&quot;https://www.netlify.com/&quot;&gt;Netlify&lt;/a&gt;. I&#39;m really happy with it so far.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Patreon layoffs seem cruel</title>
		<link href="https://jonkuperman.com/patreon-layoffs-seem-cruel/"/>
		<updated>2020-04-22T00:00:00Z</updated>
		<id>https://jonkuperman.com/patreon-layoffs-seem-cruel/</id>
		<content type="html">&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/patreon-logo.png&quot; alt=&quot;Patreon Logo.&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Yesterday, Patreon &lt;a href=&quot;https://techcrunch.com/2020/04/21/patreon-lays-off-13-of-workforce/&quot;&gt;announced&lt;/a&gt; that it was laying off 13% of its workforce.&lt;/p&gt;
&lt;p&gt;It&#39;s not particularly surprising news. With most cities sheltering in place and so many people out of work, the tech industry has not been immune. A quick glance at &lt;a href=&quot;http://layoffs.fyi/&quot;&gt;layoffs.fyi&lt;/a&gt; will show that many startups are falling on hard times.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Most of the companies facing hard times are in industries most affected by Coronavirus shutdowns. Groupon, Yelp, Eventbrite, etc. Some of them are in unrelated industries&lt;/p&gt;
&lt;h2 id=&quot;march-was-patreons-best-month-in-years&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/patreon-layoffs-seem-cruel/#march-was-patreons-best-month-in-years&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; March was Patreons best month in years&lt;/h2&gt;
&lt;p&gt;One of the things that makes this round of layoffs so strange, is last month Patreon wrote a &lt;a href=&quot;https://blog.patreon.com/covid-19-creative-economy-patreon-data-science&quot;&gt;blog post&lt;/a&gt; saying that&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Average new patron growth across the US, UK, Canada, Germany, Australia, and Italy is up 36.2% compared to February&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;hiring-freezes&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/patreon-layoffs-seem-cruel/#hiring-freezes&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Hiring Freezes&lt;/h2&gt;
&lt;p&gt;With so many people out of work and so many tech companies instituting hiring freezes, it really is a terrible time to be laid off. So many of these companies are facing going out of business, which is totally understandable. But then Patreon went and released the following statement:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Over the past six weeks, Patreon has experienced a significant influx of new creators launching on the platform along with increased financial support from both their new and existing patrons. In March alone, we onboarded 50,000 new creators to the platform of which the average income was 60% higher than previous months. This surge, along with years of continuous growth, has put Patreon in a strong financial position to help creators successfully manage their creative businesses during this challenging time.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Although the business is in a strong cash position, we want to ensure that we can continue to support creators for many years to come. It is unclear how long this economic uncertainty will last and therefore, to prepare accordingly, we have made the difficult decision to part ways with 13% of Patreon’s workforce. This decision was not made lightly and consisted of several other factors beyond the financial ones. Prior to the pandemic, we had completed an in-depth performance review cycle and deployed a new company strategy – both exercises highlighted the need for different skill sets moving forward.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;It was this combination of economic uncertainty, performance reviews and a shift in strategy that prompted us to make this change. Patreon is now on a path to long-term success and the business will emerge from this layoff even stronger, both financially and strategically.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Which makes it sound like Patreon has plenty of money and isn&#39;t at all in danger of going out of business. They just think they can make more money by laying folks off.&lt;/p&gt;
&lt;h2 id=&quot;performance-reviews&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/patreon-layoffs-seem-cruel/#performance-reviews&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Performance Reviews&lt;/h2&gt;
&lt;p&gt;This is really the icing on the cake for me. In their official statement, they bring up performance reviews. Implying that the people they laid off were not top performers.&lt;/p&gt;
&lt;p&gt;Why even mention this? It feels like a totally inappropriate insult aimed at people who have just gone through something terrible (you laying them off during a pandemic which has caused worldwide hiring freezes).&lt;/p&gt;
&lt;h2 id=&quot;wrapping-it-all-up&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/patreon-layoffs-seem-cruel/#wrapping-it-all-up&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Wrapping it all up&lt;/h2&gt;
&lt;p&gt;So the world is in a difficult place. Many people are out of work and struggling to find jobs. Companies are going out of business and bleeding cash. Patreon is lucky enough to be in an industry that is doing better than normal during this crisis. They are having record breaking months.&lt;/p&gt;
&lt;p&gt;Despite all of this, they&#39;ve decided to go ahead and fire a bunch of people during these tough times. On top of all of that, they also want you to know that the folks they laid off were not top performers and that&#39;s why they are all being fired.&lt;/p&gt;
&lt;p&gt;Stay classy, Patreon.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Avoid Rendering Empty Content with font-display: swap</title>
		<link href="https://jonkuperman.com/avoid-empty-content-with-font-swap/"/>
		<updated>2020-04-21T00:00:00Z</updated>
		<id>https://jonkuperman.com/avoid-empty-content-with-font-swap/</id>
		<content type="html">&lt;p&gt;I&#39;ve been working on rebuilding my website. I found this awesome font called &lt;a href=&quot;http://atipofoundry.com/fonts/wotfard&quot;&gt;Wotfard&lt;/a&gt; while browsing &lt;a href=&quot;https://joshwcomeau.com/&quot;&gt;Josh W Comeau&lt;/a&gt;&#39;s site.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;my-first-attempt&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/avoid-empty-content-with-font-swap/#my-first-attempt&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; My first attempt&lt;/h2&gt;
&lt;p&gt;I wanted to add it to my new site so I added this to the top of my global.css file.&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token atrule&quot;&gt;&lt;span class=&quot;token rule&quot;&gt;@font-face&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Wotfard&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token url&quot;&gt;&lt;span class=&quot;token function&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string url&quot;&gt;&quot;/fonts/wotfard-regular-webfont.eot&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token url&quot;&gt;&lt;span class=&quot;token function&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string url&quot;&gt;&quot;/fonts/wotfard-regular-webfont.eot?#iefix&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;embedded-opentype&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token url&quot;&gt;&lt;span class=&quot;token function&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string url&quot;&gt;&quot;/fonts/wotfard-regular-webfont.woff2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;woff2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token url&quot;&gt;&lt;span class=&quot;token function&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string url&quot;&gt;&quot;/fonts/wotfard-regular-webfont.ttf&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;truetype&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-weight&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; normal&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; normal&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Wotfard&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sans-serif&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This worked great! Except for this pesky problem where every time I refresh or load a new page, for a tiny split second, I see a bunch of empty content where the text is supposed to be!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/font.gif&quot; alt=&quot;Flash of empty content.&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This is happening because the custom web font takes a split second to load after the page loads. And since all of our text is set to this custom font, our site doesn&#39;t have anything to display until the font is finished loading!&lt;/p&gt;
&lt;p&gt;Fortunately, this can be fixed with a single line of CSS!&lt;/p&gt;
&lt;h2 id=&quot;introducing-font-display:-swap&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/avoid-empty-content-with-font-swap/#introducing-font-display:-swap&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Introducing font-display: swap&lt;/h2&gt;
&lt;p&gt;All I did was add &lt;code&gt;font-display: swap;&lt;/code&gt; to my &lt;code&gt;@font-face&lt;/code&gt; block.&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token atrule&quot;&gt;&lt;span class=&quot;token rule&quot;&gt;@font-face&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Wotfard&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token url&quot;&gt;&lt;span class=&quot;token function&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string url&quot;&gt;&quot;/fonts/wotfard-regular-webfont.eot&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token url&quot;&gt;&lt;span class=&quot;token function&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string url&quot;&gt;&quot;/fonts/wotfard-regular-webfont.eot?#iefix&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;embedded-opentype&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token url&quot;&gt;&lt;span class=&quot;token function&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string url&quot;&gt;&quot;/fonts/wotfard-regular-webfont.woff2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;woff2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token url&quot;&gt;&lt;span class=&quot;token function&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string url&quot;&gt;&quot;/fonts/wotfard-regular-webfont.ttf&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;truetype&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-weight&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; normal&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; normal&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; swap&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Wotfard&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sans-serif&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and voila! no more flash of unstyled content. Now it loads all of my text with a system font until the web font is ready, and then swaps it in! So it&#39;s a little jumpy but better than before!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/font2.gif&quot; alt=&quot;Jittery content but no flash!.&quot; /&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Working with people who are smarter than you</title>
		<link href="https://jonkuperman.com/working-with-people-who-are-smarter-than-you/"/>
		<updated>2020-02-27T00:00:00Z</updated>
		<id>https://jonkuperman.com/working-with-people-who-are-smarter-than-you/</id>
		<content type="html">&lt;p&gt;When I was just starting in tech, every job was brimming with people smarter than me! I couldn’t imagine anything better. I was young, new to programming and so eager to learn.&lt;/p&gt;
&lt;p&gt;As the years went by, I did pretty well for myself. I was lucky enough to work at several great tech companies such as Twitter, Brave, and Adobe. Eventually, I was promoted to Senior Software Engineer and even put on a few teams as Tech Lead.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Somewhere along the line, my mentality shifted. I went from eager to learn from all of my smart, talented peers to afraid of getting fired when my manager realizes I’m a lot less smart than other people at my level.&lt;/p&gt;
&lt;p&gt;Sometimes, working with a smarter coworker is easy to justify. They’ve been at the company a lot longer, they’re older, they’ve been coding for more years, etc. Other times, they’re just a lot better than I am.&lt;/p&gt;
&lt;p&gt;A lot of this is honestly just my insecurity and imposter syndrome. But I thought it might be nice for me to share some of the ways I cope with these feelings.&lt;/p&gt;
&lt;h2 id=&quot;adding-value&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/working-with-people-who-are-smarter-than-you/#adding-value&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Adding Value&lt;/h2&gt;
&lt;p&gt;As I get older, I spend more and more time thinking about the value I’m able to add at work. For some people, a lot of the value they add is by writing code. Others add value by writing documentation, mentoring new hires or interfacing with other teams. I try to focus on the areas where I can add the most value and work hard on improving those!&lt;/p&gt;
&lt;p&gt;When I work with someone better at coding than I am, I try to find other necessary tasks that come with the work we’re doing. I put extra effort into taking care of those and let the other person excel where they shine while I try to do the same.&lt;/p&gt;
&lt;h2 id=&quot;a-rising-tide&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/working-with-people-who-are-smarter-than-you/#a-rising-tide&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; A Rising Tide&lt;/h2&gt;
&lt;p&gt;Another important lesson is getting away from having a &lt;a href=&quot;https://www.psychologytoday.com/us/blog/science-choice/201504/the-scarcity-mindset&quot;&gt;Scarcity Mindset&lt;/a&gt;. Something in my brain feels threatened by working with people better at my job than me. But there’s nothing to feel threatened by. It always amazes me how giving honest, appreciative feedback to my managers about the excellence of my coworkers not only doesn’t affect me negatively but often comes back to me in the form of positive feedback from my coworkers.&lt;/p&gt;
&lt;p&gt;A rising tide lifts all boats. One of my goals for 2020 is to get back to my beginner mindset. Feeling lucky to get to work with a ton of smart people and being earnestly excited to learn from them!&lt;/p&gt;
&lt;p&gt;Do you struggle with having a scarcity mindset? Do you feel threatened working with folks that are a lot smarter? How do you cope with it? Let me know in the comments!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>10 years is a long time</title>
		<link href="https://jonkuperman.com/10-years-is-a-long-time/"/>
		<updated>2020-02-14T00:00:00Z</updated>
		<id>https://jonkuperman.com/10-years-is-a-long-time/</id>
		<content type="html">&lt;p&gt;Losing weight, running a marathon, learning to code, saving money. These are important goals many of us share. They are also goals that, for the most part, cannot be achieved in a short amount of time.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;So many of us crave instant gratification. Perhaps me more than most. As I get older, and more and more of my goals involve long term dedication, I struggle with working so hard for something and not having it weeks, months or even years later.&lt;/p&gt;
&lt;h2 id=&quot;losing-weight&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/10-years-is-a-long-time/#losing-weight&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Losing Weight&lt;/h2&gt;
&lt;p&gt;I’ve been struggling with my weight since my late twenties. It’s constantly going up and down and I find it very difficult to stick to a plan. It still blows my mind that I can be so good and eat so well for an entire week and still not look or feel any different. It’s been a very challenging mental shift for me to know that I’m investing in my health and while it won’t come overnight, it won’t come at all if I don’t put in the work!&lt;/p&gt;
&lt;p&gt;I’m a highly motivated person who struggles to stick to one interest for very long. Unfortunately, this makes achieving long term goals even more difficult! Being “super” good on my diet for 3 days is not nearly as important as being “pretty” good for months.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Discipline is more important than motivation.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;running-a-marathon&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/10-years-is-a-long-time/#running-a-marathon&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Running a marathon&lt;/h2&gt;
&lt;p&gt;Last year, I read &lt;a href=&quot;https://www.amazon.com/Rise-Ultra-Runners-Journey-Endurance-ebook/dp/B07KGJ5NSM&quot;&gt;The Rise of the Ultra Runners&lt;/a&gt; and was so inspired and motivated to start running!&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/jkup/status/1165329008843612160&quot;&gt;https://twitter.com/jkup/status/1165329008843612160&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;My girlfriend and I started running every day after work for as long as we could. A few things happened:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I got really bad blisters&lt;/li&gt;
&lt;li&gt;My pace and stamina improved each week!&lt;/li&gt;
&lt;li&gt;Despite that, I started getting disappointed with how far away from being able to run a marathon I was.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/jkup/status/1169847804602118144&quot;&gt;https://twitter.com/jkup/status/1169847804602118144&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Behind the scenes, the motivation dissipated and all that was left was my discipline (or lack thereof). Running is such a great example of disciplined, long term goals because even the best runners I know are training hard all year to shave a few seconds off their pace! Imagine that, running 5 days a week for a year just to shave 10 minutes off their marathon pace. Do you have that sort of discipline? Do I?&lt;/p&gt;
&lt;p&gt;Long story short I fell off my running streak. After a few months I started running again and there was a bit of good news. I didn’t fall all the way back to zero! I think a bright side to learning things that take a long time to perfect is that stopping for a few months isn’t a huge deal!&lt;/p&gt;
&lt;h2 id=&quot;learning-to-code&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/10-years-is-a-long-time/#learning-to-code&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Learning to code&lt;/h2&gt;
&lt;p&gt;I’ve been coding for years. I really have put the work in. Luckily, since coding is my profession, it forces me to keep practicing long after the motivation has faded. This has been such a blessing for me. It’s amazing to look back on where I was 10 years ago (knowing literally nothing about code) and see how far I’ve come.&lt;/p&gt;
&lt;p&gt;I want to find ways to keep myself accountable for my long term goals when I don’t have the luxury of relying on practice to survive!&lt;/p&gt;
&lt;h2 id=&quot;saving-money&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/10-years-is-a-long-time/#saving-money&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Saving money&lt;/h2&gt;
&lt;p&gt;Last year I decided it was time for me to be a little smarter with my money. I’ve always been good at living within my means but I’ve never invested money before. I got motivated and read a lot of books on the stock market, real estate investing, savings accounts and retirement. I learned a ton of interesting things, but most of those I’ll save for another post! One saying that stuck with me about stock market investing was:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;It’s about time in the market, not timing the market.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;To me, this is a perfect analogy for there being no better way to get good at something than investing consistent amounts of time into it for many years. Take this example I found when reading about compound interest.&lt;/p&gt;
&lt;p&gt;If you put $100 a month in a stock market index fund (assuming an average return of 10% annually) starting when you are 25 years old, by the time you turn 65 you would have $535,636.99! That’s the power of doing something consistently for a long period of time.&lt;/p&gt;
&lt;p&gt;This is especially amazing because after 10 years of saving, you’d only have $19,384.28. After 20 years you’d still only have $69,402.75. It’s really all about keeping your money in the market for a long period of time.&lt;/p&gt;
&lt;p&gt;I’m struggling to change my mindset. To find &lt;em&gt;sustainable&lt;/em&gt; diets, savings plans, and running schedules! To remind myself that it’s not about how fast I’ll be able to run next week, or next month. To know that putting in the work will absolutely yield great results, it’s only a matter of time!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Suspend a React Component from the DevTools</title>
		<link href="https://jonkuperman.com/suspend-a-react-component-from-the-devtools/"/>
		<updated>2020-02-11T00:00:00Z</updated>
		<id>https://jonkuperman.com/suspend-a-react-component-from-the-devtools/</id>
		<content type="html">&lt;p&gt;Today we’re going to learn how to manually suspend a React Component by using the React DevTools.&lt;/p&gt;
&lt;p&gt;Let’s start by using &lt;a href=&quot;https://github.com/facebook/create-react-app&quot;&gt;create-react-app&lt;/a&gt; to make a very basic Hello World.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Open your terminal and type in the following:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;npx create-react-app suspense-demo
&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; suspense-demo
&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; start&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That should open a new tab in your browser and you should see the Create React App welcome page, which looks like this.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/create-react-app-welcome-page.png&quot; alt=&quot;Create React App welcome page.&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now let’s open the suspense-demo folder in your favorite text editor. Inside the src/ folder next to App.js create a new file and call it Suspendable.js. Put the following inside.&lt;/p&gt;
&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; React &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;react&quot;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Suspendable&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;Finished Loading!&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt; Suspendable&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now open App.js and let’s replace the current contents with your Suspendable component, wrapped in a React.Suspense tag.&lt;/p&gt;
&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; React &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;react&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;App.css&quot;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; Suspendable &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;lazy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;./Suspendable&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;App&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;React.Suspense&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;fallback&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Loading...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Suspendable&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;React.Suspense&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt; App&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now if you go back to your browser you’ll see your Suspense component loading, but it likely happens too quickly and you’ll never see “Loading…” you’ll just see “Finished Loading!”.&lt;/p&gt;
&lt;p&gt;If you want to test the React component in its suspended state you can do so by installing the &lt;a href=&quot;https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en&quot;&gt;React DevTools&lt;/a&gt; and opening up the Components tab. Click on your Suspendable component in the list and then click the little stopwatch icon in the sidebar to suspend the component.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/suspend-component-react-devtools.png&quot; alt=&quot;Suspend React Component with DevTools&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Click the highlighted button to suspend a React component.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>A weird login flow</title>
		<link href="https://jonkuperman.com/ufc-reset-your-password/"/>
		<updated>2020-02-03T00:00:00Z</updated>
		<id>https://jonkuperman.com/ufc-reset-your-password/</id>
		<content type="html">&lt;p&gt;I’m a pretty big UFC fan. I like to watch older fights and for that reason I have a subscription to UFC Fight Pass.&lt;/p&gt;
&lt;p&gt;A few months ago they did a website redesign and among other things changed their URL from &lt;a href=&quot;http://ufc.tv/&quot;&gt;UFC&lt;/a&gt; to &lt;a href=&quot;https://ufcfightpass.com/&quot;&gt;UFC Fight Pass&lt;/a&gt;. When this redesign launched my password manager stop recognizing it and when I couldn’t log in I went through their “Forgot my password” flow.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;I entered my email address and off it went! I got the email in my inbox just like usual and when I clicked on “Reset your password” it took me to the new site. The only problem was, it looks like they forgot to implement the Reset your password screen on the new redesign! It just redirects to the home screen.&lt;/p&gt;
&lt;p&gt;Luckily, after the redirect, you are logged in with a temporary password so you can still watch videos!&lt;/p&gt;
&lt;p&gt;Four months later, I’m actually loving this workflow. I still haven’t been able to set a password but I’ve gotten really fast at going to their site, “resetting” my password and clicking the link in my email. Why do we need passwords again?&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>My first month as a remote worker</title>
		<link href="https://jonkuperman.com/my-first-month-as-a-remote-worker/"/>
		<updated>2020-02-01T00:00:00Z</updated>
		<id>https://jonkuperman.com/my-first-month-as-a-remote-worker/</id>
		<content type="html">&lt;p&gt;At the end of December I moved from San Francisco to Florida (of all places) and started working remotely for Adobe.&lt;/p&gt;
&lt;p&gt;It’s been quite a transition, moving across the country, buying a house and starting to work remote. I figured while it’s still fresh in my head I’d document some of the pros and cons I’ve found so far!&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;pros&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-month-as-a-remote-worker/#pros&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Pros&lt;/h2&gt;
&lt;h3 id=&quot;more-focus-time&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-month-as-a-remote-worker/#more-focus-time&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; More focus time&lt;/h3&gt;
&lt;p&gt;Working for a West Coast tech company from the East Coast means that literally no one is online until about noon my time. That means that if I start working at 9am EST, I have three entire hours with no emails, no Slack messages and no meetings. I’m really enjoying this time to put on my headphones and get some great work done.&lt;/p&gt;
&lt;h3 id=&quot;less-distractions&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-month-as-a-remote-worker/#less-distractions&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Less distractions&lt;/h3&gt;
&lt;p&gt;While I do miss the social interactions of being in the office, open offices are just terrible places to focus. When I finish a meeting at home, I turn off the app and am immediately back in my empty office working. No one coming up to talk, no overhearing arguments in the office, it’s a lot easier to concentrate on what I need to do.&lt;/p&gt;
&lt;h3 id=&quot;housework-and-errands&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-month-as-a-remote-worker/#housework-and-errands&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Housework and errands&lt;/h3&gt;
&lt;p&gt;When I was working from the office, I had a really hard time motivating myself to get errands done before or after work. Running to the post office, doing laundry, cleaning the house were all things I’d tend to put off. Working from home makes taking care of those issues a lot easier. Especially (and this is a con as well) since I no longer have a group of coworkers to eat lunch with, it’s easy to run around the house doing some chores after I eat.&lt;/p&gt;
&lt;h3 id=&quot;time-with-my-family&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-month-as-a-remote-worker/#time-with-my-family&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Time with my family&lt;/h3&gt;
&lt;p&gt;It’s also been really nice having my girlfriend and my dogs one room away at all times. Luckily, our new house is big enough that we’re not working right on top of each other. But it really is nice to order some food and meet in the living room and have a nice lunch all together!&lt;/p&gt;
&lt;h2 id=&quot;cons&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-month-as-a-remote-worker/#cons&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Cons&lt;/h2&gt;
&lt;h3 id=&quot;loneliness&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-month-as-a-remote-worker/#loneliness&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Loneliness&lt;/h3&gt;
&lt;p&gt;As I get older, more and more of my friends and social interactions involve work or work friends. Between not being at an office and moving to a state where I know so few people, it’s taken a pretty big toll on my social life.&lt;/p&gt;
&lt;h3 id=&quot;feeling-disconnected-from-coworkers&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-month-as-a-remote-worker/#feeling-disconnected-from-coworkers&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Feeling disconnected from coworkers&lt;/h3&gt;
&lt;p&gt;So far I’ve been having a pretty easy time keeping up to date on my work tasks. I’m having a much harder time keeping up to date with my coworkers on a social level. Last week some of my teammates dialed me in to a video call while they had coffee! Going forward, I’d like to set up regular 1:1’s with them to feel more connected.&lt;/p&gt;
&lt;h3 id=&quot;work-life-balance&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-month-as-a-remote-worker/#work-life-balance&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Work-Life balance&lt;/h3&gt;
&lt;p&gt;If I take a full lunch break and finish at 5, I feel like I didn’t work enough. If I stay online until 8pm (5pm PST) I feel like I worked way too much. I’m going to have to work a lot harder on finding the perfect balance to strike going forward.&lt;/p&gt;
&lt;h3 id=&quot;conclusion&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/my-first-month-as-a-remote-worker/#conclusion&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Conclusion&lt;/h3&gt;
&lt;p&gt;I’m really loving working remotely. I think it’s going to be a great way forward for me. It does come with its own unique challenges and I’ll have to develop some new routines and systems to handle those.&lt;/p&gt;
&lt;p&gt;Any of you work remotely? Got any tips? I’d love to hear them in the comments!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Outages and blame culture</title>
		<link href="https://jonkuperman.com/outages-and-blame-culture/"/>
		<updated>2019-12-09T00:00:00Z</updated>
		<id>https://jonkuperman.com/outages-and-blame-culture/</id>
		<content type="html">&lt;p&gt;If you work with software, you experience bugs. If you work with cloud software, sometimes those bugs cause outages.&lt;/p&gt;
&lt;p&gt;Every job I&#39;ve had has some approach to &amp;quot;dealing&amp;quot; with outages. There&#39;s usually some form of an on-call person. Maybe there is an Operations team to help organize (paging the on-call, getting other teams involved, deducing root cause, writing up a report). This is great because if you don&#39;t document, it&#39;s easy to have rose-colored glasses and feel like things don&#39;t happen &amp;quot;that often.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Some companies even make you present your &amp;quot;findings&amp;quot; after each outage. This can have value in showing your company what happened and what steps you are talking to prevent it from happening again. That&#39;s the critical thing, answering two questions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;What could we do to prevent something like this from happening again?&lt;/li&gt;
&lt;li&gt;How can we be 100% sure this exact thing won&#39;t happen again?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Some companies put you through the wringer. They force you to write multiple docs explaining what happened and attend many public meetings where you must fall on your sword and tell rooms full of strangers how you messed up and that it will &amp;quot;not happen again.&amp;quot;&lt;/p&gt;
&lt;p&gt;This might seem like a good idea! The more punishing you are around outages, the more you drive the point home that we all must have a very high quality bar. The problem is, it backfires in a lot of strange and nasty ways.&lt;/p&gt;
&lt;p&gt;Companies that overly punish outages end up with blame game cultures. If a client team and a service team are on a call about an outage, and whoever takes the &amp;quot;blame&amp;quot; will have to write docs and attend meetings for the next three weeks, it becomes a very high stakes game of hot potato.&lt;/p&gt;
&lt;p&gt;Another problem with this culture is many outages don&#39;t have a single team at fault. Maybe a client team was misusing an API, but that API wasn&#39;t documented, or returned an incorrect error code!&lt;/p&gt;
&lt;p&gt;TL;DR Companies should be careful about how much they punish teams for having outages and flexible enough to understand that many outages share blame across multiple teams. It&#39;s better to focus on these three things alone:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;What happened?&lt;/li&gt;
&lt;li&gt;How can we prevent that specific thing from ever happening again?&lt;/li&gt;
&lt;li&gt;Are there any things we learned that could help us prevent similar things from happening?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;And call it a day.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Managing Immutable State with Object Spread</title>
		<link href="https://jonkuperman.com/immutable-state-with-object-spread/"/>
		<updated>2019-12-01T00:00:00Z</updated>
		<id>https://jonkuperman.com/immutable-state-with-object-spread/</id>
		<content type="html">&lt;p&gt;There are a lot of great libraries for managing immutable state in your web apps. &lt;a href=&quot;https://redux.js.org/&quot;&gt;Redux&lt;/a&gt; and &lt;a href=&quot;https://immerjs.github.io/immer/&quot;&gt;Immer&lt;/a&gt; are two great examples.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;When workings with libraries like these, you often need to create functions that take in the current state object and a piece of new data and return a new state object for which the only difference is the piece of new data.&lt;/p&gt;
&lt;p&gt;Let&#39;s look at a quick example:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; state &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;User 1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;User 2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;topics&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Topic 1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;My first topic&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Topic 2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;My second topic!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; newUser &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;User 3&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;addUser&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;state&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; newUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;users&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;newUser&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; state
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This works totally fine. But if we look at this line&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;users&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;newUser&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can see that we are &lt;strong&gt;mutating&lt;/strong&gt; the state object, by pushing a new item onto the &lt;code&gt;users&lt;/code&gt; array.&lt;/p&gt;
&lt;h2 id=&quot;mutable-vs-immutable&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/immutable-state-with-object-spread/#mutable-vs-immutable&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Mutable vs Immutable&lt;/h2&gt;
&lt;p&gt;For those not familiar, let&#39;s take a look at what we mean by mutability. Say you have an array of numbers:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; arr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And you want to add 1 to each number. You could do this by mutating or changing the existing array:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; arr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  arr&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;arr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// [2, 3, 4, 5, 6]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another approach we could take is to create a &lt;strong&gt;new&lt;/strong&gt; array with our changes, while keeping the original one around. We can use a method like &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map&quot;&gt;Array.prototype.map&lt;/a&gt; to accomplish this.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; arr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; newArr &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; arr&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;newArr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// [2, 3, 4, 5, 6]&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;arr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// [1, 2, 3, 4, 5]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The second approach is what we&#39;d consider immutable as we never change (or mutate) the original array.&lt;/p&gt;
&lt;h2 id=&quot;why-have-immutable-state&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/immutable-state-with-object-spread/#why-have-immutable-state&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Why have immutable state?&lt;/h2&gt;
&lt;p&gt;Many popular libraries encourage an &lt;strong&gt;immutable&lt;/strong&gt; approach to state for a few reasons.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Performance&lt;/strong&gt;. View libraries like React which compute changes can move a lot faster with immutable data structures.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Undo&lt;/strong&gt;. Allowing users to &amp;quot;undo&amp;quot; an action is the holy grail of state management. With immmutable data structures, we can just keep the previous state around (or even just a log of state changes) and easily allow users to revert a change.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bugs&lt;/strong&gt;. There are a whole category of bugs that can be caused when mutating an object directly. An immutable approach ensures there is never invalid state and in the worst case state can always be reverted.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Testability&lt;/strong&gt;. Immutable state changes are dead simple to test.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;making-the-adduser-function-immutable-with-object-spread&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/immutable-state-with-object-spread/#making-the-adduser-function-immutable-with-object-spread&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Making the addUser function immutable with Object Spread&lt;/h2&gt;
&lt;p&gt;One great language feature for this type of work is the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax&quot;&gt;spread syntax&lt;/a&gt;. This allows us to write really clean code for immutable state operations that generate new objects comprised mostly of values of the original object. Let&#39;s take a look at our &lt;code&gt;addUser&lt;/code&gt; function again.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; state &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;User 1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;User 2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;topics&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Topic 1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;My first topic&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Topic 2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;My second topic!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; newUser &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;User 3&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;addUser&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;state&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; newUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;users&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; newUser&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; newState &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;addUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; newUser&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;newState&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 3 users&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// old state with 2 users&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	<entry>
		<title>Compiled vs. Interpreted Languages</title>
		<link href="https://jonkuperman.com/compiled-vs-interpreted/"/>
		<updated>2019-11-08T00:00:00Z</updated>
		<id>https://jonkuperman.com/compiled-vs-interpreted/</id>
		<content type="html">&lt;p&gt;I&#39;ve been reading this &lt;a href=&quot;http://craftinginterpreters.com/&quot;&gt;fantastic book&lt;/a&gt; called &amp;quot;Crafting Interpreters&amp;quot; lately by Bob Nystrom.&lt;/p&gt;
&lt;p&gt;It talks about the different types of programming languages. We can think about all compilers as falling into three categories.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Compilers that output machine code.&lt;/li&gt;
&lt;li&gt;Compilers that output bytecode and need to be interpreted.&lt;/li&gt;
&lt;li&gt;Compilers that output an intermediary format and then hand it off to another compiler.&lt;/li&gt;
&lt;/ol&gt;
&lt;hr /&gt;
&lt;p&gt;There is a lot I find interesting about the book so far, but one thing that I was fascinated to read about the differences between &amp;quot;compiled&amp;quot; and &amp;quot;interpreted&amp;quot; languages.&lt;/p&gt;
&lt;p&gt;Bob talks about if you are building a new language, you need to need to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Build a parser to handle your new syntax and build an AST.&lt;/li&gt;
&lt;li&gt;Write any transformations or optimizations.&lt;/li&gt;
&lt;li&gt;Build a generator to generate output code.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This third step is the really interesting one!&lt;/p&gt;
&lt;p&gt;An example of a compiler that does #3 from above (Compilers that output an intermediary format and then hand it off to another compiler) would be &lt;a href=&quot;https://babeljs.io/&quot;&gt;Babel&lt;/a&gt;. Babel basically works like this.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Let users author ES6+ JavaScript.&lt;/li&gt;
&lt;li&gt;Turn it into an AST.&lt;/li&gt;
&lt;li&gt;Transform the AST into the equivalent ES5 AST.&lt;/li&gt;
&lt;li&gt;Convert the AST to JavaScript.&lt;/li&gt;
&lt;li&gt;Hand that JavaScript off to a different compiler (the one in your browser).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So, in this case, the &amp;quot;output code&amp;quot; that Babel generates is just JavaScript! But what if we wanted to make a language that actually generated CPU instructions?&lt;/p&gt;
&lt;h2 id=&quot;compiled-vs.-interpreted&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/compiled-vs-interpreted/#compiled-vs.-interpreted&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Compiled vs. Interpreted&lt;/h2&gt;
&lt;h3 id=&quot;compiled&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/compiled-vs-interpreted/#compiled&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Compiled&lt;/h3&gt;
&lt;p&gt;If you are building a language that must run on multiple processor architectures (let&#39;s say x86 and ARM), you&#39;ll need to write two different &amp;quot;back ends&amp;quot; or &amp;quot;generators.&amp;quot; These will both take the same AST your compiler created and output CPU specific instructions (this is a lot of work!). These are what we refer to as &amp;quot;compiled&amp;quot; languages. Every compiled language has a custom generator for each CPU architecture they support.&lt;/p&gt;
&lt;h3 id=&quot;interpreted&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/compiled-vs-interpreted/#interpreted&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Interpreted&lt;/h3&gt;
&lt;p&gt;Another approach would be to build a single generator. Instead of having it generate code for an existing CPU architecture, you could have it generate code for a &amp;quot;virtual&amp;quot; or &amp;quot;hypothetical&amp;quot; CPU. This is what Java does and we refer to the output as &amp;quot;bytecode.&amp;quot;&lt;/p&gt;
&lt;p&gt;If you create an interpreted language, you&#39;ll need to also build a &amp;quot;virtual machine&amp;quot; so that your hypothetical CPU code can run on real CPUs. This is where things are kind of neat but a little confusing.&lt;/p&gt;
&lt;p&gt;If you build a VM (something capable of executing your generated bytecode) in an existing language, then the VM can run on any CPU architecture that compiles that language. So you can:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Write in a custom langauge&lt;/li&gt;
&lt;li&gt;Compile it to your custom bytecode&lt;/li&gt;
&lt;li&gt;Make a small VM in a popular language like C&lt;/li&gt;
&lt;li&gt;Now your custom language has only one generator and can run anywhere that C can compile!&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I thought this was an interesting distinction and made the different approaches C++ and Java took seem a lot more like a reasonable trade-off as opposed to a mystery.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Numbering a list with CSS!</title>
		<link href="https://jonkuperman.com/numbering-a-list-with-css/"/>
		<updated>2019-10-13T00:00:00Z</updated>
		<id>https://jonkuperman.com/numbering-a-list-with-css/</id>
		<content type="html">&lt;p&gt;Yesterday, I converted my site to 11ty. I decided to use their &lt;a href=&quot;https://github.com/11ty/eleventy-base-blog&quot;&gt;base blog starter&lt;/a&gt; and when I did, I noticed this cool UI they have for listing your posts.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/my-website.png&quot; alt=&quot;Screenshot of my website.&quot; /&gt;&lt;/p&gt;
&lt;p&gt;When I went to change the styling, I noticed that these numbers get added, entirely with CSS! Let&#39;s take a look at how they do this.&lt;/p&gt;
&lt;p&gt;This works by combining CSS &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/counter-increment&quot;&gt;counter increment&lt;/a&gt; with &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Lists_and_Counters/Using_CSS_counters&quot;&gt;CSS counters&lt;/a&gt;. All you have to do is this:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ol&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;myList&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;One&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Two&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Three&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ol&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then style it with&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.myList li&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;counter-increment&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; start-from 1&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;.myList li:before&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;start-from&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; decimal-leading-zero&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;. &quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	<entry>
		<title>Eleventy has me feeling more connected with my website</title>
		<link href="https://jonkuperman.com/feeling-connected-with-my-website/"/>
		<updated>2019-10-12T00:00:00Z</updated>
		<id>https://jonkuperman.com/feeling-connected-with-my-website/</id>
		<content type="html">&lt;p&gt;I&#39;ve been using &lt;a href=&quot;https://www.gatsbyjs.org/&quot;&gt;Gatsby&lt;/a&gt; on my site for ages. I enjoy using it. It&#39;s pretty easy to get up and running with, it loads quickly, and it comes with some great plugins like this one for &lt;a href=&quot;https://www.gatsbyjs.org/docs/working-with-images/&quot;&gt;optimizing images&lt;/a&gt;. It deploys easily and has all the benefits of a static site (you don&#39;t have to worry about maintaining your own databases or servers). The thing is, though, there&#39;s a lot to it.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;img src=&quot;https://jonkuperman.com/img/11ty_logo.png&quot; alt=&quot;Eleventy Logo.&quot; /&gt;&lt;/p&gt;
&lt;p&gt;There&#39;s no way of avoiding having to use React, Helmet, GraphQL, a complicated build system, tons of plugins, etc. After a fair amount of time, I started feeling pretty disconnected from the HTML/CSS I was trying to produce on my blog.&lt;/p&gt;
&lt;p&gt;I&#39;d heard a ton of great stuff about &lt;a href=&quot;https://www.11ty.io/&quot;&gt;11ty&lt;/a&gt;, a new static site generator that&#39;s supposed to be very simple to use. So I figured I&#39;d give it a try. I moved my site over pretty quickly using their &lt;a href=&quot;https://github.com/11ty/eleventy-base-blog&quot;&gt;base blog repo&lt;/a&gt;, and so far, it feels great being a little &amp;quot;closer to the wire&amp;quot; to my content.&lt;/p&gt;
&lt;p&gt;We&#39;ll see how it goes.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Easier Type Safety in JavaScript Classes</title>
		<link href="https://jonkuperman.com/easier-type-safety-in-javascript-classes/"/>
		<updated>2019-07-09T00:00:00Z</updated>
		<id>https://jonkuperman.com/easier-type-safety-in-javascript-classes/</id>
		<content type="html">&lt;p&gt;I work with TypeScript a lot at Adobe. It&#39;s really great for so many reasons, but I often find new shorthand tricks I wish I knew when I was getting started! This is one of those tricks.&lt;/p&gt;
&lt;p&gt;Let&#39;s say you have a &lt;code&gt;Person&lt;/code&gt; class with a few properties.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; age&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; job&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; name
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;age &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; age
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;job &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; job
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;Now you can call it like this.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; person &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Jon&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;31&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Programmer&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;person&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Jon&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now let&#39;s say you want to add some types to this class, so it errors if people misuse it.&lt;/p&gt;
&lt;p&gt;You might try doing something like:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; string&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; number&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;job&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; name
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;age &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; age
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;job &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; job
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; person &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Jon&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;31&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Programmer&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;person&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Jon&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But then you&#39;d get an error saying.&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;Property &lt;span class=&quot;token string&quot;&gt;&#39;name&#39;&lt;/span&gt; does not exist on &lt;span class=&quot;token builtin class-name&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Person&#39;&lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So then you might try to move the type declarations to the class properties like this.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; string
  &lt;span class=&quot;token literal-property property&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; number
  &lt;span class=&quot;token literal-property property&quot;&gt;job&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; string

  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; age&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; job&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; name
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;age &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; age
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;job &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; job
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; person &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Jon&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;31&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Programmer&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Does not error :(&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;person&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Jon&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now this compiles! But, it no longer has the type information for the constructor parameters, so it doesn&#39;t error even though you pass in a string for age instead of a number.&lt;/p&gt;
&lt;p&gt;So then you might take this long-winded approach and add duplicate type declarations to the class properties as well as the constructor parameters.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; string&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; number&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;job&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; string&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; string&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; number&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;job&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;age &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; age&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;job &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; job&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; person &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Jon&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;31, &#39;&lt;/span&gt;Programmer&#39;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Errors! :)&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;person&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;age&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Jon&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And now we get the type safety we&#39;ve been looking for!&lt;/p&gt;
&lt;p&gt;The shorthand I learned today is that you can add access modifiers to your constructor parameters and then TypeScript will automatically set those parameters as class values when initialized.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; string&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; number&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;job&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; person &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Jon&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;31&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Programmer&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Errors! :)&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;person&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;age&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Jon&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;TypeScript&#39;s access modifiers allow you to set class properties as &lt;code&gt;public&lt;/code&gt;, &lt;code&gt;private&lt;/code&gt; and &lt;code&gt;protected&lt;/code&gt;. All class properties are &lt;code&gt;public&lt;/code&gt; by default, but this neat trick will save you a good amount of lines while preserving type safety.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Writing a Babel plugin to convert arrow functions to function expressions</title>
		<link href="https://jonkuperman.com/converting-arrow-functions-to-function-expressions-babel/"/>
		<updated>2018-11-20T00:00:00Z</updated>
		<id>https://jonkuperman.com/converting-arrow-functions-to-function-expressions-babel/</id>
		<content type="html">&lt;p&gt;I&#39;m still (slowly) learning how to work with ASTs and tools that use them. Today I wanted to learn how Babel takes arrow functions like:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;log&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;message&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and converts it into ES5 function expressions like:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;log&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;message&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;Hilariously, Acorn (the JavaScript parser that Babel uses) comes with a built-in &lt;code&gt;arrowFunctionToExpression&lt;/code&gt; method!&lt;/p&gt;
&lt;p&gt;If we head over to &lt;a href=&quot;https://astexplorer.net/&quot;&gt;astexplorer.net&lt;/a&gt; and type in the code that we want to transform, we get an Abstract Syntax Tree like:&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;File&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;45&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;loc&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;44&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;program&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Program&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;45&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;loc&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;44&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;sourceType&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;module&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;interpreter&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token null keyword&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;body&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;VariableDeclaration&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;45&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token property&quot;&gt;&quot;loc&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;
          &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;44&lt;/span&gt;
          &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token property&quot;&gt;&quot;declarations&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
          &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;VariableDeclarator&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;44&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;loc&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;6&lt;/span&gt;
              &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;43&lt;/span&gt;
              &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;id&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Identifier&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;&quot;loc&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;6&lt;/span&gt;
                &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;9&lt;/span&gt;
                &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;&quot;identifierName&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;log&quot;&lt;/span&gt;
              &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;log&quot;&lt;/span&gt;
            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;init&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ArrowFunctionExpression&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;44&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;&quot;loc&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;12&lt;/span&gt;
                &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;43&lt;/span&gt;
                &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
              &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;&quot;id&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token null keyword&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;&quot;generator&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;&quot;async&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;&quot;params&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
                &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Identifier&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;loc&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;12&lt;/span&gt;
                    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;19&lt;/span&gt;
                    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;identifierName&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;message&quot;&lt;/span&gt;
                  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;message&quot;&lt;/span&gt;
                &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
              &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;token property&quot;&gt;&quot;body&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;CallExpression&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;44&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;&quot;loc&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;23&lt;/span&gt;
                  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;43&lt;/span&gt;
                  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
                &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;&quot;callee&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;MemberExpression&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;35&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;loc&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;23&lt;/span&gt;
                    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;34&lt;/span&gt;
                    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
                  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;object&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Identifier&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;31&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;loc&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                        &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                        &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;23&lt;/span&gt;
                      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                        &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                        &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;30&lt;/span&gt;
                      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;identifierName&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;console&quot;&lt;/span&gt;
                    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;console&quot;&lt;/span&gt;
                  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;property&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Identifier&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;32&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;35&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;loc&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                        &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                        &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;31&lt;/span&gt;
                      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                        &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                        &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;34&lt;/span&gt;
                      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;identifierName&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;log&quot;&lt;/span&gt;
                    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;log&quot;&lt;/span&gt;
                  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                  &lt;span class=&quot;token property&quot;&gt;&quot;computed&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;
                &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;token property&quot;&gt;&quot;arguments&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
                  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Identifier&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;36&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;43&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;loc&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                        &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                        &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;35&lt;/span&gt;
                      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                        &lt;span class=&quot;token property&quot;&gt;&quot;line&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                        &lt;span class=&quot;token property&quot;&gt;&quot;column&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;42&lt;/span&gt;
                      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                      &lt;span class=&quot;token property&quot;&gt;&quot;identifierName&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;message&quot;&lt;/span&gt;
                    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;message&quot;&lt;/span&gt;
                  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
                &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
              &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
          &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token property&quot;&gt;&quot;kind&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;const&quot;&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;directives&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;comments&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When making Babel plugins or anything that parses ASTs we use a Computer Science concept called the &lt;a href=&quot;https://en.wikipedia.org/wiki/Visitor_pattern&quot;&gt;Visitor Pattern&lt;/a&gt;. Basically, we pick the &amp;quot;type&amp;quot; of node we want to grab onto and then do operations on it. In our case we can our app goes &lt;em&gt;File&lt;/em&gt; -&amp;gt; &lt;em&gt;Program&lt;/em&gt; -&amp;gt; &lt;em&gt;VariableDeclaration&lt;/em&gt; -&amp;gt; &lt;em&gt;ArrowFunctionExpression&lt;/em&gt;! Perfect, we&#39;ll grab ArrowFunctionExpression.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;babel&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;types&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; t &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; babel

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;visitor&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;ArrowFunctionExpression&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;arrowFunctionToExpression&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Most of that is just boilerplate. The important bit is that we hook into all ArrowFunctionExpression&#39;s and call &lt;code&gt;arrowFunctionToExpression()&lt;/code&gt; on them. That results in the following output:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;log&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;message&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Perfect! I promise I&#39;ll try something more challenging next time :)&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Getting Started with ASTs</title>
		<link href="https://jonkuperman.com/getting-started-with-asts/"/>
		<updated>2018-11-18T00:00:00Z</updated>
		<id>https://jonkuperman.com/getting-started-with-asts/</id>
		<content type="html">&lt;p&gt;Hey all!&lt;/p&gt;
&lt;p&gt;I&#39;ve wanted to move my blog back to my domain for a while now. I miss writing a lot. Medium is excellent but makes me feel like everything I write is high stakes and needs to polish.&lt;/p&gt;
&lt;p&gt;Lately, I&#39;m interested in Abstract Syntax Trees. If you&#39;re not familiar, they are a data format used by programs like Babel, ESLint, and Webpack. ASTs are a tree representation of code. Let&#39;s take a look at a small example.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;We can head over to &lt;a href=&quot;https://astexplorer.net/&quot;&gt;AST Explorer&lt;/a&gt; and type any JavaScript we want into the top left panel. Then we&#39;ll see the equivalent AST in the top right panel.&lt;/p&gt;
&lt;p&gt;Here is some JavaScript:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Hello World!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And the AST:&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Program&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;range&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;body&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ExpressionStatement&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;range&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;expression&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;CallExpression&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;27&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token property&quot;&gt;&quot;range&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;27&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token property&quot;&gt;&quot;callee&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;MemberExpression&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token property&quot;&gt;&quot;range&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token property&quot;&gt;&quot;object&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Identifier&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;range&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;console&quot;&lt;/span&gt;
          &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token property&quot;&gt;&quot;property&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Identifier&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;range&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;log&quot;&lt;/span&gt;
          &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token property&quot;&gt;&quot;computed&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token property&quot;&gt;&quot;arguments&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
          &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Literal&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;start&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;26&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;range&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;26&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;value&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Hello World!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token property&quot;&gt;&quot;raw&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&#39;Hello World!&#39;&quot;&lt;/span&gt;
          &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;sourceType&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;module&quot;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;ASTs are an intermediary representation of your code. They allow you to do things like transpilation, linting or bundling. I&#39;m especially interested in contributing to some of these projects. I&#39;ve been spending a lot of my free time learning more about ASTs, languages, and compilers in general.&lt;/p&gt;
&lt;p&gt;Here are some of the resources I&#39;ve found helpful:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md&quot;&gt;The Babel Plugin Handbook&lt;/a&gt; It&#39;s somewhat out of date but full of great information for making Babel plugins and understanding important concepts like the Visitor Pattern.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://frontendmasters.com/courses/linting-asts/&quot;&gt;Code Transformation and Linting with ASTs&lt;/a&gt; This course by Kent C. Dodds is excellent for beginners who want to get their feet wet making some plugins for ESLint and Babel.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://a.co/d/b13e3q5&quot;&gt;Language Implementation Patterns&lt;/a&gt; This book is excellent, although a bit on the heavy side. It talks about the shared patterns across all languages and compiles and offers straightforward examples of each.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.amazon.com/Compilers-Principles-Techniques-Tools-2nd/dp/0321486811&quot;&gt;Compilers: Principles, Techniques, and Tools&lt;/a&gt; The &amp;quot;Dragon&amp;quot; book. This is the de-facto book in our industry when it comes to writing compilers. I haven&#39;t finished it yet so I&#39;ll hold off on my thoughts until then!&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Have you done any work with ASTs or compilers? Did you find any helpful resources that I didn&#39;t mention here? Drop me a comment on Twitter &lt;a href=&quot;https://twitter.com/jkup&quot;&gt;@jkup&lt;/a&gt;! I&#39;d love to hear from you.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Lighthouse Error: Content is not sized correctly for the viewport</title>
		<link href="https://jonkuperman.com/content-is-not-sized-correctly-for-the-viewport/"/>
		<updated>2018-11-18T00:00:00Z</updated>
		<id>https://jonkuperman.com/content-is-not-sized-correctly-for-the-viewport/</id>
		<content type="html">&lt;p&gt;If you&#39;re like me, you probably spend quite a bit of time chasing those perfect 100&#39;s in &lt;a href=&quot;https://developers.google.com/web/tools/lighthouse/&quot;&gt;Lighthouse&lt;/a&gt;. One error I&#39;ve run into multiple times is &lt;code&gt;Content is not sized correctly for the viewport&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This error can occur for multiple reasons. The Lighthouse rule checks&lt;/p&gt;
&lt;hr /&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;innerWidth &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;outerWidth&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Sometimes you have some quirky CSS causing this problem but something that&#39;s happened to me time and time again is leaving my browser tab zoomed in. If you zoom in our out before running a Lighthouse Audit, it can report back a false positive for content not being correctly sized for the viewport.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://twitter.com/jkup/status/1064354253831958529&quot;&gt;https://twitter.com/jkup/status/1064354253831958529&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is because the value of &lt;code&gt;window.innerWidth&lt;/code&gt; changes as you zoom in or out but &lt;code&gt;window.outerWidth&lt;/code&gt; stays the same!&lt;/p&gt;
&lt;p&gt;So make sure you cmd+0 (or ctrl+0) before running that audit!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Add a Service Worker to Jekyll blog on GitHub Pages</title>
		<link href="https://jonkuperman.com/adding-service-worker-jekyll-github-page/"/>
		<updated>2018-11-18T00:00:00Z</updated>
		<id>https://jonkuperman.com/adding-service-worker-jekyll-github-page/</id>
		<content type="html">&lt;p&gt;I need to refresh my blog!&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;...famous last words&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;After a few days of researching all the latest and greatest technology, I ended up back where I started. Running a &lt;a href=&quot;https://jekyllrb.com/&quot;&gt;Jekyll&lt;/a&gt; blog on &lt;a href=&quot;https://pages.github.com/&quot;&gt;GitHub Pages&lt;/a&gt;. Although there are a lot of great options out there, I&#39;m pretty lazy, and this approach still works great!&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;One thing I was excited about with an alternative like &lt;a href=&quot;https://www.gatsbyjs.org/&quot;&gt;Gatsby&lt;/a&gt; or &lt;a href=&quot;https://nextjs.org/&quot;&gt;Next.js&lt;/a&gt; was taking advantage of some of the new web APIs like &lt;a href=&quot;https://developers.google.com/web/fundamentals/primers/service-workers/&quot;&gt;Service Workers&lt;/a&gt; and &lt;a href=&quot;https://developers.google.com/web/fundamentals/web-app-manifest/&quot;&gt;Manifest&lt;/a&gt; files. Luckily I found a &lt;a href=&quot;https://github.com/lavas-project/jekyll-pwa&quot;&gt;great looking plugin&lt;/a&gt; which generates Service Workers for you!&lt;/p&gt;
&lt;h2 id=&quot;not-so-fast&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/adding-service-worker-jekyll-github-page/#not-so-fast&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Not So Fast&lt;/h2&gt;
&lt;p&gt;I installed the PWA plugin, configured it, and noticed it running smoothly in development! It couldn&#39;t have been easier. Unfortunately, when I went to deploy it to production, I didn&#39;t see the Service Worker, and the app was not available offline!&lt;/p&gt;
&lt;p&gt;It seems like while GitHub pages host Jekyll sites easily, they run Jekyll in &amp;quot;safe mode&amp;quot; which disallows the use of many plugins. Back to the drawing board.&lt;/p&gt;
&lt;p&gt;My next thought was to check out &lt;a href=&quot;https://developers.google.com/web/tools/workbox/&quot;&gt;Workbox&lt;/a&gt;. Workbox is an initiative by the folks at Google to make Service Worker generation and customization easy.&lt;/p&gt;
&lt;p&gt;I&#39;ve used Workbox before with JS heavy apps alongside build tools like Gulp and Webpack. The integration with these build tools is seamless, but they didn&#39;t have a clean option for Jekyll.&lt;/p&gt;
&lt;h2 id=&quot;introducing-workbox-cli!&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/adding-service-worker-jekyll-github-page/#introducing-workbox-cli!&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Introducing workbox-cli!&lt;/h2&gt;
&lt;p&gt;Workbox provides an &lt;a href=&quot;https://developers.google.com/web/tools/workbox/modules/workbox-cli&quot;&gt;out of the box solution&lt;/a&gt; for apps that don&#39;t use Webpack or Gulp. It&#39;s a standalone CLI app that can be installed with &lt;code&gt;npm install workbox-cli -g&lt;/code&gt; and then used with a command like &lt;code&gt;workbox wizard&lt;/code&gt;. The wizard generates a workbox-config.js file which then can be used to generate a service-worker.js file. Here is my lightweight configuration:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;exports &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;globDirectory&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;./_site&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;globPatterns&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;**/*.{html,css,png,ico,xml,json,js}&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;swDest&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;./sw.js&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which generates something like this:&lt;/p&gt;
&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/**
 * Welcome to your Workbox-powered service worker!
 *
 * You&#39;ll need to register this file in your web app and you should
 * disable HTTP caching for this file too.
 * See https://goo.gl/nhQhGp
 *
 * The rest of the code is auto-generated. Please don&#39;t update this file
 * directly; instead, make changes to your Workbox build configuration
 * and re-run your build process.
 * See https://goo.gl/2aRDsh
 */&lt;/span&gt;

importScripts(&lt;span class=&quot;token string&quot;&gt;&quot;https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js&quot;&lt;/span&gt;);

&lt;span class=&quot;token comment&quot;&gt;/**
 * The workboxSW.precacheAndRoute() method efficiently caches and responds to
 * requests for URLs in the manifest.
 * See https://goo.gl/S9QRab
 */&lt;/span&gt;
self.__precacheManifest = &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;2018/11/18/content-is-not-sized-correctly-for-the-viewport.html&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;b8296e61e61b180e1b4f7606c332d27a&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;2018/11/18/getting-started-with-asts.html&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;9a7f7ec5aee1b59c98179f4eee0c4051&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;css/style.css&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;5a5ff92978aed905a5cfcd43acdd3ed1&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;favicon-16x16.png&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;c11b060a3fc097bb5dfa397801696181&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;favicon-32x32.png&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;4106c0929ea4e86af8b4c32b3c5cb005&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;favicon-96x96.png&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;258c7595bce80a8c608e51ae227d84eb&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;favicon.ico&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;b4edcd8aecd2b771aec9a39cb032f740&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;feed.xml&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;a4e7f5bdfb297a383c7e6e513abdb5a8&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;google115b0b3efae5b385.html&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;4be3d71ff251a338c77a1e0d2e263e53&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;images/icons/icon-128x128.png&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;406286c197ab21ec8bfc84bef3bbfd92&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;images/icons/icon-144x144.png&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;05d0ef9821328286268e681a4edb649d&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;images/icons/icon-152x152.png&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;5319ce81e0070ed214e0904053d91a43&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;images/icons/icon-192x192.png&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;6738ac38beff3020bc1478994b6b1dd1&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;images/icons/icon-384x384.png&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;2bd87bce217800ce8611c965b4e16c5c&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;images/icons/icon-512x512.png&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;068ef79122e182e250ea12d541204655&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;images/icons/icon-72x72.png&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;efe5da2908f53b6704e8e31a5691c6c0&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;images/icons/icon-96x96.png&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;d992f5f38ea810ae6d062138b3070909&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;index.html&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;4a2eab3f48167712ece3bdaea38f88bf&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;manifest.json&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;cf78eefd76455d552c13a40594d9476c&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;workbox-config.js&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;revision&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;5a236654f477f68ae3829b7f219715db&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;.concat(self.__precacheManifest || &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;);
workbox.precaching.suppressWarnings();
workbox.precaching.precacheAndRoute(self.__precacheManifest&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;);&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The specific thing to note (which makes this work well with Jekyll) is that Workbox gathers its list of files from the generated _site/ directory. If Workbox wrote the sw.js file to that directory it would just get deleted on the next Jekyll serve. Instead it reads from _site/ and writes to ./ so that the generated file will be put back in _site/ by Jekyll serve.&lt;/p&gt;
&lt;p&gt;Does anyone have a better approach?&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Staying Mostly Safe Online</title>
		<link href="https://jonkuperman.com/staying-mostly-safe-online/"/>
		<updated>2016-11-14T00:00:00Z</updated>
		<id>https://jonkuperman.com/staying-mostly-safe-online/</id>
		<content type="html">&lt;h1 id=&quot;staying-mostly-safe-online&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/staying-mostly-safe-online/#staying-mostly-safe-online&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Staying Mostly Safe Online&lt;/h1&gt;
&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/2000/0*IaiYD3_nHw9p4LJi.jpeg&quot; alt=&quot;Anonymous Hacker so you know this is a legit post&quot; /&gt;&lt;/p&gt;
&lt;p&gt;2016 has become the year of the data breach. With massive hacks affecting &lt;a href=&quot;http://krebsonsecurity.com/2016/05/fraudsters-steal-tax-salary-data-from-adp/&quot;&gt;ADP&lt;/a&gt;, the &lt;a href=&quot;http://motherboard.vice.com/read/hacker-plans-to-dump-alleged-details-of-20000-fbi-9000-dhs-employees&quot;&gt;Department of Homeland Security&lt;/a&gt;, the &lt;a href=&quot;http://fortune.com/2016/02/10/irs-hack-refunds/&quot;&gt;Internal Revenue Service&lt;/a&gt;, &lt;a href=&quot;http://www.makeuseof.com/tag/need-know-massive-linkedin-accounts-leak/&quot;&gt;LinkedIn&lt;/a&gt; and &lt;a href=&quot;https://www.wired.com/2016/05/hack-brief-old-myspace-account-just-came-back-haunt/&quot;&gt;Myspace&lt;/a&gt; to name a few. It’s more important than ever before to talk about staying safe online.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;The &lt;a href=&quot;https://ssd.eff.org/en&quot;&gt;Electronic Frontier Foundation&lt;/a&gt; has a great page dedicated to educating users on “Surveillance Self Defense” but I’ve always wished they would be more liberal with a cheat sheet of good general tools you can use to stay safe(er) online. So here is mine:&lt;/p&gt;
&lt;h2 id=&quot;passwords&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/staying-mostly-safe-online/#passwords&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Passwords&lt;/h2&gt;
&lt;p&gt;One of the best things you can do to stay safe online is to have secure and unique passwords for all of your sites.&lt;/p&gt;
&lt;h2 id=&quot;password-managers&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/staying-mostly-safe-online/#password-managers&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Password Managers&lt;/h2&gt;
&lt;p&gt;The idea of memorizing dozens of different passwords for all of your websites is overwhelming! Luckily there is no need to. I recommend downloading a password manager immediately (&lt;a href=&quot;https://1password.com/&quot;&gt;1Password&lt;/a&gt; if you only need Mac/Windows and &lt;a href=&quot;https://www.lastpass.com/&quot;&gt;Lastpass&lt;/a&gt; if you need Linux support).&lt;/p&gt;
&lt;p&gt;Password managers help you out by easily allowing you to generate long and unique passwords for each site you visit. You only have one master password to remember and then you simply “unlock” passwords for sites as you use them.&lt;/p&gt;
&lt;p&gt;These password managers have the added advantage autocompleting login forms but &lt;em&gt;only&lt;/em&gt; autocompleting when you are on the correct domain! This means they will not only help you with hard to crack passwords but help you avoid &lt;a href=&quot;https://en.wikipedia.org/wiki/Phishing&quot;&gt;Phishing&lt;/a&gt; attempts where bad sites make themselves look like good sites in an attempt to get your login credentials.&lt;/p&gt;
&lt;h2 id=&quot;general-rules&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/staying-mostly-safe-online/#general-rules&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; General rules&lt;/h2&gt;
&lt;p&gt;Aside from using a password manager the general rules for passwords are easier to remember if you understand how passwords are stolen in the first place.&lt;/p&gt;
&lt;p&gt;There are two main types of password attacks which can be mitigated by choosing a “strong” password.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Brute Force&lt;/strong&gt;: This type of attack uses a computer program to try as many passwords as possible until it finally gets it. This means common passwords (Password123) and short passwords are easier to crack. &lt;strong&gt;So make yours long and uncommon&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Dictionary Attack&lt;/strong&gt;: This type of attack uses a list of common words in an attempt to speed up figuring out your password. This means a password like (MySecretPass) will be a lot easier to crack than (1lk2j3b). &lt;strong&gt;So at least add some randomness to your password&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/2800/0*yC692JjiI6-zg2uI.png&quot; alt=&quot;1Password Home Screen&quot; /&gt;&lt;em&gt;1Password Home Screen&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;browsing&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/staying-mostly-safe-online/#browsing&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Browsing&lt;/h2&gt;
&lt;p&gt;Browsing the internet makes you vulnerable to many different types of attacks. Fortunately there are tools available to make browsing the web a lot safer!&lt;/p&gt;
&lt;p&gt;Here are the things that can go wrong while browsing the internet and tools I recommend to mitigate risks.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;You are growing the web on an unsecured wireless network and someone is sitting there reading all your secret data (&lt;a href=&quot;https://en.wikipedia.org/wiki/Man-in-the-middle_attack&quot;&gt;man-in-the-middle attack&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The easiest thing you can do here is invest in a good Virtual Private Network (&lt;a href=&quot;https://en.wikipedia.org/wiki/Virtual_private_network&quot;&gt;VPN&lt;/a&gt;). I personally use &lt;a href=&quot;https://www.expressvpn.com/&quot;&gt;ExpressVPN&lt;/a&gt; but I’ve heard great things about &lt;a href=&quot;https://www.privateinternetaccess.com/&quot;&gt;Private Internet Access&lt;/a&gt; as well! They cost about $7 a month and are essentially just a little app you put on your phone and computer that will keep you safe on public networks.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/2000/0*9hxmFxb2CDZpxu_x.png&quot; alt=&quot;Express VPN connect screen&quot; /&gt;&lt;/p&gt;
&lt;p&gt;VPN’s also give you protection from your Internet Service Provider. If you’d rather Comcast not know what you are doing online, a VPN will encrypt all of your traffic and keep your privacy.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You are being tracked by advertising companies on every site you visit. Sometimes they even collude to share your data with each other. They know what you are shopping for, what illnesses you have and use that information to hike up prices and target you for advertising.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The easiest thing to do here is use a browser that prevents that sort of tracking. I use &lt;a href=&quot;https://brave.com/&quot;&gt;Brave browser&lt;/a&gt; (confession: I also work there!) but if you are happy with Chrome or Firefox you can supplement with plugins such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://adblockplus.org/&quot;&gt;Adblock Plus&lt;/a&gt; helps by stopping bad ads and trackers from making it through to your browser.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://disconnect.me/&quot;&gt;Disconnect&lt;/a&gt; stops trackers and malware and makes the web faster!&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://www.eff.org/https-everywhere&quot;&gt;HTTPS Everywhere&lt;/a&gt; Forces website to send you data securely if possible.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Last shameless Brave plug: You get all that and more for free by simply using the Brave browser.&lt;/p&gt;
&lt;h2 id=&quot;authentication&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/staying-mostly-safe-online/#authentication&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Authentication&lt;/h2&gt;
&lt;p&gt;This section relates to the password section above but it really is a separate issue.&lt;/p&gt;
&lt;p&gt;Most websites these days offer &lt;a href=&quot;https://en.wikipedia.org/wiki/Multi-factor_authentication&quot;&gt;2 Factor Authentication (2FA)&lt;/a&gt;. An easy way to think about 2FA is by thinking about entering your password as 1 factor, so this approach has you enter your password and then it requires a second factor.&lt;/p&gt;
&lt;p&gt;The most common approach is that websites will send you a text message with a short code. So you not only need your username and password but you’ll also need your cell phone to log into your account.&lt;/p&gt;
&lt;p&gt;This is great because even if someone cracked your password with one of the approaches above they still wouldn’t be able to access your account!&lt;/p&gt;
&lt;p&gt;I highly recommend setting up 2FA with &lt;strong&gt;every&lt;/strong&gt; one of your accounts that allows it.&lt;/p&gt;
&lt;p&gt;You can find a list of websites that offer 2fa on &lt;a href=&quot;https://twofactorauth.org/&quot;&gt;twofactorauth.org&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/2800/0*-8F7SVG1ky-pUlyi.png&quot; alt=&quot;two factor auth website&quot; /&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Sharing Styles with React and Aphrodite</title>
		<link href="https://jonkuperman.com/sharing-styles-react-aphrodite/"/>
		<updated>2016-11-01T00:00:00Z</updated>
		<id>https://jonkuperman.com/sharing-styles-react-aphrodite/</id>
		<content type="html">&lt;p&gt;Lately I’ve been using Khan Academy’s &lt;a href=&quot;https://github.com/Khan/aphrodite&quot;&gt;Aphrodite&lt;/a&gt; in a lot of my projects. React and Aphrodite work very well together! (although React is not a requirement) and makes managing CSS a lot easier!&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Using React and Aphrodite together makes each component look something like this:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; Component &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;react&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; StyleSheet&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; css &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;aphrodite&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; logo &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;./logo.svg&quot;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; styles &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; StyleSheet&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;textAlign&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;center&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;

  &lt;span class=&quot;token literal-property property&quot;&gt;AppLogo&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;animation&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;AppLogoSpin infinite 20s linear&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;80px&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;

  &lt;span class=&quot;token literal-property property&quot;&gt;AppHeader&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;backgroundColor&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#222&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;150px&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;20px&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;white&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;

  &lt;span class=&quot;token literal-property property&quot;&gt;AppIntro&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;fontSize&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;large&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;App&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Component&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;div className&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;styles&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;App&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
        &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;div className&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;styles&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;AppHeader&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
          &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;img src&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;logo&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; className&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;styles&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;AppLogo&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; alt&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;logo&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
          &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;h2&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;Welcome to React&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;h2&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
        &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;div&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
        &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;p className&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;styles&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;AppIntro&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
          To &lt;span class=&quot;token keyword&quot;&gt;get&lt;/span&gt; started&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; edit &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;code&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;src&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;App&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;js&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;code&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; and save to reload&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;
          &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;Click Me&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;button&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
        &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;p&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
      &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;div&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt; App&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What I love about these two together is that your styles are colocated with your JavaScript components. In practice, this means that it’s often trivial to find and fix style issues as once you’ve found the component, you’re already in the right file!&lt;/p&gt;
&lt;p&gt;Coming from a Sass / LESS background one of the things I missed most was being able to easily share styles via creating and importing specific files like Buttons.less and then including them wherever they are needed!&lt;/p&gt;
&lt;p&gt;Aphrodite allows you to pass styles as props, something like this:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;App&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Component&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Marker styles&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;styles&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;large&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; styles&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;red&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Marker&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Component&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token comment&quot;&gt;// css() accepts styles, arrays of styles (including nested arrays),&lt;/span&gt;
        &lt;span class=&quot;token comment&quot;&gt;// and falsy values including undefined.&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;div className&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;styles&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;marker&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;props&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;styles&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; styles &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; StyleSheet&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;red&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;backgroundColor&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;red&#39;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;

    &lt;span class=&quot;token literal-property property&quot;&gt;large&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;20&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;

    &lt;span class=&quot;token literal-property property&quot;&gt;marker&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;backgroundColor&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;blue&#39;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So therefore Marker gets its styling from App. The only issue here is that you’ll have to pass your shared styles all the way down through your app if a lower component needs something from its parent.&lt;/p&gt;
&lt;p&gt;In order to work around that I had an idea for creating individual .js files that export themselves as an Aphrodite StyleSheet object. That way you can create something like:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; StyleSheet &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;aphrodite&quot;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt; StyleSheet&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;Button&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;red&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and then later in your app:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; Component &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;react&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; StyleSheet&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; css &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;aphrodite&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; ButtonStyles &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;./styles/Buttons&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; logo &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;./logo.svg&quot;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; styles &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; StyleSheet&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;textAlign&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;center&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;

  &lt;span class=&quot;token literal-property property&quot;&gt;AppLogo&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;animation&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;AppLogoSpin infinite 20s linear&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;80px&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;

  &lt;span class=&quot;token literal-property property&quot;&gt;AppHeader&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;backgroundColor&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#222&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;150px&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;20px&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;white&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;

  &lt;span class=&quot;token literal-property property&quot;&gt;AppIntro&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;fontSize&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;large&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;App&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Component&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;div className&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;styles&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;App&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
        &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;div className&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;styles&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;AppHeader&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
          &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;img src&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;logo&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; className&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;styles&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;AppLogo&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; alt&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;logo&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
          &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;h2&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;Welcome to React&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;h2&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
        &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;div&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
        &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;p className&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;styles&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;AppIntro&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
          To &lt;span class=&quot;token keyword&quot;&gt;get&lt;/span&gt; started&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; edit &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;code&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;src&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;App&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;js&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;code&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; and save to reload&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;
          &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;button className&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;ButtonStyles&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Button&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;Click Me&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;button&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
        &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;p&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
      &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;div&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt; App&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It seems to work nicely so far. I’d love to hear your thoughts!&lt;/p&gt;
&lt;p&gt;Check out this &lt;a href=&quot;https://github.com/jkup/aphrodite-react&quot;&gt;demo project&lt;/a&gt; if you’d like to see an example!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>The Life of a PHP Developer</title>
		<link href="https://jonkuperman.com/life-of-a-php-developer/"/>
		<updated>2016-02-14T00:00:00Z</updated>
		<id>https://jonkuperman.com/life-of-a-php-developer/</id>
		<content type="html">&lt;h2 id=&quot;people-are-really-mean-about-php.&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/life-of-a-php-developer/#people-are-really-mean-about-php.&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; People are really mean about PHP.&lt;/h2&gt;
&lt;p&gt;I read &lt;a href=&quot;https://modelviewculture.com/pieces/c-is-manly-python-is-for-n00bs-how-false-stereotypes-turn-into-technical-truths&quot;&gt;this great article&lt;/a&gt; the other day about How False Stereotypes Turn Into Technical “Truths”&lt;/p&gt;
&lt;hr /&gt;
&lt;blockquote&gt;
&lt;p&gt;Subjective perceptions about languages impact more than just debates between idling programmers, affecting important decisions like hiring and funding.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That really got me thinking about the community perception of PHP.&lt;/p&gt;
&lt;p&gt;Today I was listening to a &lt;a href=&quot;https://devchat.tv/js-jabber/140-jsj-using-art-to-get-and-keep-people-interested-in-programming-with-jenn-schiffer/&quot;&gt;JavaScript Jabber episode&lt;/a&gt; with &lt;a href=&quot;https://twitter.com/jennschiffer&quot;&gt;Jenn Schiffer&lt;/a&gt; and she had a few awesome comments about how judgmental people are when it comes to technology and how chasing trends often detracts from making cool things that people want to use.&lt;/p&gt;
&lt;h2 id=&quot;learning-how-to-program&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/life-of-a-php-developer/#learning-how-to-program&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Learning how to program&lt;/h2&gt;
&lt;p&gt;Although JavaScript is quickly filling this role, there are a number of reasons new developers are drawn to PHP:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You want to build a website or application on a shared host.&lt;/li&gt;
&lt;li&gt;All of the books and videos you buy involve working on the LAMP stack.&lt;/li&gt;
&lt;li&gt;All of the entry-level job postings you see are for PHP developers.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;everybody-hates-php&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/life-of-a-php-developer/#everybody-hates-php&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Everybody hates PHP&lt;/h2&gt;
&lt;p&gt;Here are some examples of the negativity surrounding PHP in the programming community:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://phpsadness.com/&quot;&gt;PHP Sadness&lt;/a&gt;: An entire site devoted to tracking things that are ‘sad’ about PHP.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/&quot;&gt;PHP: a fractal of bad design&lt;/a&gt;: Another article complaining about how broken PHP is.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://whydoesitsuck.com/why-does-php-suck/&quot;&gt;Why does PHP suck?&lt;/a&gt; Another, similar article.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I don’t really have the energy to find any more of these but all over Hacker News and Reddit there are quotes like:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If you learn PHP today, you should most definitely be ostracized.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You start questioning whether or not you chose a bad language.&lt;/p&gt;
&lt;h2 id=&quot;everything-is-built-on-php&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/life-of-a-php-developer/#everything-is-built-on-php&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Everything is built on PHP&lt;/h2&gt;
&lt;p&gt;Maybe you start doubting yourself, thinking that you bet on a bad horse. It seems like everyone loves Clojure and Haskell and JavaScript and no one likes PHP. Maybe you just got lucky landing your first job?&lt;/p&gt;
&lt;p&gt;Maybe you start poking around the internet, what projects are actually built with PHP?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Facebook&lt;/li&gt;
&lt;li&gt;WordPress&lt;/li&gt;
&lt;li&gt;Yahoo&lt;/li&gt;
&lt;li&gt;Wikipedia&lt;/li&gt;
&lt;li&gt;4chan&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It’s kind of ridiculous. A large portion of the worlds largest websites are written in PHP. It seems just inarguable that PHP is a worthwhile and practical language choice for making web applications, but I digress…&lt;/p&gt;
&lt;h2 id=&quot;it&#39;s-not-2004-anymore&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/life-of-a-php-developer/#it&#39;s-not-2004-anymore&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; It’s not 2004 anymore&lt;/h2&gt;
&lt;p&gt;A lot of these criticisms of PHP are predicated on things the language was missing when they last looked in the early 2000’s.&lt;/p&gt;
&lt;p&gt;PHP has classes now and can do proper OOP. There are great frameworks like &lt;a href=&quot;http://laravel.com/&quot;&gt;Laravel&lt;/a&gt; and &lt;a href=&quot;https://symfony.com/&quot;&gt;Symfony&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;PHP has a &lt;a href=&quot;https://packagist.org/&quot;&gt;package manager&lt;/a&gt; which pulls from an enormous archive of open source packages.&lt;/p&gt;
&lt;p&gt;PHP has great testing frameworks. Unit testing frameworks like &lt;a href=&quot;https://phpunit.de/&quot;&gt;PHPUnit&lt;/a&gt; and Behavioral testing like &lt;a href=&quot;https://docs.behat.org/en/latest/&quot;&gt;Behat&lt;/a&gt; and &lt;a href=&quot;https://codeception.com/&quot;&gt;Codeception&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Some of the complaints in the aforementioned links are definitely reasonable. There are inconsistencies in the language, and there are certainly languages out there without as many problems but PHP holds up really well when you consider its age, flexibility and &lt;a href=&quot;http://www.sitepoint.com/phps-creator-rasmus-lerdorf/&quot;&gt;what it was designed for&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;the-effect-on-developers&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/life-of-a-php-developer/#the-effect-on-developers&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The effect on developers&lt;/h2&gt;
&lt;p&gt;It is incredibly discouraging not being taken seriously as a developer despite working on serious development projects. It’s really taken its toll on the community.&lt;/p&gt;
&lt;p&gt;It often feels like PHP developers end up in insular micro-communities. Feeling unwelcome in the larger software engineering community they frequently have their own meetups, their own user groups and their own conferences.&lt;/p&gt;
&lt;h2 id=&quot;anecdote&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/life-of-a-php-developer/#anecdote&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Anecdote&lt;/h2&gt;
&lt;p&gt;Sometimes I really do get tired of the judgment. Despite thinking that PHP is a perfectly fine language, I often think about abandoning PHP development entirely just so I don’t have to deal with the judgment anymore.&lt;/p&gt;
&lt;p&gt;When I was younger I looked weird. I had dyed dreadlocks, facial piercings and patched clothing. I really liked looking that way, but it was exhausting.&lt;/p&gt;
&lt;p&gt;Taking college classes, applying for internships, starting my own company. It was a constant distraction. The best case scenario was being ‘surprisingly professional’ for someone that ‘looks like I do’.&lt;/p&gt;
&lt;p&gt;10 years later, same problem — different distraction. You know a lot about compsci for a PHP developer. Bleh.&lt;/p&gt;
&lt;h2 id=&quot;no-end-in-sight&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/life-of-a-php-developer/#no-end-in-sight&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; No end in sight&lt;/h2&gt;
&lt;p&gt;Unfortunately, I really don’t see this problem going away. Often times, people are just complaining about PHP because it’s a popular thing to do. But unfortunately I don’t see it stopping any time soon.&lt;/p&gt;
&lt;p&gt;It really is unfortunate, and creates a chicken-egg situation. If PHP developers are made to feel terrible, they will leave and there will be less and less great developers working with PHP.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>ssh_exchange_identification: read: connection reset by peer</title>
		<link href="https://jonkuperman.com/connection-reset-by-peer/"/>
		<updated>2015-10-07T00:00:00Z</updated>
		<id>https://jonkuperman.com/connection-reset-by-peer/</id>
		<content type="html">&lt;p&gt;This tutorial is meant to help troubleshoot &lt;strong&gt;connection reset by peer&lt;/strong&gt; issues you might have while using SSH.&lt;/p&gt;
&lt;p&gt;Ever tried to SSH into your server and seen an error like this?&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;ssh_exchange_identification: read: Connection reset by peer&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;The first thing you should always do if SSH fails is try again with verbose logging on. Just try something like this:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ssh&lt;/span&gt; username@address.com &lt;span class=&quot;token parameter variable&quot;&gt;-vv&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the problem is on your client’s side, some sort of error should show up in that log. If you aren’t seeing anything useful in there, the problem may be with your server.&lt;/p&gt;
&lt;h2 id=&quot;the-tricky-part&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/connection-reset-by-peer/#the-tricky-part&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Tricky Part&lt;/h2&gt;
&lt;p&gt;So, how do you get on your server if you cant ssh!?&lt;/p&gt;
&lt;p&gt;If you’re lucky, your host will provide you with some sort of shell access via their web UI. If not, they should at least offer some alternative method for access. That part you’ll need to figure out for yourself.&lt;/p&gt;
&lt;h2 id=&quot;after-you-get-access&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;direct-link&quot; href=&quot;https://jonkuperman.com/connection-reset-by-peer/#after-you-get-access&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; After You Get Access&lt;/h2&gt;
&lt;p&gt;If you want to see everything that SSH is doing on the server side, here’s what you can try ( assuming Debian or Ubuntu here ):&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;service&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ssh&lt;/span&gt; stop
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; /usr/sbin/sshd &lt;span class=&quot;token parameter variable&quot;&gt;-d&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That will show you a real time log of everything that happens to SSH. If, as I suspect, you are banned from your server ( fail2ban or some other program has put your IP in /etc/hosts.deny ) you should see something like this in the log:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;debug1: Connection refused by tcp wrapper&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It could mean a number of things, but very likely you’re being blocked by hosts.deny. The simplest way to test would be to put an allow all in hosts.allow&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;vi&lt;/span&gt; /etc/hosts.allow&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and put in something like:&lt;/p&gt;
&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;sshd: ALL&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then try re-connecting. If that was your problem, try re-configuring fail2ban or whatever you have on your server that is sticking IPs into hosts.deny. If not, keep Googling! 😉&lt;/p&gt;
</content>
	</entry>
</feed>
