<?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: Johannes Zillmann</title>
    <description>The latest articles on DEV Community by Johannes Zillmann (@o_a_e).</description>
    <link>https://dev.to/o_a_e</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%2F24451%2Fe52c05b9-32dc-4cee-a50e-a628fcb98dee.jpg</url>
      <title>DEV Community: Johannes Zillmann</title>
      <link>https://dev.to/o_a_e</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/o_a_e"/>
    <language>en</language>
    <item>
      <title>CSS main page layout with resizing and scroll overflow sections</title>
      <dc:creator>Johannes Zillmann</dc:creator>
      <pubDate>Tue, 12 Sep 2023 01:56:04 +0000</pubDate>
      <link>https://dev.to/o_a_e/css-main-page-layout-with-resizing-and-scroll-overflow-sections-3glg</link>
      <guid>https://dev.to/o_a_e/css-main-page-layout-with-resizing-and-scroll-overflow-sections-3glg</guid>
      <description>&lt;p&gt;Here is a picture of the layout I want:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────┬───────────────────────┐
│ Sidebar │ Editor                │
│         │                       │
│         │                       │
│       ◄─┼─►                 ▲   │
│         │                   │   │
│         ├───────────────────┼───┤
│         │ Preview           │   │
│         │                   ▼   │
│         │  Table                │
│         │  &amp;lt;overflow-scroll&amp;gt;    │
│         │                       │
└─────────┴───────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;whole page&lt;/code&gt; should &lt;code&gt;not be scrollable&lt;/code&gt; (&lt;em&gt;more like a desktop app, 100vw +100vh&lt;/em&gt;).&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Sidebar&lt;/code&gt; should be &lt;code&gt;vertically resizable&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Editor&lt;/code&gt; should be &lt;code&gt;horizontally resizable&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Preview&lt;/code&gt; should take up the rest of the space. &lt;code&gt;Overflow&lt;/code&gt; should be managed via &lt;code&gt;vertically + horizontally scrolling&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Initial Problem
&lt;/h1&gt;

&lt;p&gt;I was using flex box instruction here and there. While that worked in general for putting things where I want them to be, ultimately it lead to parts of the table being rendered outside of the visible and reachable area.&lt;/p&gt;

&lt;p&gt;Naively I thought the browser knows what space is left for the table (because of &lt;code&gt;100vw +100vh&lt;/code&gt; on &lt;code&gt;html&lt;/code&gt;) but that isn't true.&lt;/p&gt;

&lt;p&gt;So i implemented the same layout in &lt;code&gt;css grid&lt;/code&gt; and &lt;code&gt;flex box&lt;/code&gt; (but this time a &lt;em&gt;wholesome&lt;/em&gt; flex box which wraps the entire screen vertically and horizontally).&lt;/p&gt;

&lt;h1&gt;
  
  
  Flexbox approach
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;The code is in &lt;code&gt;Svelte+Tailwind&lt;/code&gt;. Didn't take the time to unwind that further.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script lang="ts"&amp;gt;
  import Resizer from './Resizer.svelte';

  let sidebarWidth = 256;
  let topHeight = 312;
&amp;lt;/script&amp;gt;

&amp;lt;svelte:head&amp;gt;
    &amp;lt;script src="https://cdn.tailwindcss.com"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/svelte:head&amp;gt;

&amp;lt;div class="wrapper"&amp;gt;
  &amp;lt;!-- SIDEBAR --&amp;gt;
  &amp;lt;aside id="sidebar p-2" aria-label="Sidebar" class="sidebar p-2" style:--sidebar-width={sidebarWidth}&amp;gt;
    &amp;lt;span class="font-bold text-xl"&amp;gt;Sidebar:&amp;lt;/span&amp;gt;
    &amp;lt;span&amp;gt;
      Lorem ipsum!
    &amp;lt;/span&amp;gt;
  &amp;lt;/aside&amp;gt;

  &amp;lt;!-- SIDEBAR/MAIN DIVIDER --&amp;gt;
  &amp;lt;div class="shrink-0 px-1"&amp;gt;
    &amp;lt;Resizer
      size={sidebarWidth}
      min={128}
      max={512}
      orientation="vertical"
      onResize={(newSize) =&amp;gt; (sidebarWidth = newSize)}
      onResizeEnd={() =&amp;gt; {}}
    /&amp;gt;
  &amp;lt;/div&amp;gt;

  &amp;lt;!-- MAIN --&amp;gt;
  &amp;lt;div id="main" class="main"&amp;gt;
    &amp;lt;!-- TOP --&amp;gt;
    &amp;lt;div id="top p-2 bg-green-100" class="mainTop" style:--top-height={topHeight}&amp;gt;
      &amp;lt;span class="font-bold text-xl"&amp;gt;Top:&amp;lt;/span&amp;gt;
      Lorem ipsum?
    &amp;lt;/div&amp;gt;

    &amp;lt;!-- TOP/BOTTOM DIVIDER --&amp;gt;
    &amp;lt;div class="shrink-0 py-2"&amp;gt;
      &amp;lt;Resizer
        size={topHeight}
        min={64}
        max={5120}
        orientation="horizontal"
        onResize={(newSize) =&amp;gt; (topHeight = newSize)}
        onResizeEnd={() =&amp;gt; {}}
      /&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;!-- BOTTOM --&amp;gt;
    &amp;lt;div id="Bottom" class="mainBottom"&amp;gt;
      &amp;lt;span class="font-bold text-xl"&amp;gt;Bottom:&amp;lt;/span&amp;gt;
      Lorem ipsum.
    &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;style&amp;gt;
  :global(.html) {
    height: 100vh;
    width: 100vw;
  }
  .wrapper {
    height: 100%;
    width: 100%;
    display: flex;
  }

  .sidebar {
    width: calc(var(--sidebar-width) * 1px);
    overflow: scroll;
    flex-shrink: 0;
    border: 1px solid yellow;
  }

  .main {
    display: flex;
    flex-direction: column; 
    min-width: 0;
  }

  .mainTop {
    height: calc(var(--top-height) * 1px);
    overflow: scroll;
    border: 1px solid yellow;
  }

  .mainBottom {
    flex: 1 1 0%;
    overflow: scroll;
    border: 1px solid yellow;
  }
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Play around with it at &lt;a href="https://svelte.dev/repl/674dcfad17aa4b628e5c2fef4fda100f?version=4.2.0"&gt;https://svelte.dev/repl/674dcfad17aa4b628e5c2fef4fda100f?version=4.2.0&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  CSS Grid approach
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;The code is in &lt;code&gt;Svelte+Tailwind&lt;/code&gt;. Didn't take the time to unwind that further.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script lang="ts"&amp;gt;
  import Resizer from './Resizer.svelte';

  let sidebarWidth = 256;
  let topHeight = 312;
&amp;lt;/script&amp;gt;

&amp;lt;svelte:head&amp;gt;
    &amp;lt;script src="https://cdn.tailwindcss.com"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/svelte:head&amp;gt;

&amp;lt;div class="wrapper"&amp;gt;
  &amp;lt;!-- SIDEBAR --&amp;gt;
  &amp;lt;aside id="sidebar" aria-label="Sidebar" class="sidebar p-2" style:--sidebar-width={sidebarWidth}&amp;gt;
    &amp;lt;span class="font-bold text-xl"&amp;gt;Sidebar:&amp;lt;/span&amp;gt;
    &amp;lt;span&amp;gt;
      Lorem ipsum!
    &amp;lt;/span&amp;gt;
  &amp;lt;/aside&amp;gt;

  &amp;lt;!-- SIDEBAR/MAIN DIVIDER --&amp;gt;
  &amp;lt;div style="grid-area: sidebarResizer;"&amp;gt;
    &amp;lt;Resizer
      size={sidebarWidth}
      min={128}
      max={512}
      orientation="vertical"
      onResize={(newSize) =&amp;gt; (sidebarWidth = newSize)}
      onResizeEnd={() =&amp;gt; {}}
    /&amp;gt;
  &amp;lt;/div&amp;gt;

  &amp;lt;!-- TOP --&amp;gt;
  &amp;lt;div id="top" class="mainTop p-2" style:--top-height={topHeight}&amp;gt;
    &amp;lt;span class="font-bold text-xl"&amp;gt;Top:&amp;lt;/span&amp;gt;
    Lorem ipsum?
  &amp;lt;/div&amp;gt;

  &amp;lt;!-- TOP/BOTTOM DIVIDER --&amp;gt;
  &amp;lt;div class="" style="grid-area: mainResizer;"&amp;gt;
    &amp;lt;Resizer
      size={topHeight}
      min={128}
      max={640}
      orientation="horizontal"
      onResize={(newSize) =&amp;gt; (topHeight = newSize)}
      onResizeEnd={() =&amp;gt; {}}
    /&amp;gt;
  &amp;lt;/div&amp;gt;

  &amp;lt;!-- BOTTOM --&amp;gt;
  &amp;lt;div id="Bottom" class="mainBottom p-2"&amp;gt;
    &amp;lt;span class="font-bold text-xl"&amp;gt;Bottom:&amp;lt;/span&amp;gt;
    Lorem ipsum.
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;style&amp;gt;
  .wrapper {
    display: grid;
    grid-template-columns: auto auto 1fr;
    grid-template-areas:
      'sidebar sidebarResizer mainTop'
      'sidebar sidebarResizer mainResizer'
      'sidebar sidebarResizer mainBottom';
    gap: 5px;
    height: 100vh;
    width: 100vw;
  }

  .sidebar {
    grid-area: sidebar;
    width: calc(var(--sidebar-width) * 1px);
    overflow: scroll;
    border: 1px solid yellow;
  }

  .mainTop {
    grid-area: mainTop;
    height: calc(var(--top-height) * 1px);
    overflow: scroll;
    border: 1px solid yellow;
  }
  .mainBottom {
    grid-area: mainBottom;
    overflow: scroll;
    border: 1px solid yellow;
  }
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Play around with it at &lt;a href="https://svelte.dev/repl/ed4679d507c04c34a512db05cf6de601?version=4.2.0"&gt;https://svelte.dev/repl/ed4679d507c04c34a512db05cf6de601?version=4.2.0&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusions
&lt;/h1&gt;

&lt;p&gt;Think the &lt;code&gt;grid&lt;/code&gt; variant is far more comprehensible.&lt;br&gt;
&lt;code&gt;Flexbox&lt;/code&gt; is cluttered with &lt;code&gt;not so obvious tricks&lt;/code&gt; to make it work &lt;br&gt;
(&lt;em&gt;try removing &lt;code&gt;min-width: 0&lt;/code&gt; or some of the &lt;code&gt;flex: 1 1 0%&lt;/code&gt; statements&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;Hope there is something for somebody in here! 🙏&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>svelte</category>
    </item>
    <item>
      <title>Fullstack with Svelte &amp; tRPC</title>
      <dc:creator>Johannes Zillmann</dc:creator>
      <pubDate>Tue, 22 Nov 2022 02:01:18 +0000</pubDate>
      <link>https://dev.to/o_a_e/fullstack-with-svelte-trpc-2cab</link>
      <guid>https://dev.to/o_a_e/fullstack-with-svelte-trpc-2cab</guid>
      <description>&lt;p&gt;Usually I just do &lt;em&gt;backend-less Svelte&lt;/em&gt; apps. This time around I tried to go full stack in &lt;em&gt;javascript/typescript&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I started with &lt;a href="https://kit.svelte.dev/"&gt;Svelte-Kit&lt;/a&gt; but then decided for &lt;a href="https://svelte.dev/"&gt;Svelte&lt;/a&gt; - with a typical &lt;a href="https://vitejs.dev/"&gt;Vite&lt;/a&gt; build on the frontend - and &lt;a href="https://www.fastify.io/"&gt;Fastify&lt;/a&gt; + &lt;a href="https://trpc.io/"&gt;tRPC&lt;/a&gt; on the backend.&lt;/p&gt;

&lt;h2&gt;
  
  
  The project
&lt;/h2&gt;

&lt;p&gt;Find the project at &lt;a href="https://github.com/jzillmann/svelte-trpc-skeleton"&gt;https://github.com/jzillmann/svelte-trpc-skeleton&lt;/a&gt;. It's just a skeleton project with minimal setup (mono repo, NPM workspaces) and a cookie based login. &lt;/p&gt;

&lt;p&gt;I spare to list the individual setup steps since there is nothing sophisticated here. If you need those OR if you like video tutorial have a look at &lt;a href="https://www.youtube.com/watch?v=Lam0cYOEst8"&gt;https://www.youtube.com/watch?v=Lam0cYOEst8&lt;/a&gt;. I found it excellent and it's basically the same setup just with different technologies. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why not Svelte-Kit
&lt;/h2&gt;

&lt;p&gt;Svelte is one of a few frameworks I dare to say I love. So going with &lt;em&gt;Svelte-Kit&lt;/em&gt; was an obvious choice for me.&lt;br&gt;
Why I left that path ?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The application I want to build is well suited for SPA &lt;em&gt;(single page application)&lt;/em&gt;. So I gain very little from SSR &lt;em&gt;(server side rendering)&lt;/em&gt; and the build in routing.&lt;/li&gt;
&lt;li&gt;While Svelte-Kit's page endpoints are properly typed (typescript), the shadow/server endpoints are not yet and those are the ones I would use most heavily. &lt;em&gt;(see &lt;a href="https://github.com/sveltejs/kit/issues/647"&gt;https://github.com/sveltejs/kit/issues/647&lt;/a&gt; for progress on this)&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;With the &lt;em&gt;Fastify/tRPC stack&lt;/em&gt; I can make use of more of the existing HTTP features like

&lt;ul&gt;
&lt;li&gt;Using web-sockets &lt;em&gt;(Svelte-Kit is not there yet: &lt;a href="https://github.com/sveltejs/kit/issues/1491"&gt;https://github.com/sveltejs/kit/issues/1491&lt;/a&gt;)&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Cancelling of HTTP requests &lt;em&gt;(see &lt;a href="https://www.reddit.com/r/SvelteKit/comments/yjdx13/detect_aborted_request_on_the_server/"&gt;https://www.reddit.com/r/SvelteKit/comments/yjdx13/detect_aborted_request_on_the_server/&lt;/a&gt;)&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Overall it seems like the chosen stack is a little more lightweight and easier to grasp then getting familiar with Svelte-Kit.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Words
&lt;/h2&gt;

&lt;p&gt;Since I didn't do much beyond the project setup, final judgment is not here yet, but I feel excited about it!&lt;/p&gt;

&lt;p&gt;Also, there are things the skeleton could be improved upon... like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;testing setup&lt;/li&gt;
&lt;li&gt;unified typescript setup&lt;/li&gt;
&lt;li&gt;unified formatting/linting setup&lt;/li&gt;
&lt;li&gt;real production settings&lt;/li&gt;
&lt;li&gt;etc...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's not my priority to do these things, but feel free to contribute if you feel like it!&lt;/p&gt;

</description>
      <category>svelte</category>
      <category>trpc</category>
      <category>typescript</category>
      <category>fullstack</category>
    </item>
    <item>
      <title>Chasing a hundred rabits at a time — A dev week</title>
      <dc:creator>Johannes Zillmann</dc:creator>
      <pubDate>Sun, 13 Dec 2020 21:15:43 +0000</pubDate>
      <link>https://dev.to/o_a_e/chasing-a-hundred-rabits-at-a-time-a-dev-week-411f</link>
      <guid>https://dev.to/o_a_e/chasing-a-hundred-rabits-at-a-time-a-dev-week-411f</guid>
      <description>&lt;h3&gt;
  
  
  Chasing a hundred rabits at a time — A dev week
&lt;/h3&gt;

&lt;p&gt;I wish i was that guy who is enjoying the &lt;em&gt;doing&lt;/em&gt; more then the &lt;em&gt;achieving&lt;/em&gt;. If i were, last week would have been a great adventure with many surprising turns… truly enjoyable. But i’m not, and thus last week felt particular annoying.&lt;/p&gt;

&lt;p&gt;If you are into developing software you probably know those days:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You start with a well defined task.&lt;/li&gt;
&lt;li&gt;You are well motivated. Already, you have it even solved — at least in your head.&lt;/li&gt;
&lt;li&gt;You start touching the system and things go downhill from there. You are finding one flaw after another and — if you’re not stepping back at the right time — you’re trying to solve 10 things at the same time while being pressured by not proceeding with your initial task. Not very sustainable for your brain on the long run as i perceive it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Last week was like that for me. &lt;strong&gt;&lt;em&gt;Every single day&lt;/em&gt;&lt;/strong&gt;. Quite unusual since i haven’t had these things for a longer time and i never had them &lt;strong&gt;strong&lt;/strong&gt; like that. Thus i feel the urge to write things down and recapture the story.&lt;/p&gt;

&lt;h3&gt;
  
  
  Context
&lt;/h3&gt;

&lt;p&gt;At my company we work on a system which sits between your data warehouses and your intelligence tools (&lt;a href="https://www.datameer.com/spotlight/"&gt;Spotlight&lt;/a&gt;). Kind of a unified access layer to your data in this regard.&lt;/p&gt;

&lt;p&gt;For the past couple of weeks i was working on a benchmark suite. How is the performance of the system with a particular cluster size and a particular configuration, when the data sits in S3, when the data sits in Snowflake, when … you get it…&lt;/p&gt;

&lt;h3&gt;
  
  
  The Task
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Integrate Redshift into our TPC-H benchmark suite&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data in the scale factors 1, 10 and 100 was already on S3.&lt;/li&gt;
&lt;li&gt;Benchmark infrastructure was ready and running for a couple of other source system.&lt;/li&gt;
&lt;li&gt;All there left to do, was to setup the tables in Redshift and do little coding and configuration work on the benchmark setup side of things.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Slow Start
&lt;/h3&gt;

&lt;p&gt;I know we already had an Redshift cluster up and possibly even the TPC-H data was on it. Thus my first step was to discover what’s there.&lt;br&gt;&lt;br&gt;
That wasn’t wild, but it already started to annoy me a bit:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With almost 10 different AWS accounts the company runs and 4 to 5 different regions in use, find you’re way through the web-console world. Good luck… But with colleagues who know, not a big deal.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;What ?&lt;/em&gt; You found the cluster, you have the credentials but it won’t tell you the existing databases unless you name one ? 🤦&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Things going downhill — the web-service and data generation battle
&lt;/h3&gt;

&lt;p&gt;The data is already on S3, i’ve now fully control over the Redshift database, i found blogs describing how to setup TPC-H on Redshift (DDL’s included), so what could possibly go wrong ?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UDD0a7YV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A7o_kavKfrOGvJGjgkq1MDw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UDD0a7YV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A7o_kavKfrOGvJGjgkq1MDw.png" alt=""&gt;&lt;/a&gt;Action — Problem sequence getting the data setup in Redshift&lt;/p&gt;

&lt;h3&gt;
  
  
  If that would have been all
&lt;/h3&gt;

&lt;p&gt;As pictured in the flow graph above, getting the data in the right shape into Redshift was a longer journey than expected. I’ve didn’t even include all the details, like the EC2 machine is was using had only 2 disk, each of approximate 93 GB of free space(The benchmark data in one format was 100GB, with the biggest file 70 GB), wich required quite a bit of chunking the data generation and upload work. However, once i had this done, problems didn’t stop to flow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The benchmark suite started to fail on setting things up&lt;/li&gt;
&lt;li&gt;Did current changes in the communication protocol didn’t make it into the benchmark project ? No exactly… the deployed version was just mismatched with the client library.&lt;/li&gt;
&lt;li&gt;How did i find out ? Just deployed a current dev version…&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Just&lt;/em&gt; comes with a litlle sarcasm here. Turned out that the old way of deploying custom versions was broken. The new way didn’t work with the particular AWS account i was using. Thanks to extraordinary devops support we got things running after 5 iterations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And just on my last weekday (Thursday for me), when things started to settle down (but i still had a couple of verifications on my list) i got a call. Hey we need you for that other urgent thing… 😤&lt;/p&gt;

&lt;h3&gt;
  
  
  Could i’ve done better ?
&lt;/h3&gt;

&lt;p&gt;For sure i could have shortened the cycles here and there, like trying to generate the data on my laptop had no thinking attached to it at all. But even if i did all things perfectly, it still would have felt like the universe conspired against me and it wouldn’t have been considerably faster.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Words
&lt;/h3&gt;

&lt;p&gt;Often the final judgement just depends on the perspective. There are quite some positive things that did happen on the way:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I’ve strengthened my bash script skills to make the steps reproducible.&lt;/li&gt;
&lt;li&gt;I’ve learned a bit of S3 ACL syntax on the way.&lt;/li&gt;
&lt;li&gt;I discovered that our existing data was flawed.&lt;/li&gt;
&lt;li&gt;Technically, I understood it all ;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But i guess the major thing i put on my wishlist for next year is… &lt;em&gt;that i be more of that guy who enjoys a surprising challenging journey&lt;/em&gt;!&lt;/p&gt;




</description>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>JS/TS Managing alternative implementations with RollupJS</title>
      <dc:creator>Johannes Zillmann</dc:creator>
      <pubDate>Sun, 24 May 2020 18:01:17 +0000</pubDate>
      <link>https://dev.to/o_a_e/js-ts-managing-alternative-implementations-with-rollupjs-2dgo</link>
      <guid>https://dev.to/o_a_e/js-ts-managing-alternative-implementations-with-rollupjs-2dgo</guid>
      <description>&lt;p&gt;Short post about a trivial thing to do. I’m in the JS/&lt;a href="https://www.electronjs.org"&gt;Electron&lt;/a&gt; world. I just decided I want to package my app for Electron but for a regular Browser as well. Why ?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A) I can do a demo version of the app on the web!&lt;/li&gt;
&lt;li&gt;B) I can use &lt;a href="https://www.cypress.io"&gt;Cypress&lt;/a&gt; for testing it!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Will see how far this goes, but currently i’m using only two Electron/Desktop features that can be easily mimicked in an browser environment:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reading and Writing app config =&amp;gt; &lt;a href="https://github.com/sindresorhus/electron-store"&gt;ElectronStore&lt;/a&gt; / &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage"&gt;Local Storage&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Reading and Writing files =&amp;gt; &lt;a href="https://nodejs.org/api/fs.html"&gt;Node FS API&lt;/a&gt; / &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage"&gt;Local Storage&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Basic Structure
&lt;/h3&gt;

&lt;p&gt;Simple. Lets just focus on the app config.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I defined a common ‘interface’ (&lt;em&gt;AppConfig&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;One implementation wrapping &lt;a href="https://github.com/sindresorhus/electron-store"&gt;ElectronStore&lt;/a&gt; (&lt;em&gt;ElectronAppConfig&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;A second implementation wrapping the local storage (&lt;em&gt;LocalAppConfig&lt;/em&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Most Naive Approach
&lt;/h3&gt;

&lt;p&gt;I just kept all 3 classes under &lt;code&gt;/src&lt;/code&gt; with a factory method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;createAppConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;appConfigSchema&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__electronEnv__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ElectronStore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;electron-store&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;ElelectronAppConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;ElectronStore&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;schema&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;appConfigSchem&lt;/span&gt;&lt;span class="p"&gt;}));&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;defaults&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;appConfigSchema&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;o&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({...&lt;/span&gt;&lt;span class="nx"&gt;o&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="nx"&gt;appConfigSchema&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;default&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}),{});&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;LocalAppConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;defaults&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;Then in the &lt;code&gt;rollup.config.js&lt;/code&gt; i’m using the &lt;a href="https://github.com/rollup/plugins/tree/master/packages/replace"&gt;plugin-replace&lt;/a&gt; to steer the &lt;code&gt;__electronEnv__&lt;/code&gt; variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;replace&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@rollup/plugin-replace&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;electronEnv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!!&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ELECTRON&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nl"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="nx"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;__electronEnv__&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;electronEnv&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;And finally i enrich my NPM electron tasks with then env variable in the &lt;code&gt;package.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"electron"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ELECTRON=true run-s build pure-electron"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That’s it for the naive approach. It’s working most of the times (sometimes there is a hiccup with a &lt;code&gt;require not found error&lt;/code&gt;, but a rebuild usually solves it).&lt;/p&gt;

&lt;p&gt;Anyway, the purist in me, wanted a clearer structure and also the inline &lt;em&gt;require&lt;/em&gt; &lt;em&gt;statements&lt;/em&gt; seemed odd.&lt;/p&gt;

&lt;h3&gt;
  
  
  Moving to a more satisfactory approach
&lt;/h3&gt;

&lt;p&gt;Have another folder next to &lt;code&gt;/src&lt;/code&gt;, let’s called it &lt;code&gt;/includes&lt;/code&gt; with three sub-folders:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;api&lt;/strong&gt; : &lt;em&gt;AppConfig&lt;/em&gt;, …&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;electron&lt;/em&gt;&lt;/strong&gt; : &lt;em&gt;index.js&lt;/em&gt; (contain factory methods for all electron implementations), &lt;em&gt;ElectronAppConfig&lt;/em&gt;, …&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;browser&lt;/strong&gt; : &lt;em&gt;index.js&lt;/em&gt; (contain factory methods for all browser implementations), &lt;em&gt;LocalAppConfig&lt;/em&gt;, …&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now use &lt;a href="https://github.com/rollup/plugins/tree/master/packages/alias"&gt;plugin-alias&lt;/a&gt; to alias the &lt;em&gt;index.js&lt;/em&gt; of the desired implementation at build time in rollup.config.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;alias&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@rollup/plugin-alias&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;electronEnv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!!&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ELECTRON&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;storagePackage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;electronEnv&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;electron&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;browser&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nl"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="nx"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;find&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;storage&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;replacement&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`./includes/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;storagePackage&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/index.js`&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And access the implementation in your main code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createAppConfig&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;storage&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;appConfig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createAppConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;appConfigSchema&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Easy. Not too much gain here, but some clearer structure!&lt;/p&gt;

&lt;h3&gt;
  
  
  And now in Typescript…
&lt;/h3&gt;

&lt;p&gt;Once i moved to the approach above, i thought ‘Ok, lets try typescript’. Cause that’s an obvious thing to do if you’re talking about &lt;em&gt;interfaces&lt;/em&gt; and &lt;em&gt;implementations&lt;/em&gt;, right ?&lt;/p&gt;

&lt;p&gt;I failed using the exact same approach but luckily the typescript &lt;a href="https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping"&gt;path-mapping&lt;/a&gt; came to rescue:&lt;/p&gt;

&lt;p&gt;Here is the &lt;code&gt;rollup.config.js&lt;/code&gt; part:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;typescript&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@rollup/plugin-typescript&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nl"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
 &lt;span class="nx"&gt;typescript&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;es6&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;baseUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;paths&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;`./includes/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;storagePackage&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/index.js`&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Imports work the same as in the previous approach!&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Words
&lt;/h3&gt;

&lt;p&gt;Not sure if i delivered on the promise of &lt;em&gt;shortness&lt;/em&gt;, but finding the second/third approaches took me longer than expected and drove me almost nuts. Part i blame on my inexperience in the JS world, part is that the search space for such a problem seems heavily convoluted. That said, there might be a couple of alternatives worth investigating:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dynamic Modules: &lt;a href="https://medium.com/@leonardobrunolima/javascript-tips-dynamically-importing-es-modules-with-import-f0093dbba8e1"&gt;https://medium.com/@leonardobrunolima/javascript-tips-dynamically-importing-es-modules-with-import-f0093dbba8e1&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Multiple packages (with individual dependencies) managed with… lets say &lt;a href="https://github.com/lerna/lerna"&gt;Lerna&lt;/a&gt;…&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have any feedback or inspiration, let me know!&lt;/p&gt;




</description>
      <category>javascript</category>
      <category>rollup</category>
      <category>electron</category>
      <category>modularity</category>
    </item>
    <item>
      <title>Getting started with Electron and Svelte</title>
      <dc:creator>Johannes Zillmann</dc:creator>
      <pubDate>Mon, 14 Oct 2019 19:44:32 +0000</pubDate>
      <link>https://dev.to/o_a_e/getting-started-with-electron-and-svelte-2gn8</link>
      <guid>https://dev.to/o_a_e/getting-started-with-electron-and-svelte-2gn8</guid>
      <description>&lt;p&gt;Short tutorial setting up a blank but working &lt;a href="https://electronjs.org"&gt;Electron&lt;/a&gt; app with &lt;a href="http://svelte.dev/"&gt;Svelte&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;There are some project templates for exactly this purpose out there. Each one had some sweets but also some oddities (like producing ton’s of warnings in Electron’s dev console). So i massaged and combined them and came up with what i’m describing here!&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up Node &amp;amp; Svelte
&lt;/h3&gt;

&lt;p&gt;Create or navigate into your empty project folder and execute the following commands in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npx degit sveltejs/template
npm &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;This should create the &lt;em&gt;package.json&lt;/em&gt; and a &lt;a href="https://rollupjs.org"&gt;Rollup&lt;/a&gt; configuration with basic Svelte.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A little cleanup&lt;/strong&gt; to be made… If you have a look at the &lt;em&gt;package.json&lt;/em&gt; you will see &lt;a href="https://www.npmjs.com/package/sirv-cli"&gt;sirv-cli&lt;/a&gt; as only production dependency. You won’t need this for Electron, so move it to dev:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;sirv-cli &lt;span class="nt"&gt;--save-dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Relativize all of your links&lt;/strong&gt; inside the &lt;em&gt;public/index.html&lt;/em&gt; for usage through Electron. One example:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt; &lt;span class="nx"&gt;defer&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/build/bundle.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;becomes&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt; &lt;span class="nx"&gt;defer&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;build/bundle.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Svelte is ready to go&lt;/strong&gt;! Test it out by executing&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;and open &lt;a href="http://localhost:5000"&gt;http://localhost:5000&lt;/a&gt;. You should see a &lt;em&gt;Hello World&lt;/em&gt; printed!&lt;/p&gt;
&lt;h3&gt;
  
  
  Setting up Electron
&lt;/h3&gt;

&lt;p&gt;Install &lt;a href="https://electronjs.org"&gt;Electron&lt;/a&gt; (plus &lt;a href="https://www.npmjs.com/package/npm-run-all"&gt;npm-run-all&lt;/a&gt; &amp;amp; &lt;a href="https://www.npmjs.com/package/cross-env"&gt;cross-env&lt;/a&gt;) as a dev dependency:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; &lt;span class="nt"&gt;--verbose&lt;/span&gt; electron 
npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; npm-run-all
npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; cross-env
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Create the &lt;a href="https://electronjs.org/docs/tutorial/application-architecture"&gt;electron main script&lt;/a&gt; - i will call it &lt;em&gt;electron.js&lt;/em&gt; — under &lt;em&gt;src/&lt;/em&gt;&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Now edit your &lt;em&gt;package.json&lt;/em&gt; and&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add following line under the existing &lt;em&gt;version&lt;/em&gt; line:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"main"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./src/electron.js"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add 2 commands to the &lt;em&gt;scripts&lt;/em&gt; section:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"electron"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"run-s build pure-electron"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"pure-electron"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"electron ."&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Electron app is ready to go&lt;/strong&gt;! Test it by executing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run electron
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Live Reload for Electron
&lt;/h3&gt;

&lt;p&gt;You are now able to build and run the Electron app. In order to have a &lt;em&gt;live reload&lt;/em&gt; (updating the app when you change your CSS/JavaScript files) do the following.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install the &lt;a href="https://github.com/paulmillr/chokidar"&gt;Chokidar&lt;/a&gt; library which helps with file watching:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;chokidar &lt;span class="nt"&gt;--save-dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Edit &lt;em&gt;src/electron.js&lt;/em&gt; and add the following code to the &lt;em&gt;createWindow()&lt;/em&gt; function under the instantiation of the &lt;em&gt;mainWindow variable&lt;/em&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;watcher&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NODE_ENV&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;development&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nx"&gt;watcher&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;chokidar&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../public/build&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;ignoreInitial&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
 &lt;span class="nx"&gt;watcher&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;change&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nx"&gt;mainWindow&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reload&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;ul&gt;
&lt;li&gt;Also close the watcher in the existing &lt;em&gt;mainWindow.on(‘closed’…&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;watcher&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nx"&gt;watcher&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;close&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;ul&gt;
&lt;li&gt;Now add these commands to your &lt;em&gt;package.json&lt;/em&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"electron-dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"run-p dev pure-electron-dev"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"pure-electron-dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"cross-env NODE_ENV=development electron ."&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Live reload ready to go&lt;/strong&gt;! Test it by executing&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run electron-dev
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;and e.g. adding another exclamation mark to the headline inside of &lt;em&gt;src/App.svelte&lt;/em&gt;!&lt;/p&gt;

&lt;h3&gt;
  
  
  Bundling a distribution (OS X)
&lt;/h3&gt;

&lt;p&gt;In order to build a distribution, you have a couple of options. Most common are &lt;a href="https://github.com/electron/electron-packager"&gt;Electron Packager&lt;/a&gt; (Electrons default bundler) and &lt;a href="https://www.electron.build"&gt;Electron Builder&lt;/a&gt;. Both come with their own ways of configuring a distribution, so don’t mix them up. I will show how to build a minimal OS-X bundle with &lt;strong&gt;Electron Builder&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install the package:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;electron-builder &lt;span class="nt"&gt;--save-dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Create a &lt;em&gt;electron-builder.yml&lt;/em&gt; file in the root of your project:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;appId: "my.app.id"

# Package app code into a asar archive. Set to false to debug issues.
asar: true

# Mac OS configuration
mac:
 icon: "public/icons/my_app.icns"
 category: "public.app-category.utilities"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add this command to &lt;em&gt;package.json&lt;/em&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"dist-darwin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"run-s build pure-dist-darwin"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"pure-dist-darwin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"electron-builder --dir --mac --config electron-builder.yml"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Thats it!&lt;/strong&gt; If you are on Mac, you should now be able to execute&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dist-darwin
open dist/mac/svelte-app.app
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the &lt;a href="https://www.electron.build/#quick-setup-guide"&gt;quickstart guide&lt;/a&gt; you’ll find out how to &lt;strong&gt;customize the most basic things&lt;/strong&gt; , e.g:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change the &lt;em&gt;app name&lt;/em&gt; through changing the &lt;em&gt;name&lt;/em&gt; in the &lt;em&gt;package.json.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Change the &lt;em&gt;window title&lt;/em&gt; through changing the &lt;em&gt;title&lt;/em&gt; in &lt;em&gt;public/index.html&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Setting up app icons (OS X)
&lt;/h3&gt;

&lt;p&gt;By default the app will use the electron icon. You can customize this easily, once you have a icon image and know how to produce the required artifacts from it. Here is how i did it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Used &lt;a href="https://designer.gravit.io"&gt;Gravit Designer&lt;/a&gt; to create an image.&lt;/li&gt;
&lt;li&gt;Exported the image as PNG.&lt;/li&gt;
&lt;li&gt;Used &lt;a href="https://github.com/onmyway133/IconGenerator"&gt;Icon Generator&lt;/a&gt; to generate the icons from the PNG&lt;/li&gt;
&lt;li&gt;Renamed the generated icon folder from &lt;code&gt;AppIcon.appiconset&lt;/code&gt; to &lt;code&gt;AppIcon.iconset&lt;/code&gt; (so &lt;em&gt;iconutil&lt;/em&gt; can work with it)&lt;/li&gt;
&lt;li&gt;Execute on terminal:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;iconutil &lt;span class="nt"&gt;-c&lt;/span&gt; icns AppIcon.iconset
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Moved the AppIcon.iconset to what is configured in the &lt;em&gt;electron-builder.yml&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In case you think you did everything correctly but still see the standard Electron icon… Try the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;dist/mac/template-electron-svelte.app
&lt;span class="nb"&gt;touch &lt;/span&gt;dist/mac/template-electron-svelte.app/Contents/Info.plist
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Final Words
&lt;/h3&gt;

&lt;p&gt;This is just a starter. For Electron functionality refer to it’s excellent guide: &lt;a href="https://electronjs.org/docs"&gt;https://electronjs.org/docs&lt;/a&gt;. To build and publish releases see &lt;a href="https://www.electron.build/"&gt;https://www.electron.build/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Find the complete code under &lt;a href="https://github.com/jzillmann/template-electron-svelte"&gt;https://github.com/jzillmann/template-electron-svelte&lt;/a&gt;. The &lt;a href="https://github.com/jzillmann/template-electron-svelte/commits/master"&gt;commits&lt;/a&gt; are structured similar to this article!&lt;/p&gt;

&lt;p&gt;Hope this helped you as much as if it would have helped me! Let me know if you have any simplifications or recommendations on that!&lt;/p&gt;




</description>
      <category>electron</category>
      <category>javascript</category>
      <category>desktopapp</category>
      <category>svelte</category>
    </item>
    <item>
      <title>Impressions on Svelte from a non pro</title>
      <dc:creator>Johannes Zillmann</dc:creator>
      <pubDate>Thu, 03 Oct 2019 17:14:29 +0000</pubDate>
      <link>https://dev.to/o_a_e/impressions-on-svelte-from-a-non-pro-28hb</link>
      <guid>https://dev.to/o_a_e/impressions-on-svelte-from-a-non-pro-28hb</guid>
      <description>&lt;h3&gt;
  
  
  Impressions on Svelte (non pro)
&lt;/h3&gt;

&lt;p&gt;I guess i’m vulnerable to the &lt;em&gt;new shiny thing syndrome&lt;/em&gt;. I wasn’t looking for any kind of web framework (as usual), as i was clicking &lt;a href="https://dev.to/jesseskinner/svelte-is-the-most-beautiful-web-framework-i-ve-ever-seen-325f"&gt;Svelte is the most beautiful web framework I’ve ever seen&lt;/a&gt; (as usual).&lt;/p&gt;

&lt;h3&gt;
  
  
  Background
&lt;/h3&gt;

&lt;p&gt;Building the backends, frontend development seemed pretty chaotic to me for a long time. &lt;a href="https://reactjs.org"&gt;React&lt;/a&gt; paved the way. First time i felt comfortable structuring JavaScript.&lt;br&gt;&lt;br&gt;
With many available component libraries, it was easy enough to get my first web apps (&lt;a href="https://pdf2md.morethan.io"&gt;https://pdf2md.morethan.io&lt;/a&gt;, &lt;a href="https://jmh.morethan.io"&gt;https://jmh.morethan.io&lt;/a&gt;) up and running even though my knowledge of JavaScript, HTML and CSS was lacking.&lt;/p&gt;
&lt;h3&gt;
  
  
  Fast forward to Svelte
&lt;/h3&gt;

&lt;p&gt;Documentation of &lt;a href="https://svelte.dev"&gt;Svelte&lt;/a&gt; is pretty good. It has a neat &lt;a href="https://svelte.dev/tutorial/"&gt;tutorial&lt;/a&gt;, a simple but helpful &lt;a href="https://svelte.dev/docs"&gt;API documentation&lt;/a&gt; and a &lt;a href="https://svelte.dev/examples"&gt;examples section&lt;/a&gt; (which is more or less an replication of the tutorial).&lt;br&gt;&lt;br&gt;
Getting started is really simple. Bootstrap a running hello world app up with these 3 commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx degit sveltejs/template
npm install
npm run dev
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To get into Svelte, I decided to build a simple numerology calculator for names (&lt;a href="https://nanuca.morethan.io"&gt;Nanuca&lt;/a&gt;). I found it pretty straight forward to get up to speed, and looking back at the &lt;a href="https://svelte.dev/docs"&gt;API documentation&lt;/a&gt; after the first evening, i was amazed that there isn’t so much stuff to learn anyway.&lt;/p&gt;

&lt;h3&gt;
  
  
  Impressions and thoughts
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Easy to start, cushy learning curve.&lt;/li&gt;
&lt;li&gt;Less concepts to master, less boilerplate then &lt;a href="https://reactjs.org"&gt;React&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;It forced me to learn more CSS and JS basics (which was a good thing to me at this point in time)&lt;/li&gt;
&lt;li&gt;— &lt;a href="https://reactjs.org"&gt;React&lt;/a&gt; has an amazing ecosystem. Lots of predefined components available. You don’t have to master HTML/CSS to build something great.&lt;/li&gt;
&lt;li&gt;— Every once in a while however i run into a simple problem which took annoyingly long to solve without that basic knowledge.&lt;/li&gt;
&lt;li&gt;Even something fairly complex like animations and transitions are pretty simple to master.&lt;/li&gt;
&lt;li&gt;There is a out-of-the-box &lt;a href="https://svelte.dev/docs#svelte_store"&gt;store implementation&lt;/a&gt; which takes some time to get used to, but probably less then the &lt;a href="https://redux.js.org"&gt;Redux&lt;/a&gt; and co thing.&lt;/li&gt;
&lt;li&gt;With so many amazing component-based frameworks out there, it seems beneficial to build JavaScript libraries which are not tight to one framework in particular.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Simply said… i’m just enjoying working &lt;em&gt;in&lt;/em&gt; &lt;a href="https://svelte.dev"&gt;Svelte&lt;/a&gt;. It’s simple, it’s powerful, it never stepped in my way so far! So this time, i’m pretty happy i fell pray to &lt;a href="https://dev.to/jesseskinner/svelte-is-the-most-beautiful-web-framework-i-ve-ever-seen-325f"&gt;Svelte is the most beautiful web framework I’ve ever seen&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  More
&lt;/h3&gt;

&lt;p&gt;There is probably a lot of more to say about what &lt;a href="https://svelte.dev"&gt;Svelte&lt;/a&gt; is and how it works… but i leave that to the masters of JavaScript. &lt;a href="https://gist.github.com/Rich-Harris/0f910048478c2a6505d1c32185b61934"&gt;This small writeup&lt;/a&gt; might be a good starting point for going into the theoretical background.&lt;/p&gt;

&lt;p&gt;Find the code of the example project here: [&lt;a href="https://nanuca.morethan.io"&gt;https://nanuca.morethan.io&lt;/a&gt;]&lt;/p&gt;




</description>
      <category>react</category>
      <category>frontenddev</category>
      <category>javascript</category>
      <category>svelte</category>
    </item>
    <item>
      <title>Benchmarking Infrastructure for the JVM</title>
      <dc:creator>Johannes Zillmann</dc:creator>
      <pubDate>Sat, 03 Feb 2018 08:15:15 +0000</pubDate>
      <link>https://dev.to/o_a_e/benchmarking-infrastructure-for-the-jvm-4lg0</link>
      <guid>https://dev.to/o_a_e/benchmarking-infrastructure-for-the-jvm-4lg0</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;When performance is measured, performance improves. When performance is measured and reported, the rate of improvement accelerates. — Thomas Monson&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There is a tool called &lt;a href="http://openjdk.java.net/projects/code-tools/jmh/" rel="noopener noreferrer"&gt;JMH&lt;/a&gt; which is one of the &lt;a href="https://en.wikipedia.org/wiki/Java_virtual_machine" rel="noopener noreferrer"&gt;JVM’s&lt;/a&gt; best friend when it comes to performance tracking and analysis. In this post, i…&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Describe the pieces of infrastructure i developed around JMH and how you can use those for your own endeavors…&lt;/li&gt;
&lt;li&gt;Tell the long story of the Why... ;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How and Why — Chapter I
&lt;/h3&gt;

&lt;p&gt;A few years ago - working at &lt;a href="https://www.datameer.com" rel="noopener noreferrer"&gt;Datameer&lt;/a&gt;, a big data platform - some customers were concerned about performance. &lt;em&gt;“Why is this and that job taking only five hours in Hive but eight in Datameer ?”&lt;/em&gt; Kind of that in different shades. So a small team set out to investigate &amp;amp; solve the complaints before they could turn into a problem. First thing they did, was to craft a benchmark suite which run data processing jobs on Hadoop with Hive and with Datameer. With that, they were able to compare both products, figure out how to improve Datameer and we could finally cope with the customer’s expectation in terms of performance.&lt;/p&gt;

&lt;p&gt;A few month later, i was asking &lt;em&gt;“Hey where is our performance suite running? And where can i see the report ?”.&lt;/em&gt; The response was like &lt;em&gt;“Well, you’ve to prepare an environment, then trigger the benchmarks manually and then you can find the performance number printed to the logs!”&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“Phew, if that suite doesn’t run regularly and if it doesn’t alarm or cheer anyone with some fancy graphs… that thing will rotten soon…”.&lt;/em&gt; Maybe i was just thinking, maybe i articulated my concern in more polite terms. Anyhow…&lt;/p&gt;

&lt;p&gt;I can’t prove that proper reporting and automation would have saved the life of this piece of infrastructure, but eventually it lay dead for a while and got removed from the codebase years after.&lt;/p&gt;

&lt;h3&gt;
  
  
  How and Why — Chapter II
&lt;/h3&gt;

&lt;p&gt;Two years back - still working at Datameer - we started to develop a new major feature. The feature’s main feature was about performance. It didn’t really brought new functionality to the table, but through it’s mere speed, it should enable new use cases.&lt;/p&gt;

&lt;p&gt;This time i was more involved and, building on the former experience, i had these thoughts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If performance is that much crucial, we have to measure the de-facto state of each feature and track losses and gains with each step of development.&lt;/li&gt;
&lt;li&gt;I want good reporting &amp;amp; proper automation!!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pretty obvious... There should be proper software out there i thought…&lt;/p&gt;

&lt;p&gt;It didn’t took me long until i figured that &lt;a href="http://openjdk.java.net/projects/code-tools/jmh/" rel="noopener noreferrer"&gt;JMH&lt;/a&gt; is kind of the de-facto tool used by most (and more &amp;amp; more) people, to realize micro benchmarks on the JVM. While JMH’s strength lies surely in micro benchmarking, i found it for good use in “integration benchmarking” as well. The pluggable profilers it can run are pretty cool too. They help to find explanations for the seen performance, such as object allocation, JIT work, etc...&lt;/p&gt;

&lt;p&gt;But in terms of presenting the benchmark results… most of the tooling around JMH lacked what i was wishing for. Gradle plugins were there, but only for mere execution. The existing Jenkins plugins were of great help, but missed depth. A online visualizer did exist… but it was pretty good in hiding and i didn’t find it at that time. And the printout / the result file JMH does at the end of a execution… well its pretty good if you work on a small set of benchmarks, but once you grow your suite… good luck keeping your vision!&lt;/p&gt;

&lt;p&gt;Thats why i set out and developed my own set of tools…&lt;/p&gt;

&lt;h3&gt;
  
  
  JMH Visualizer — Online Visualizer
&lt;/h3&gt;

&lt;p&gt;Starting with a gradle plugin generating html and javascript based on the benchmark results, i soon figured out that this won’t scale and developing a regular webapp with standard tools will bring me much farther much sooner.&lt;/p&gt;

&lt;p&gt;So here it is, a mostly javascript app, the &lt;em&gt;JMH visualizer:&lt;/em&gt; &lt;a href="http://jmh.morethan.io" rel="noopener noreferrer"&gt;&lt;em&gt;http://jmh.morethan.io&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Code is at &lt;a href="https://github.com/jzillmann/jmh-visualizer" rel="noopener noreferrer"&gt;https://github.com/jzillmann/jmh-visualizer&lt;/a&gt;. Assuming you know how to execute JMH benchmarks, you can instruct JMH to output JSON instead of CSV (e.g. java -jar benchmarks.jar -rf json). Simply upload the produced JSON at the &lt;a href="http://jmh.morethan.io" rel="noopener noreferrer"&gt;JMH Visualizer page&lt;/a&gt; and you will get a graphical representation of the json like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AFidKfiWSPtPg3ljuwWiZiw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AFidKfiWSPtPg3ljuwWiZiw.png"&gt;&lt;/a&gt;one benchmark run&lt;/p&gt;

&lt;p&gt;Execute the benchmarks a second time and upload both of the JSON files and you will get a compare view:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AX2wcz8VIoJKsZJRmpiw-Bw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AX2wcz8VIoJKsZJRmpiw-Bw.png"&gt;&lt;/a&gt;two benchmark runs&lt;/p&gt;

&lt;p&gt;Upload three or more JSON files and you get a line chart:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2ADhQPPyTYr9h-4yXtYBEspg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2ADhQPPyTYr9h-4yXtYBEspg.png"&gt;&lt;/a&gt;three or more benchmark runs&lt;/p&gt;

&lt;p&gt;Here a few additional points to the online visualizer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It’s online, but your data stays offline (&lt;em&gt;once the hmtl and javascript is loaded, you can safely disconnect from the internet and start using the visualizer&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;You usually write your benchmarks in a class. JMH Visualizer does bundle the benchmarks from one class into one chart usually.&lt;/li&gt;
&lt;li&gt;It tries to make use of most of the provided data, so additionally to the score it visualizes, it give insights into the score-error, iteration result s and secondary metrics like &lt;em&gt;·gc.alloc.rate.norm.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Loading your reports from Gists or external URL’s
&lt;/h4&gt;

&lt;p&gt;If you have posted your benchmark results (in JSON form) anywhere in the web, you can now reference them (instead of uploading). JMH Visualizer understands those 4 paramters: &lt;em&gt;source, sources, gist, gists&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://jmh.morethan.io/?source=https://gist.githubusercontent.com/jzillmann/7d23b2382911cc434754a23773b06598/raw/1bcad4bb64624d8a2be15114a4eee4c406c3ae95/string-concatenation_jdk7.json" rel="noopener noreferrer"&gt;http://jmh.morethan.io/?source=https://gist.githubusercontent.com/jzillmann/7d23b2382911cc434754a23773b06598/raw/1bcad4bb64624d8a2be15114a4eee4c406c3ae95/string-concatenation_jdk7.json&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jmh.morethan.io/?sources=https://gist.githubusercontent.com/jzillmann/7d23b2382911cc434754a23773b06598/raw/1bcad4bb64624d8a2be15114a4eee4c406c3ae95/string-concatenation_jdk7.json,https://gist.githubusercontent.com/jzillmann/866d39d43b264f507a67368f2313baca/raw/d0ae1502e8c493e6814c83f2df345fecb763c078/string-concatenation_jdk8.json" rel="noopener noreferrer"&gt;http://jmh.morethan.io/?sources=https://gist.githubusercontent.com/jzillmann/7d23b2382911cc434754a23773b06598/raw/1bcad4bb64624d8a2be15114a4eee4c406c3ae95/string-concatenation_jdk7.json,https://gist.githubusercontent.com/jzillmann/866d39d43b264f507a67368f2313baca/raw/d0ae1502e8c493e6814c83f2df345fecb763c078/string-concatenation_jdk8.json&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jmh.morethan.io/?gist=7d23b2382911cc434754a23773b06598" rel="noopener noreferrer"&gt;http://jmh.morethan.io/?gist=7d23b2382911cc434754a23773b06598&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jmh.morethan.io/?gists=7d23b2382911cc434754a23773b06598,866d39d43b264f507a67368f2313baca" rel="noopener noreferrer"&gt;http://jmh.morethan.io/?gists=7d23b2382911cc434754a23773b06598,866d39d43b264f507a67368f2313baca&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is especially helpful if you want to share your results with others, e.g. in an issue tracker!&lt;/p&gt;

&lt;h3&gt;
  
  
  Gradle JMH Report
&lt;/h3&gt;

&lt;p&gt;Once the online visualizer was build, it was straightforward to put it inside a &lt;a href="https://gradle.org/" rel="noopener noreferrer"&gt;Gradle&lt;/a&gt; plugin which then could produce a local report for executed benchmarks. You find it here: &lt;a href="https://plugins.gradle.org/plugin/io.morethan.jmhreport" rel="noopener noreferrer"&gt;https://plugins.gradle.org/plugin/io.morethan.jmhreport&lt;/a&gt; with a getting-started guide included in &lt;a href="https://github.com/jzillmann/gradle-jmh-report" rel="noopener noreferrer"&gt;https://github.com/jzillmann/gradle-jmh-report&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note: This plugin only generates a visual report based on a benchmark result. It does NOT execute your benchmark suite for you &lt;em&gt;(I’ve written about how to setup execution in&lt;/em&gt; &lt;a href="https://dev.to/o_a_e/jmh-with-gradle--from-easy-to-simple-4jj9-temp-slug-1646988"&gt;&lt;em&gt;JMH with Gradle — From Easy to Simple&lt;/em&gt;&lt;/a&gt;&lt;em&gt;).&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Jenkins Plugin
&lt;/h3&gt;

&lt;p&gt;Finally… automation… Hooked up the online visualizer in a &lt;a href="https://jenkins.io" rel="noopener noreferrer"&gt;Jenkins&lt;/a&gt; plugin as well: &lt;a href="https://plugins.jenkins.io/jmh-report" rel="noopener noreferrer"&gt;https://plugins.jenkins.io/jmh-report&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This allows to run your benchmarks suite regularily and figure out regressions or improvements easily (even in a big suite).&lt;/p&gt;

&lt;h3&gt;
  
  
  Above and Beyond
&lt;/h3&gt;

&lt;p&gt;JMH is quite a beast. Writing meaningful benchmarks isn’t as easy as writing good unit tests (and even that is challenging at times). Understanding the inner mechanics of the JVM is often necessary to understand some of the “awkwardnesses” of JMH and to avoid the common pitfalls which are inherent when it comes to micro benchmarking.&lt;/p&gt;

&lt;p&gt;I found that visualizing the data JMH produces helped me a great deal to understand JMH and to write acceptable benchmarks. I would love to build on that. It’s probably easy to analyze the benchmarks and yield warnings or tips to the user (like “This benchmark has a high variation, try…”) and by thus helping other JMH starters... However, due lack of free time, respectively due abundance of idea’s creating software for a better world… i’m not sure how much i’m going to drive this stack forward… So participation is appreciated, contact me through &lt;a href="https://github.com/jzillmann/jmh-visualizer/issues" rel="noopener noreferrer"&gt;https://github.com/jzillmann/jmh-visualizer/issues&lt;/a&gt; !!&lt;/p&gt;

&lt;p&gt;Also, you might be interested in a &lt;a href="https://gist.github.com/jzillmann/9668664923e6c8f19596078ff8bb5456" rel="noopener noreferrer"&gt;list of other JMH tools&lt;/a&gt; i put together.&lt;/p&gt;




</description>
      <category>jvm</category>
      <category>jmh</category>
      <category>benchmarking</category>
      <category>report</category>
    </item>
    <item>
      <title>JMH with Gradle — From Easy to Simple</title>
      <dc:creator>Johannes Zillmann</dc:creator>
      <pubDate>Thu, 20 Oct 2016 22:22:54 +0000</pubDate>
      <link>https://dev.to/o_a_e/jmh-with-gradle--from-easy-to-simple-52ec</link>
      <guid>https://dev.to/o_a_e/jmh-with-gradle--from-easy-to-simple-52ec</guid>
      <description>&lt;p&gt;&lt;a href="http://openjdk.java.net/projects/code-tools/jmh/"&gt;JMH&lt;/a&gt; is &lt;em&gt;a Java harness for building, running, and analyzing nano/micro/milli/macro benchmarks written in Java and other languages targeting the JVM&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gradle.org/"&gt;Gradle&lt;/a&gt; is my current build tool of choice.&lt;/p&gt;

&lt;p&gt;This post tells how to setup JMH in gradle.&lt;/p&gt;

&lt;p&gt;Starting with the simple approach. Just include and use this plugin: &lt;a href="https://github.com/melix/jmh-gradle-plugin"&gt;https://github.com/melix/jmh-gradle-plugin&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I used it quite a while and it worked out of the box for smaller projects. On medium sized ones i run into some problems, but could resolve them by making use of its configurations (like &lt;strong&gt;zip64 = true&lt;/strong&gt; ). For a larger project with a complex dependency setup however, i run into some additional classpath problems.&lt;/p&gt;

&lt;p&gt;So i took a step back, looked what the project was doing, also cast a glance at &lt;a href="http://gvsmirnov.ru/blog/tech/2014/03/10/keeping-your-benchmarks-separate.html"&gt;http://gvsmirnov.ru/blog/tech/2014/03/10/keeping-your-benchmarks-separate.html&lt;/a&gt; and figured… it’s not as complex… and can be even less complex… E.g. i don’t see why i need that shadow jar stuff!&lt;/p&gt;

&lt;h4&gt;
  
  
  Step by Step
&lt;/h4&gt;

&lt;p&gt;Common practice is to have the JMH benchmarks separated, like instead of putting them e.g. in &lt;strong&gt;src/test/java&lt;/strong&gt; , put them into &lt;strong&gt;src/jmh/java&lt;/strong&gt;. Do that in gradle by adding another source-set:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sourceSets { 
  jmh 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In case your benchmarks using classes from your tests, do it like that:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sourceSets { 
    jmh { 
        compileClasspath += sourceSets.test.runtimeClasspath 
        runtimeClasspath += sourceSets.test.runtimeClasspath 
        } 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Next you wanna setup the dependencies for that new source-set called &lt;strong&gt;jmh&lt;/strong&gt;. So everything your benchmarks depend on, which is usually the project itself (with all its dependencies) and the JMH jars:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dependencies { 
    jmhCompile project 
    jmhCompile 'org.openjdk.jmh:jmh-core:1.18' 
    jmhAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.18' 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Note: &lt;strong&gt;jmhCompile&lt;/strong&gt; is bound to the &lt;strong&gt;jmh&lt;/strong&gt; source-set definition. You can choose the source-set name freely. If you call it e.g. &lt;strong&gt;benchmark&lt;/strong&gt; , use &lt;strong&gt;benchmarkCompile&lt;/strong&gt; in the dependencies section!&lt;/p&gt;

&lt;p&gt;Anyone still using Eclipse ? This piece helps to set it up correctly:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;eclipse { 
    classpath { 
        plusConfigurations.add(configurations.jmhCompile) 
        defaultOutputDir = file('build/classes-jmh-ide') 
    } 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The final piece is about the execution of the benchmark. In its simplest version it looks like that:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;task jmh(type: JavaExec, description: 'Executing JMH benchmarks') { 
    classpath = sourceSets.jmh.runtimeClasspath 
    main = 'org.openjdk.jmh.Main' 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;But almost certainly you wanna enhance that version, making some of JMH’s parameter, parameter of the Gradle task. E.g. the regex to select the Benchmarks + writing the result to a JSON file:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;task jmh(type: JavaExec, description: 'Executing JMH benchmarks') { 
    classpath = sourceSets.jmh.runtimeClasspath 
    main = 'org.openjdk.jmh.Main' 

    def include = project.properties.get('include', ''); 
    def format = project.properties.get('format', 'json'); 
    def resultFile = file("build/reports/jmh/result.${format}") 
    resultFile.parentFile.mkdirs() 

    args include 
    args '-rf', format 
    args '-rff', resultFile 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Voila, now you can run your benchmarks with:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gw jmh2 -Pinclude=“.\*MyBenchmark.\*”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Note: &lt;em&gt;There are probably still more parameters you wanna pass through… see the below complete version for some more i found useful.&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Complete version
&lt;/h4&gt;

&lt;p&gt;Putting everything together and adding some sugar and spice (jmhHelp task, more parameters, etc..) leaves us with that:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;h4&gt;
  
  
  Closing Story
&lt;/h4&gt;

&lt;p&gt;Few month back i discovered another Gradle plugin — think it was about annotation processing — and told my dear friend and colleague &lt;a href="https://mascha.me"&gt;Mascha&lt;/a&gt; about it. I was enthusiastic, he was like ’yeah, i would check what the plugin is doing really, i’m preferring to do simple things on my own lately’.&lt;/p&gt;

&lt;p&gt;I virtually raised my eyebrows in a way he couldn’t see it (i like re-using things), but didn’t confront.&lt;/p&gt;

&lt;p&gt;Now weeks later, i figured he is right! This time… ;)&lt;/p&gt;

&lt;h4&gt;
  
  
  Final Words
&lt;/h4&gt;

&lt;p&gt;I hope you enjoyed the post! Let me know if you think it’s worth making this a plugin… ;)&lt;/p&gt;

&lt;p&gt;Actually, there seems to be a plugin doing the JMH integration in a similar way: &lt;a href="https://github.com/blackboard/jmh-gradle-plugin"&gt;https://github.com/blackboard/jmh-gradle-plugin&lt;/a&gt;. Checked it out, i haven’t!&lt;/p&gt;




</description>
      <category>jmh</category>
      <category>gradle</category>
      <category>benchmarking</category>
      <category>jvm</category>
    </item>
  </channel>
</rss>
