<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Erik Ostrom</title>
    <description>The latest articles on DEV Community by Erik Ostrom (@eostrom).</description>
    <link>https://dev.to/eostrom</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F144416%2Fb9776f7e-4aa9-4275-9629-c21307b99371.jpeg</url>
      <title>DEV Community: Erik Ostrom</title>
      <link>https://dev.to/eostrom</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/eostrom"/>
    <language>en</language>
    <item>
      <title>Svelte: first impressions</title>
      <dc:creator>Erik Ostrom</dc:creator>
      <pubDate>Wed, 31 Jul 2019 15:21:09 +0000</pubDate>
      <link>https://dev.to/eostrom/svelte-first-impressions-45ga</link>
      <guid>https://dev.to/eostrom/svelte-first-impressions-45ga</guid>
      <description>&lt;p&gt;&lt;em&gt;[cross-posted from &lt;a href="https://www.erikostrom.com/code/words/svelte-first-impressions/"&gt;my web site&lt;/a&gt;.]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://svelte.dev/"&gt;Svelte&lt;/a&gt; is "a tool for building fast web applications." Here are a few&lt;br&gt;
thoughts after running through the (excellent) &lt;a href="https://svelte.dev/tutorial/basics"&gt;tutorial&lt;/a&gt;. Just to get this out of the way: If it seems like I'm wrong about something, I probably am! All I did was read the tutorial.&lt;/p&gt;



&lt;p&gt;The first thing everyone tells you about Svelte is that... you know what? Let's skip that. You've already heard it, or if you haven't I'll tell you later.&lt;/p&gt;

&lt;p&gt;I'm excited by what reactivity feels like in Svelte. Here's some &lt;a href="https://svelte.dev/tutorial/reactive-declarations"&gt;code from the tutorial&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;$&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;doubled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;handleClick&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{handleClick}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  Clicked {count}
  {count === 1 ? 'time' : 'times'}
&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt; 

&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;{count} doubled is {doubled}&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;count&lt;/code&gt; is declared as a variable in a Svelte component. That's all it took to make it reactive. Now when it's incremented in &lt;code&gt;handleClick&lt;/code&gt;,&lt;br&gt;
the button text is automatically updated.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;$&lt;/code&gt; label signifies a &lt;i&gt;reactive declaration.&lt;/i&gt; &lt;code&gt;doubled&lt;/code&gt; is not just &lt;em&gt;initialized&lt;/em&gt; but &lt;em&gt;defined&lt;/em&gt; as &lt;code&gt;count * 2&lt;/code&gt; – meaning that whenever &lt;code&gt;count&lt;/code&gt; changes, &lt;code&gt;doubled&lt;/code&gt; is recomputed. And when &lt;code&gt;doubled&lt;/code&gt; changes, the paragraph below the button is automatically updated too.  &lt;/p&gt;

&lt;p&gt;All the modern frameworks have some version of this, and the differences are subtle. All I can say is that this feels good to me.&lt;/p&gt;



&lt;p&gt;&lt;i&gt;(By the way, how does Svelte get away with reactivity that feels this simple? Because it's not "just JavaScript." The code above looks like slightly funky HTML with an embedded script, and syntactically the script is valid JavaScript. But semantically it's different – variable assignment triggers code execution! – and that's because Svelte isn't a framework, it's a compiler. But we'll get to that.)&lt;/i&gt;&lt;/p&gt;



&lt;p&gt;Just as reactivity within components feels simple, so does data management outside of them. Here's another &lt;a href="https://svelte.dev/tutorial/custom-stores"&gt;sample from the tutorial&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;createCount&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;subscribe&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;update&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;writable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;subscribe&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;increment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="na"&gt;decrement&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="na"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;OK, that doesn't make a lot of sense out of context. But it creates a data store with a standard interface (subscribe and unsubscribe), and a custom interface (increment, decrement, reset).&lt;/p&gt;

&lt;p&gt;I don't know what it's like to use this for complex applications, but at this level, it's very appealing.  &lt;/p&gt;




&lt;p&gt;This is just a standalone feature, not a basic concept like reactivity and data stores. But I love that Svelte templates have built-in &lt;a href="https://svelte.dev/tutorial/await-blocks"&gt;syntax for promises&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;{#await promise}
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;...waiting&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
{:then number}
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;The number is {number}&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
{:catch error}
  &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"color: red"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    {error.message}
  &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
{/await}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This makes a no-brainer out of the "loading" indicators I often put off until later because they feel like tedious boilerplate.&lt;/p&gt;

&lt;p&gt;Also, bonus points for doing some basic accessibility checks at build &lt;br&gt;
time.&lt;/p&gt;




&lt;p&gt;The first thing everyone else tells you about Svelte is that it's "compiled." Most web development frameworks consist of a large bundle of code that has to be downloaded and parsed by every user's browser, and that code in turn has to interpret your application code to figure out what to put on the page from moment to moment. Svelte doesn't do that. Instead, you use Svelte to translate your application code into a small bundle of very efficient code that already knows how it has to manipulate the page.&lt;/p&gt;

&lt;p&gt;The second thing everyone tells you is that, because it's compiled, Svelte is much faster than most frameworks.&lt;/p&gt;

&lt;p&gt;To me, those aren't the most exciting things about Svelte. There are three reasons for that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;While Svelte delivers an &lt;a href="https://www.freecodecamp.org/news/a-realworld-comparison-of-front-end-frameworks-with-benchmarks-2019-update-4be0d3c78075/#metric-2-size"&gt;impressively small bundle,&lt;/a&gt; that's only one component of perceived and actual &lt;a href="https://www.freecodecamp.org/news/a-realworld-comparison-of-front-end-frameworks-with-benchmarks-2019-update-4be0d3c78075/#performance"&gt;performance&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Performance is important, but it's not the only important thing. Robustness matters. Developer experience matters.&lt;/li&gt;
&lt;li&gt;I don't know, it's just not what I think is fun.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To be clear, I'm not saying that Svelte's overall performance isn't great, or that it isn't robust, or that the developer experience is bad. (In fact, most of this post is in praise of the developer experience!) I'm just saying that the "compiled, therefore performant" story itself doesn't grab me.&lt;/p&gt;




&lt;p&gt;There are at least two things I'm curious about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is debugging like? Is it harder because the compiled JavaScript is further removed from the source code?&lt;/li&gt;
&lt;li&gt;What is testing like? (Sounds like it's a &lt;a href="https://github.com/sveltejs/svelte/wiki/FAQ#how-do-i-do-testing-svelte-apps"&gt;work in progress&lt;/a&gt;.) &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Overall, though, I'm impressed with Svelte. I'm looking forward to building something with it, and I recommend front-end developers check it out.   &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>svelte</category>
    </item>
    <item>
      <title>the feeds I read</title>
      <dc:creator>Erik Ostrom</dc:creator>
      <pubDate>Wed, 10 Apr 2019 19:03:03 +0000</pubDate>
      <link>https://dev.to/eostrom/the-feeds-i-read-30oj</link>
      <guid>https://dev.to/eostrom/the-feeds-i-read-30oj</guid>
      <description>&lt;p&gt;&lt;em&gt;[cross-posted from &lt;a href="https://www.erikostrom.com/code/words/the-feeds-i-read"&gt;my web site&lt;/a&gt;.]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;My colleague Eric asked me how I keep up on development trends, so I&lt;br&gt;
made this list of the main RSS feeds I follow (with &lt;a href="https://feedly.com"&gt;Feedly&lt;/a&gt;/&lt;a href="https://noinnion.com/greader/"&gt;gReader&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  news
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://news.vuejs.org"&gt;Vue.js News,&lt;/a&gt; because I'm just really into Vue.
Also available as a podcast. Friends, I read it &lt;em&gt;and&lt;/em&gt; I listen to it.
That's how into Vue I am.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://javascriptweekly.com"&gt;JavaScript Weekly&lt;/a&gt;  is a big (but not
too big) list of links every week: articles, announcements, tools,
tutorials, and job ads.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://changelog.com"&gt;The Changelog&lt;/a&gt; covers open source generally.
I don't read as many
links from here, but it helps me keep tabs on what the wider developer
community is talking about. This is the reason I know I should probably
know what Kubernetes is.&lt;/li&gt;
&lt;li&gt;I wasn't subscribed to &lt;a href="http://css-tricks.com/"&gt;CSS Tricks&lt;/a&gt; until
I made this list, but I seemed to wind up reading a lot of articles from
there anyway, so now I am.&lt;/li&gt;
&lt;li&gt;Also I just found &lt;a href="https://webplatform.news/"&gt;Web Platform News&lt;/a&gt;
and it looks useful.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  views
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://alistapart.com"&gt;A List Apart&lt;/a&gt; is more design-focused than
my other reads, and it goes both deep and wide – like this is where
I read last week about how to support
&lt;a href="https://alistapart.com/article/accessibility-for-vestibular"&gt;users with vestibular disorders&lt;/a&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.sandimetz.com"&gt;Sandi Metz&lt;/a&gt; hasn't published a blog post
in over a year, but I'm still subscribed because I know when she does
it'll be worth reading and then thinking about until the next one.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://avdi.codes"&gt;Avdi Grimm,&lt;/a&gt; like Sandi, is just a smart person who
thinks
a lot about how to write better software, or write software better.
And then, lucky for us, he shares his thoughts.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also I'm &lt;a href="https://dev.to"&gt;here&lt;/a&gt;, of course, and I follow a bunch of people on &lt;a href="https://twitter.com/erikostrom"&gt;Twitter&lt;/a&gt;, but that's for another day. What do you read?&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
