<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Albert Skibinski on Medium]]></title>
        <description><![CDATA[Stories by Albert Skibinski on Medium]]></description>
        <link>https://medium.com/@askibinski?source=rss-88d83dcd8e6b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*nFvCl3hawgvDCN9nrrfUaw.png</url>
            <title>Stories by Albert Skibinski on Medium</title>
            <link>https://medium.com/@askibinski?source=rss-88d83dcd8e6b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 10:33:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@askibinski/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Drupal 10 Single Directory Components + Storybook]]></title>
            <link>https://medium.com/@askibinski/drupal-10-single-directory-components-storybook-23d9ec59ecae?source=rss-88d83dcd8e6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/23d9ec59ecae</guid>
            <category><![CDATA[drupal]]></category>
            <category><![CDATA[storybook]]></category>
            <dc:creator><![CDATA[Albert Skibinski]]></dc:creator>
            <pubDate>Mon, 18 Dec 2023 22:55:44 GMT</pubDate>
            <atom:updated>2024-02-11T08:57:52.380Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FiGOJDJjexjWGxDHMvymVQ.png" /><figcaption>Image generated by ChatGPT</figcaption></figure><p><strong>Note</strong>: This is an update on the <a href="https://medium.com/@askibinski/integrating-storybook-with-drupal-ddabfc6c2f9d">blogpost I wrote in 2019</a> about integrating Drupal with Storybook.</p><p><strong>Update</strong> 02/2024: There is also a new <a href="https://www.drupal.org/project/storybook">Drupal Storybook</a> module which uses a different approach. It does not use Twig.js but uses a drush command to convert stories written in Twig to JSON and then uses a Storybook setup as server to <a href="https://dev.to/gromnan/storybook-with-server-side-twig-components-easy-43ii">server-side render the JSON</a> into components (instead of client side rendering the components directly as done in this post).</p><h4>Single Directory Components</h4><p>Since Drupal 10.1 we can use <a href="https://www.drupal.org/docs/develop/theming-drupal/using-single-directory-components/about-single-directory-components">Single Directory Components</a> (SDC) as an experimental module. More background info on that <a href="https://www.lullabot.com/articles/getting-single-directory-components-drupal-core">here</a>, but in this post we use SDC and integrate it with Storybook using <a href="https://vitejs.dev/">Vitejs</a> as a more modern builder (instead of webpack).</p><p>So can we leverage that and hopefully improve our setup from 2019 and simplify usage? Yes! Because thanks to SDC we can now use a more complete pattern of embedding/including components in twig templates like this:</p><pre>{{ include(&#39;my_theme:my_component&#39;, {<br>  title: &#39;Hello world!&#39;,<br>  some_other_prop: false<br>}, with_context = false)<br>}}</pre><p>The component is automatically retrieved based on the ID (theme or module name and component name, separated by “:”) so we do not need to use the namespaces anymore provided by components module and defining libraries ourselves. Any css and js with the same name are automatically attached too so we do not need to do that manually anymore!</p><h4>Setup Storybook with ViteJS</h4><p>If you’re not familiar with Storybook I wrote a short intro on that in the older post.</p><p>We start again by using <a href="https://storybook.js.org/docs/guides/guide-html/">Storybook for HTML</a> but storybook also needs a builder. We use <a href="https://vitejs.dev/">Vitejs</a> since we want everything blazingly fast.</p><pre>npm create vite@latest vitejs -- --template vanilla</pre><p>This will scaffold a new vitejs build app in a folder called “vitejs”. You can name it whatever you want. Package.json files will be there, and some other files. Read more in the <a href="https://vitejs.dev/guide/">create vitejs guide</a>.</p><p>Then, install storybook for HTML.</p><pre>npx storybook@latest init --type html</pre><p>Now, start storybook and it should work, but without any integration yet. You should see the demo components provided though.</p><pre>npm run storybook</pre><h4>Twig.js</h4><p>Now we will need some additional libraries to handle Twig templates. Why? Well, Twig templates are server-side templates which are normally rendered with <a href="https://github.com/twigphp">TwigPHP</a> to HTML by Drupal, but Storybook is a JS tool. In order to render our Twig templates in Storybook, we need to make Storybook understand Twig.</p><p>We need the JS equivalent of TwigPHP and that is exactly what <a href="https://github.com/twigjs">Twig.js</a> is.</p><blockquote>Note: a different approach is using the <a href="https://www.drupal.org/project/cl_server">cl_server</a> module which allows to render Twig in storybook by Drupal/php. This has benefits but it also requires a working Drupal server.</blockquote><p>Twig.js will be automatically added as a dependency when we install the <a href="https://www.previousnext.com.au/blog/drupal-front-end-nirvana-vite-twig-and-storybook">Vite Plugin Twig Loader</a> to load twig files with our vitejs builder.</p><pre>npm install --save-dev vite-plugin-twig-drupal</pre><p>Besides twig.js the plugin will also add <a href="https://github.com/JohnAlbin/drupal-twig-extensions">drupal-twig-extensions</a> and <a href="https://github.com/ericmorand/drupal-attribute">drupal-attribute</a> as dependencies.</p><p>Note that if your Twig templates contain custom Twig functions which you will need to convert these to JS if you want these templates to function in Storybook.</p><h4>ViteJS configuration</h4><p>Add a <strong>vite.config.js</strong> file with these contents, note the path to your components.</p><pre>import { defineConfig } from &quot;vite&quot;<br>import twig from &#39;vite-plugin-twig-drupal&#39;;<br>import { join } from &quot;node:path&quot;<br>export default defineConfig({<br>  plugins: [<br>    twig({<br>      namespaces: {<br>        components: join(__dirname, &quot;../components&quot;),<br>      },<br>    }),<br>  ],<br>})</pre><h4>Storybook configuration</h4><p>You should have a preview.js and main.js file in your .storybook folder.</p><p>In <strong>main.js </strong>change the path to your components to “components” instead of “stories” since that folder will be the folder in your theme containing the single directory components.</p><blockquote>Note that you can arrange the folder structure anyway you like and the path to your components can change based on your vitejs app root.</blockquote><pre>stories: [<br>  &quot;../../components/**/*.mdx&quot;,<br>  &quot;../../components/**/*.stories.@(js|jsx|mjs|ts|tsx)&quot;,<br>],</pre><h4>Create a component</h4><p>Follow the <a href="https://www.drupal.org/docs/develop/theming-drupal/using-single-directory-components/quickstart">quickstart</a> to create a single directory component in your Drupal theme.</p><p>After that you should have a component in your theme components folder, something like: my_theme/components/my_component.<br>In there you should have at least a twig file and and a my_component.component.yml file for SDC.</p><p>You should already be able to use this component from any other twig template by embedding it:</p><pre>{{ include(&#39;my_theme:my_component&#39;, {<br>  title: &#39;Hello world!&#39;,<br>  some_prop: false<br>}, with_context = false)<br>}}</pre><p>In addition, create a *.stories.js file so storybook also recognizes the thing.</p><p><strong>my_component.stories.js:</strong></p><pre>export default {<br>  title: &#39;Components/MyComponent&#39;,<br>};<br><br>// Twig file.<br>import myTemplate from &quot;./my_component.twig&quot;;<br><br>// CSS file.<br>import &#39;./my_component.css&#39;;<br><br>// JS file.<br>import &#39;./my_component.js&#39;;<br><br>export const myComponent = () =&gt; (<br>  myTemplate({<br>    title: &#39;Lorem ipsum!&#39;,<br>  })<br>);</pre><h4>Use it!</h4><p>Now, you should be able to use the component anywhere in Drupal (using include, embed or in an render array) and have it available in Storybook too!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23d9ec59ecae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Storybook with Drupal]]></title>
            <link>https://medium.com/@askibinski/integrating-storybook-with-drupal-ddabfc6c2f9d?source=rss-88d83dcd8e6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ddabfc6c2f9d</guid>
            <category><![CDATA[storybook]]></category>
            <category><![CDATA[drupal]]></category>
            <dc:creator><![CDATA[Albert Skibinski]]></dc:creator>
            <pubDate>Fri, 01 Nov 2019 14:17:45 GMT</pubDate>
            <atom:updated>2023-11-14T08:05:33.306Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Gtg1HDT-W0-7LX6EPQiSg.jpeg" /></figure><blockquote><strong>Note</strong>: this article was written when Drupal 8 was the active Drupal version. Drupal 10.1 now has <a href="https://www.drupal.org/docs/develop/theming-drupal/using-single-directory-components">Single Directory Components</a> in core (beta) offering a different implementation using the same concepts . See also the contrib <a href="https://www.drupal.org/project/sdc">sdc project</a> and modules that extend this functionality for Storybook integration options.</blockquote><p>Storybook is a tool for organizing UI components and an alternative to PatternLab, another design system which is more opiniated towards atomic design.</p><p>Both systems can be used to independently design and create components and integrate them into Drupal but Storybook has some interesting features.</p><p>Storybook is much more oriented towards modern webapps built in Javascript frameworks like React, Vue or Angular. In fact, Storybook itself is a tool built in JS and because of this has allows for great reusability (more on this later).</p><p>Also, Storybook is most powerful when used in larger projects, with potentially multiple teams working on different apps but within the same brand. They’re honest about this on their <a href="https://www.learnstorybook.com/design-systems-for-developers/react/en/introduction/">design system introduction</a>:</p><blockquote>If you work with a modest team on a single app, you’re better off with a directory of UI components instead of setting up the infrastructure to enable a design system.</blockquote><p>So, Storybook really shines in large projects with decoupled apps. If you already have a decoupled Drupal with one of the popular JS frameworks, you can simple start by using one of the <a href="https://storybook.js.org/docs/guides/slow-start-guide/">guides</a> for your preferred framework.</p><p><strong>Note</strong>: There is an <a href="https://storybook.canny.io/roadmap/p/add-ability-to-run-multiple-frameworks-in-1-storybook">active issue on the roadmap</a> to support multiple frameworks in one Storybook.</p><h3>What about Twig?</h3><p>If you’re using Drupal with its default frontend template layer Twig, you need to roll your own Storybook integration. For this post, our team at <a href="https://www.intracto.com/nl-be">Intracto</a> (special thanks to <a href="https://twitter.com/denniscohn?lang=en">Dennis Cohn</a>) investigated a couple of approaches to this challenge. The goal being a guide to the most simple integrations of Storybook with your existing Drupal Twig theme (non decoupled Drupal).</p><p>You can follow along with this post by using this <a href="https://github.com/askibinski/drupal_storybook_theme/tree/blog-post">Github repo</a> or by using a theme of your own. The only requirement is the block.html.twig file is present in your theme and compatible with the one in Drupal core’s Classy theme.</p><p>We start by using <a href="https://storybook.js.org/docs/guides/guide-html/">Storybook for HTML</a>, because this is the most simple version without any JS framework dependencies.</p><p>In your Drupal theme, add Storybook by installing it with npm. Here we assume you already have a package.json because you probably already use gulp/webpack or other tools in your frontend build pipeline. If not, just npm init first.</p><pre>npm init<br>npm install <a href="http://twitter.com/storybook/html">@storybook/html</a> --save-dev</pre><p>And don’t forget to add it to your npm scripts in package.json:</p><pre>&quot;scripts&quot;: {<br>  &quot;storybook&quot;: &quot;start-storybook&quot;<br>}</pre><p>You might already have Babel as a dependency, otherwise add them too:</p><pre>npm install babel-loader @babel/core --save-dev</pre><p>Now we will need some additional libraries to handle Twig templates. Why? Well, Twig templates are server-side templates which are normally rendered with <a href="https://github.com/twigphp">TwigPHP</a> to HTML by Drupal, but Storybook is a JS tool. In order to render our Twig templates in Storybook, we need to make Storybook understand Twig.</p><p>We need the JS equivalent of TwigPHP and that is exactly what <a href="https://github.com/twigjs">Twig.js</a> is.</p><pre>npm install twig --save-dev</pre><p>This the core of Twig functionality but we also need three more libraries to help us:</p><pre>npm install twig-loader twig-drupal-filters drupal-attribute --save-dev</pre><p>Let’s go through them so we now what we are doing:</p><p><a href="https://github.com/zimmo-be/twig-loader">Twig-loader</a> is a <a href="https://webpack.js.org/loaders/">webpack loader</a>; it automatically requires twig.js, compiles the Twig template and returns a function. Without it we can’t actually load the Twig templates later on.</p><p><a href="https://www.npmjs.com/package/twig-drupal-filters">Twig-drupal-filters</a> is the JS implementations of the Twig functions and filters which are added and used by Drupal. Without it you wouldn’t be able to use templates with filters like <em>clean_class</em> or <em>safe_join</em>.</p><p>And drupal-attribute adds the helper methods like addClass(), removeClass(), setAttribute() and so one, which are <a href="https://www.drupal.org/docs/8/theming-drupal-8/using-attributes-in-templates">provided by Drupal</a>.</p><p><strong>Note</strong>: if your Twig templates contain custom Twig functions which you will need to convert these to JS if you want these templates to function in Storybook.</p><h3>Configuration</h3><p>Next stop is configuration. In your Drupal theme create a .storybook folder and in it two files: config.js and webpack.config.js.</p><p><strong>config.js:</strong></p><pre>import { <strong><em>configure </em></strong>} from &#39;@storybook/html&#39;;<br>import Twig from &#39;twig&#39;;<br>import twigDrupal from &#39;twig-drupal-filters&#39;;</pre><pre>// Add the filters to Twig instance.<br>twigDrupal(Twig);<br><br><strong><em>configure</em></strong>(<strong><em>require</em></strong>.context(&#39;../components&#39;, true, /\.stories\.js$/), <strong><em>module</em></strong>);</pre><p>This is the main Storybook configuration and here we assume our components will be created (in just a minute) in a components folder in your theme. But this can be anywhere. We also import the Twig dependencies we added earlier.</p><p><strong>webpack.config.js:</strong></p><pre>const path = <strong><em>require</em></strong>(&#39;path&#39;);<br><br><strong><em>module</em></strong>.exports = ({ config }) =&gt; {<br><br>  // Twig:<br>  config.module.rules.push({<br>    test: /\.twig$/,<br>    use: [<br>      {<br>        loader: &#39;twig-loader&#39;,<br>      },<br>    ],<br>  });</pre><pre>  return config;<br>};</pre><p>This is the webpack configuration necessary for twig-loader. Note that you can add twigOptions using the options parameter. See <a href="https://github.com/zimmo-be/twig-loader">documentation</a>.</p><h3>Create a component</h3><p>Create a <em>components</em> folder in your Drupal theme folder and in it a <em>block</em> folder with the following files: block.stories.js, block.twig, and block.css.</p><p><strong>block.stories.js:</strong></p><pre>export default { title: &#39;Blocks&#39; };<br><br>import block from &#39;./block.twig&#39;;<br>import drupalAttribute from &#39;drupal-attribute&#39;<br>import &#39;./block.css&#39;;<br>import &#39;./block.js&#39;;</pre><pre>export const default_block = () =&gt; (<br>    block({<br>        attributes: new drupalAttribute(),<br>        title_attributes: new drupalAttribute(),<br>        plugin_id: &quot;Some plugin&quot;,<br>        title_prefix: &quot;&quot;,<br>        title_suffix: &quot;&quot;,<br>        label: &quot;I&#39;m a block!&quot;,<br>        content: &quot;Lorem ipsum dolor sit amet.&quot;,<br>        configuration: {<br>            provider: &quot;Some module&quot;<br>        }<br>    })<br>);</pre><p>This <a href="https://medium.com/storybookjs/component-story-format-66f4c32366df">component story syntax</a> is pretty new in Storybook and uses <a href="https://codeburst.io/javascript-arrow-functions-for-beginners-926947fc0cdc">ES6 arrow function</a> syntax. We provide the variables which are needed in the Twig template, which is also the reason why use <em>drupal-attribute </em>here: the<em> </em>Twig templates uses attributes.addClass as we will see next.</p><p><strong>block.twig:</strong></p><pre>{%<br>  set classes = [<br>    &#39;block&#39;,<br>    &#39;block-&#39; ~ configuration.provider|clean_class,<br>    &#39;block-&#39; ~ plugin_id|clean_class,<br>  ]<br>%}<br>&lt;div{{ attributes.addClass(classes) }}&gt;<br>  {{ title_prefix }}<br>  {% if label %}<br>    &lt;h2{{ title_attributes }}&gt;{{ label }}&lt;/h2&gt;<br>  {% endif %}<br>  {{ title_suffix }}<br>  {% block content %}<br>    {{ content }}<br>  {% endblock %}<br>&lt;/div&gt;</pre><p>This is exactly the same twig template you will find in Drupal core’s Classy template: <a href="https://api.drupal.org/api/drupal/core%21themes%21classy%21templates%21block%21block.html.twig/8.7.x">block.html.twig</a>.</p><p><strong>block.css</strong>:</p><pre>.block {<br>    border: 3px solid #FF0000;<br>    padding: 20px;<br>}<br><br>h2 {<br>    margin-top: 0;<br>}</pre><p>The CSS file contains just something to set it apart for demoing purposes.</p><p><strong>block.js:</strong></p><pre><strong><em>console</em></strong>.log(&#39;Javascript works!&#39;);</pre><p>Normally, the block component in Drupal doesn’t use any special JS, but for our example we will add something for demonstration purposes.</p><p>Your theme folder should look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*tPCO-0ULDwOkLXaZ0Yq08A.png" /></figure><p>Allright, let’s start Storybook up:</p><pre>npm run storybook</pre><p>You should see a browser window with something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*1AFL8FmkPm9Yyom4x5Xqbg.png" /></figure><h3>Using the Twig template in Drupal</h3><p>At this point your basic Storybook setup is ready. Now, we would like to acually use this Twig template in Drupal. The easiest way to do this is by including the Twig file from another Twig file already provided by Drupal.</p><p>We can do this by leveraging <a href="https://symfony.com/doc/current/templates.html#templates-namespaces">Twig namespaces</a>. Drupal core already does this (see <a href="https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Template%21Loader%21FilesystemLoader.php/class/FilesystemLoader/8.7.x">FilesystemLoader</a>) for all your normal modules and themes but does not provide a way to register custom namespaces.</p><p>This is why we need the <a href="https://www.drupal.org/project/components">components</a> module to setup namespaces so we can easily include our Twig templates.</p><pre>composer require drupal/components</pre><p>Enable the module and setup the path in your theme’s info.yml file:</p><pre>component-libraries:<br>  storybook:<br>    paths:<br>      - components</pre><p>You can easily create an atomic design structure here (or any structure you desire), with atoms, molecules, organisms and so on. But for the sake of simplicity in this article we only define one @storybook namespace which maps to our components.</p><p><strong>block.html.twig</strong> (in Drupal templates):</p><pre>{% include &quot;@storybook/block/block.twig&quot; with {<br>  &quot;attributes&quot;: attributes,<br>  &quot;title_attributes&quot;: title_attributes,<br>  &quot;plugin_id&quot;: plugin_id,<br>  &quot;title_prefix&quot;: title_prefix,<br>  &quot;title_suffix&quot;: title_suffix,<br>  &quot;label&quot;: label,<br>  &quot;content&quot;: content,<br>  &quot;configuration&quot;: configuration,<br>} %}</pre><p>Here we include our Storybook component with the variables needed.</p><h3>What about Javascript and CSS?</h3><p>At this point we don’t have the javascript or CSS (fromt the storybook component) included in the Drupal twig file. So let’s set it up.</p><p>For JS, the recommended way to attach javascript behaviours is by attaching it with the <a href="https://www.drupal.org/docs/8/api/javascript-api/javascript-api-overview">Drupal.behaviour</a> object. However, Storybook knows nothing about Drupal.behaviours (nor should it). Ideally you just want to write nice system-independent ES6 code for your components.</p><p>Fortunately, there is a Babel plugin which adds this a wrapper to generated JS files.</p><pre>npm install --save-dev @babel/cli babel-plugin-drupal-behaviors</pre><p><strong>Note</strong>: we also need babel-cli for running the next command. Create a new build script for this in your package.json:</p><pre>&quot;scripts&quot;: {<br>  &quot;storybook-js&quot;: &quot;npx babel components -w -d dist/components --ignore &#39;components/**/*.stories.js&#39; --presets=@babel/preset-env,babel-preset-minify --plugins=babel-plugin-drupal-behaviors&quot;<br>}</pre><p>Running npm run storybook-js will now generate the same folder structure of our storybook components but with the JS wrapped in a Drupal behaviour in a folder dist/components in your Drupal theme. Nice! This we can use in Drupal.</p><p>But first let’s also generate processed CSS in the same destination structure using Webpack.</p><pre>npm install --save-dev webpack webpack-cli mini-css-extract-plugin webpack-fix-style-only-entries</pre><p>Create a <strong>webpack.config.js</strong> in a new <em>webpack</em> folder:</p><pre>const path = <strong><em>require</em></strong>(&#39;path&#39;);<br>const glob = <strong><em>require</em></strong>(&#39;glob&#39;);<br>const loaders = <strong><em>require</em></strong>(&#39;./loaders&#39;);<br>const plugins = <strong><em>require</em></strong>(&#39;./plugins&#39;);<br><br><strong><em>module</em></strong>.exports = {<br>  entry: glob.sync(&#39;./components/**/*.css&#39;).reduce((entries, path) =&gt; {<br> <em>   </em>const entry = path.replace(&#39;/index.js&#39;, &#39;&#39;);<em><br>    </em>entries[entry] = path;<br>    return entries;<br>  }, {}),<br>  output: {<br>    path: path.resolve(__dirname, &#39;../dist&#39;)<br>  },<br>  module: {<br>    rules: [<br>      loaders.CSSLoader,<br>    ]<br>  },<br>  plugins: [<br>    plugins.MiniCssExtractPlugin,<br>    plugins.FixStyleOnlyEntriesPlugin,<br>  ],<br>};</pre><p><strong>Note</strong>: checkout the repository for the loaders.js and plugins.js configuration included here for readability!</p><p>Let’s go through this config. First of all it creates <a href="https://dev.to/bbenefield89/webpack-how-to-create-dynamic-entry-output-paths-1oc9">dynamic entry and output paths</a> so we keep the same folder structure which is used in the storybook components folder. It creates an entry for each CSS file in our storybook components folder.</p><p>Then we are using the CSS loader because we want to load .css files. Two plugins are used. <em>MiniCssExtractPlugin</em> because Webpack by default generates JS but we want CSS as output. And the FixStyleOnlyEntriesPlugin because otherwise Webpack will always also generate a JS file for each entry CSS file and we want our destination dir to be clean.</p><p>Add a script for this config:</p><pre>&quot;scripts&quot;: {<br>  &quot;storybook-css&quot;: &quot;webpack -d --config ./webpack/webpack.config.js --display-error-details&quot;,<br>},</pre><p>And run it via npm run storybook-css. You should now see a block.css next to the generated block.js which was generated by storybook-js.</p><p><strong>Note</strong>: At this point you might ask why bother with Webpack because effectively we didn’t do much (yet) with the CSS except copying it. That’s true but you can now easily expand this webpack config to include any post processing, minifying, linting and so on. Or you could use SASS in Storybook (see below) and use sass-loader to create CSS.</p><h3>Drupal asset libraries</h3><p>The recommended way to add CSS and JS to Drupal is using <a href="https://www.drupal.org/docs/8/creating-custom-modules/adding-stylesheets-css-and-javascript-js-to-a-drupal-8-module">asset libraries</a>. This can be done through the theme’s <strong>*.libraries.yml. </strong>For example, we could add something like this:</p><pre>block:<br>  version: VERSION<br>  css:<br>    component:<br>      dist/components/block/block.css: { weight: -10 }</pre><p>But defining the library assets in the yml file like above can be cumbersome and easy to forget with hundreds of components. So, we can use <em>hook_library_info_build </em>to dynamically define these libraries by traversing the components for CSS (and JS).</p><p><strong>drupal_storybook_theme.theme:</strong></p><pre>/**<br> * Implements hook_library_info_build().<br> */<br>function drupal_storybook_theme_library_info_build() {<br>  $extensions = [&#39;css&#39;, &#39;js&#39;];<br>  $directory = &#39;themes/drupal_storybook_theme/components&#39;;<br>  $extensions = array_map(&#39;preg_quote&#39;, $extensions);<br>  $extensions = implode(&#39;|&#39;, $extensions);<br>  $file_scan = file_scan_directory($directory, &quot;/{$extensions}$/&quot;);<br>  $libraries = [];<br>  foreach ($file_scan as $file) {<br>    $parts = explode(&#39;.&#39;, $file-&gt;filename);<br>    $extension = end($parts);<br>    switch ($extension) {<br>      case &#39;css&#39;:<br>        $libraries[$file-&gt;name][$extension] = [<br>          &#39;component&#39; =&gt; [<br>            &#39;/&#39; . $file-&gt;uri =&gt; [],<br>          ],<br>        ];<br>        break;</pre><pre>      case &#39;js&#39;:<br>        $libraries[$file-&gt;name][$extension] = [<br>          &#39;/&#39; . $file-&gt;uri =&gt; [],<br>        ];<br>        break;<br>    }<br>  }</pre><pre>  return $libraries;<br>}</pre><p>This will generate library assets with JS and CSS in one asset (as long as the filenames are unique per component and identical for CSS and JS).</p><p>One last thing: actually use this asset in the Drupal twig template we used earlier:</p><p><strong>block.html.twig:</strong></p><pre>{{ attach_library(&#39;drupal_storybook_theme/block&#39;) }}<br>{% include &quot;@storybook/block/block.twig&quot; with {...}</pre><p>Okay, that’s it! Clear the cache and reload the page where your Twig template is used (anything with a block really) and you should see the styling used in Storybook. Try changing something in the Storybook template to see the difference reflected in Drupal, after running the build commands (you can create watchers for this).</p><h3>What about SASS?</h3><p>It’s possible to directly use SASS files in storybook by using the sass-loader and editing the webpack.config.js in .storybook. See also storybook’s documentation on <a href="https://storybook.js.org/docs/configurations/custom-webpack-config/">this topic</a>.</p><pre>// Sass support.<br>config.module.rules.push({<br>  test: /\.scss$/,<br>  use: [&#39;style-loader&#39;, &#39;css-loader&#39;, &#39;sass-loader&#39;],<br>  include: path.resolve(<strong><em>__dirname</em></strong>, &#39;../&#39;),<br>});</pre><p>Now you will be able to import .scss files directly from your stories.js.</p><h3>Reuse components</h3><p>A powerful feature of Storybook is reusability accross projects and teams. This is wel explained on their <a href="https://www.learnstorybook.com/design-systems-for-developers/react/en/distribute/">website</a> but basically, you have to create NPM packages of your design components which can be used by other projects. Then, you only have to add those components as a dependency in your project and they will show up together with your projects’ components in one Storybook.</p><p>So, imagine you have a central repository with design components, then all other projects only have to update the dependency if they want to use newly added components.</p><h3>Addons and extending Storybook</h3><p>Storybook also has a lot of great <a href="https://storybook.js.org/addons/">addons</a> which are easy to integrate. Some of the most useful ones which we started to use immediately are <a href="https://github.com/storybookjs/storybook/tree/master/addons/notes">Notes</a>, <a href="https://github.com/storybookjs/storybook/tree/master/addons/viewport">Viewport</a> and <a href="https://github.com/storybookjs/storybook/tree/master/addons/a11y">A11y</a>.</p><p>But you can also implement quality assurance tools like<a href="https://storybook.js.org/docs/testing/automated-visual-testing/"> automated visual testing</a>. There is quite a lot of information online about possibilities like this so check them out.</p><h3>Conclusion</h3><p>While it is nice to have Drupal and Storybook use the same Twig templates, CSS and JS, there are caveats and room for improvement.</p><p>First, the ‘additional Twig layer’ (by including templates in other twig templates) seem less then ideal, however it is the easiest and most practical implementation if you don’t want to change existing default Drupal behaviour. There are <a href="https://www.drupal.org/project/ideas/issues/2702061">core ideas</a> to make Drupal more ‘component driven’ but we will probably see more movement on this topic in contrib with initiatives like <a href="https://www.drupal.org/project/sfc">single file components</a> or <a href="https://www.compony.io/">compony</a>.</p><p>Second, with this approach you still need to make sure all the variables which are designed in Storybook are provided by Drupal. It’s one thing to convert existing templates but it’s another when your frontender wants to use data which is not easily provided by Drupal. AmazeeLabs wrote an interesting article explaining how they bypassed this problem by using <a href="https://www.amazeelabs.com/en/journal/using-twig-storybook-and-drupal">GraphQL in Twig with Storybook</a> to pull data rather then let Drupal push it.</p><p>Third, while we didn’t encounter this yet, we heard there are small differences between the Twig.js and PHP implementation. And there is the issue we mentioned earlier with custom Twig filters or functions you might have in Drupal which would have to be rebuilt in JS for Storybook.</p><p>Also worth noting is that Emulsify will switch from Patternlab to Storybook in their <a href="https://decoupleddays.com/session/announcing-emulsify-5-design-system-using-gatsby-and-storybook">upcoming release</a> and if you want to join the discussion checkout the #storybook channel at drupaltwig.slack.com. Alsoalso, Drupalcon Amsterdam 2019 has some <a href="https://www.youtube.com/user/DrupalAssociation/videos">videos</a> about Storybook + Drupal.</p><p>Happy storybooking and any feedback is welcome!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ddabfc6c2f9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blockchain: een vooruitblik op 2018]]></title>
            <link>https://medium.com/@askibinski/blockchain-een-vooruitblik-op-2018-1ddbe0014b1f?source=rss-88d83dcd8e6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ddbe0014b1f</guid>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Albert Skibinski]]></dc:creator>
            <pubDate>Fri, 29 Dec 2017 13:23:02 GMT</pubDate>
            <atom:updated>2017-12-29T14:53:48.796Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8EZ-BkSRmHIQe1z1JI4cRw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/sb8k76RX0J8?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Bekir Dönmez</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><strong><em>Het is een </em></strong><a href="https://medium.com/@askibinski/het-wordt-een-spannende-zomer-voor-blockchain-9985dc6b87a2"><strong><em>half jaar geleden</em></strong></a><strong><em> dat ik enthousiast over blockchain en met name Bitcoin en andere crypto schreef. Nu, net voor de jaarwisseling, maak ik de balans op en kijk ik vooruit naar de ontwikkelingen voor het komend jaar.</em></strong></p><h3>Bitcoin</h3><p>De ambitie van Bitcoin is om een wereldwijde, decentraal betaalmiddel te worden en <em>store of value</em>. Als je op de site van <a href="https://bitcoin.org/nl/">bitcoin.org</a> dan zie je daar (ten tijde van dit artikel) 3 speerpunten staan:</p><ul><li>Supersnelle p2p-transacties</li><li>Wereldwijde betalingen</li><li>Geen of lage verwerkingskosten</li></ul><p>Het probleem is dat momenteel alleen het 2e punt nog enigzins klopt. Supersnel waren de transacties eigenlijk nooit. Ja natuurlijk, als je nu met normale valuta een overboeking doet naar de andere kant van de wereld kan het soms dagen duren en dan is de minimale 10 minuten confirmation tijd snel te noemen. Maar je kopje koffie afrekenen wordt lastiger.</p><p>En doordat er meer transacties zijn dan het netwerk aankan, worden de verwerkingskosten hoger en hoger. Wil je namelijk zeker weten dat jouw transactie er doorheen komt, dan kan je maar beter zorgen dat de<em> transaction fee</em> hoog genoeg is. Momenteel is deze <a href="https://bitcoinfees.info/">meer dan $ 20</a> als je wil dat je transactie binnen het uur (!) is verwerkt.</p><blockquote>Bitcoin kan maximaal 7 transacties per seconde uitvoeren. Ter vergelijking: Visa kan <a href="https://usa.visa.com/dam/VCOM/download/corporate/media/visa-fact-sheet-Jun2015.pdf">56.000</a> transacties per seconden aan</blockquote><p>Voor normale dagelijkse betalingen is Bitcoin momenteel dus ongeschikt want er kunnen maar maximaal 7 transacties per seconde gedaan worden. Ter vergelijking: Visa kan <a href="https://usa.visa.com/dam/VCOM/download/corporate/media/visa-fact-sheet-Jun2015.pdf">56.000</a> transacties per seconden aan (maar het gemiddelde ligt op 2000 met pieken naar 4000).</p><p>Wil Bitcoin kans maken om een betaalmiddel te worden dan zal de bandbreedte flink opgeschroefd moeten worden. Natuurlijk wordt daaraan gewerkt en er is een flinke <a href="https://medium.freecodecamp.org/future-of-bitcoin-cc6936ba0b99">lijst aan voorstellen voor verbeteringen</a>. Een van deze voorstellen heet <em>Lightning Network</em>.</p><h3>Het probleem met Lightning Network</h3><p>Met Lightning Network kunnen transacties grotendeels off-chain behandeld worden. Het probleem is dat het er sterk op lijkt dat de enige manier waarop dit kan gaan werken is wanneer er grote “hubs” ontstaan met genoeg kapitaal. Dit zorgt voor centralisatie: exact iets dat juist niet de bedoeling was, want vervang het woord “hubs” door “banken” en we zijn weer terug bij af.</p><p>In onderstaande video wordt het heel helder uitgelegd.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FUYHFrf5ci_g&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DUYHFrf5ci_g&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FUYHFrf5ci_g%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5be53dfe42de26472b697604a6391570/href">https://medium.com/media/5be53dfe42de26472b697604a6391570/href</a></iframe><p>Natuurlijk weten we niet 100% zeker dat dit zo gaat werken - het is nu eenmaal nieuw terrein - maar er zijn (wiskundige) <a href="https://medium.com/@jonaldfyookball/mathematical-proof-that-the-lightning-network-cannot-be-a-decentralized-bitcoin-scaling-solution-1b8147650800">bewijzen </a>dat het zo zal gaan. We zullen het komend jaar zien want Lightning network is <a href="https://www.coindesk.com/lightning-last-test-shows-bitcoin-scaling-solution-almost-ready/">bijna klaar</a>.</p><h3><strong>Is Bitcoin Cash de echte Bitcoin?</strong></h3><p>De Bitcoin SegWit <em>hard fork</em> van 1 augustus was nodig om Lightning Network (LN) te implementeren. Op dat moment is ook <a href="https://www.bitcoincash.org/">Bitcoin Cash</a> (BCH) ontstaan. Een groep ontwikkelaars die weigerde om SegWit toe te passen omdat zij het oneens waren met deze visie. In plaats van SegWit/LN kiest Bitcoin Cash ervoor om de block size te vergroten en daarmee het aantal transacties dat per block opgenomen kunnen worden. Bitcoin Cash gebruikt momenteel blocksize van 8MB in plaats van de 1MB van Bitcoin dus is er ruimte voor 8x zoveel transacties.</p><p>Dat je het met 8MB ook niet gaat redden is duidelijk maar BCH vertrouwt op de <a href="https://nl.wikipedia.org/wiki/Wet_van_Moore">wet van Moore</a>: volgens deze verdubbelt het aantal transistoren op processors elke 2 jaar en deze groei zou je kunnen ook toepassen voor bandbreedte en opslag. Het vergroten van de block size zou dus geen probleem moeten zijn en in 2018 zal deze dan ook verder omhoog gaan naar 32 MB.</p><blockquote>De wet van Moore: volgens deze wet verdubbelt het aantal transistoren op processors elke 2 jaar</blockquote><p>Het risico wat volgens sommigen hierbij op de loer ligt is dat er weer centralisatie ontstaat op een ander vlak: vanuit de miners omdat toch duurdere specialistische hardware gebruikt moet gaan worden en dit dus door minder mensen gedaan kan worden. Er zijn echter ook <a href="https://www.youtube.com/watch?v=sbD0kiTddEs">argumenten </a>dit dit weer ontkrachten.</p><p>Overigens is Roger Ver een groot supporter en promotor van Bitcoin Cash. Nadat hij bekendheid kreeg als “Bitcoin Jesus” omdat hij een van de eerste Bitcoin millonairs is, is hij nu van mening dat Bitcoin Cash de echte Bitcoin is. Op internet krijgt Roger verbazingwekkend <a href="https://www.reddit.com/r/btc/comments/7b0uj5/why_do_so_many_people_hate_roger_ver/">veel haat</a> over zich heen. De twee kampen staan online vaak lijnrecht tegenover elkaar.</p><h3>Hoe wil Ethereum schalen?</h3><p>Bitcoin Cash is niet de enige concurrent voor Bitcoin. Ethereum positioneert zich niet als betaalmiddel maar kan dat wel worden. Maar ook Ethereum kan momenteel maar iets meer transacties per seconde verwerken. Het netwerk raakte onlangs overbelast nadat een game (<a href="https://www.cryptokitties.co/">Cryptokittens</a>) die gebruik maakte van de Ethereum blockchain populair werd. Als een simpel spelletje het netwerk kan laten vastlopen dan is het wel duidelijk dat het nog niet geschikt is voor grote toepassingen.</p><p>Ethereum heeft eveneens een aantal <a href="https://medium.com/blockchain-hub/scaling-ethereum-103c677c803e">proposals klaarstaan</a> om de schaalbaarheid te vergroten. Vergelijkbaar met Lightning Network heeft Ethereum het <a href="https://raiden.network/">Raiden Network</a> dat ook off-chain transacties wil verzorgen om de main blockchain te ontlasten.</p><p>Vitalik Buterin (de bedenker van Ethereum) richt zich vooral op <a href="https://medium.com/animal-media/why-business-needs-ethereum-plasma-now-scaling-problems-pt-1-8d6186438b5">Plasma</a>, een ambitieus project waarbij hiërarchisch met child-chains (blockchains in blockchains) gewerkt wordt.</p><p>Het lijkt erop dat Vitalik deze route, in combinatie met andere verbeteringen zoals Sharding en Proof of Stake prefereert. Als het lukt zou het een enorme boost zijn voor het Ethereum project.</p><blockquote><strong>Proof of Stake</strong> (PoS) is een andere manier waarop een blockchain transacties kan valideren. Proof of Work (PoW) is de manier waarop Bitcoin en Ethereum momenteel werken en vereist dat een netwerk van computers dezelfde berekeningen uitvoeren. Meer uitleg over PoW in mijn <a href="https://medium.com/@askibinski/het-wordt-een-spannende-zomer-voor-blockchain-9985dc6b87a2">vorige artikel</a> hierover. Het nadeel van PoW is dat het ontzettend veel energie in de vorm van electriciteit vereist. <a href="https://currentcrypto.nl/verschil-proof-of-work-en-proof-stake/">Proof of Stake uitleg vind je hier</a>.</blockquote><h3>Blockchain as a Service</h3><p>Was 2017 het jaar van Bitcoin en gaan we vanaf 2018 (en later) andere vooral blockchains as a service zien (BaaS)? Hieronder een een aantal projecten die interessant zijn.</p><p><em>EOS </em>is nog in ontwikkeling wordt vaak genoemd als concurrentie voor Ethereum (nickname “Ethereum On Steroids)”en gebruikt al Proof of Stake en biedt ook features als <a href="https://medium.com/@yobanjo/eos-storage-explained-225dd997d598">storage</a>. Ontwikkeling ligt bij 1 bedrijf. Gaat begin van de zomer live.</p><p><em>NEO</em>, ontstaan uit een Chinese startup, lijkt goede papieren te hebben voor een nieuwe smart economy en <a href="https://hackernoon.com/neo-versus-ethereum-why-neo-might-be-2018s-strongest-cryptocurrency-79956138bea3">lijkt op</a> Ethereum.</p><p><em>Ardor</em>, een blockchain-as-a-service platform waarbij de technologie van NXT gebruikt wordt. Je kan het dus zien als een soort NXT 2.0. Vervolgens zal Ignis de eerste child-chain zijn op Ardor. Conceptmatig lijkt dit heel erg op wat Ethereum van plan is met bovenstaand Plasma project. Ardor gaat 1 januari 2018 live.</p><p>Natuurlijk zijn er nog talloze andere projecten met grote beloften. Bijvoorbeeld Lisk, Stratis, Ark en Cardano. Het is de vraag of er genoeg ruimte is voor al deze projecten samen en Ethereum of dat er uiteindelijk een paar overblijven.</p><h3>Litecoin, Ripple en Lumen</h3><p><em>Litecoin</em>, ook wel het zilver van bitcoins goud genoemd, is ook sterk in populariteit gestegen afgelopen jaar. Litecoin heeft als relatief klein project het voordeel dat ze sneller veranderingen kunnen doorvoeren, terwijl ze toch qua code veel op Bitcoin lijken. Ook zullen Bitcoin en Litecoin door middel van <a href="https://cointelegraph.com/news/first-btc-ltc-lightning-network-swap-completed-huge-potential">atomic swaps</a> uitwisselbaar zijn. Saillant detail: Charlie Lee (bedenker van Litecoin) <a href="https://techcrunch.com/2017/12/20/litecoin-charlie-lee-conflict-of-interest/">verkocht onlangs al zijn Litecoins</a> om belangenverstrengeling te voorkomen.</p><p><em>Ripple </em>heeft een sterke groei gezien afgelopen maanden en deelt zijn geschiedenis met <em>Stellar Lumen</em>. Voor het complete verhaal kan ik je deze <a href="http://observer.com/2015/02/the-race-to-replace-bitcoin/">longread </a>aanraden. Ripple richt zich vooral op banken en heeft hierin grote bondgenoten gemaakt omdat de kosten voor banken lager worden en de efficiency vergroot kan worden. Stellar is idealistischer ingesteld, decentraler en richt zich niet alleen op banken, maar heeft wel IBM als partner.</p><h3>Echte toepassingen?</h3><p>Vitalik riep onlangs alle crypto communities op om zinvolle toepassingen te maken en hekelt de snel-rijk-worden cultuur die momenteel om de cryptowereld hangt.</p><h3>Vitalik Non-giver of Ether on Twitter</h3><p>All* crypto communities, ethereum included, should heed these words of warning. Need to differentiate between getting hundreds of billions of dollars of digital paper wealth sloshing around and actually achieving something meaningful for society. https://t.co/aNpEnBNGsA</p><p>Zijn er dan geen echte toepassingen, naast spelletjes om kattenplaatjes te verzamelen? Die zijn er wel maar schaars. Ripple wordt al <a href="https://www.forbes.com/sites/tomgroenfeldt/2017/11/01/leading-banks-in-using-ripple-blockchain-value-its-speed/#2d3d18a63930">wel </a>echt gebruikt door banken en natuurlijk zijn er genoeg plekken in <a href="http://www.bitcoinspot.nl/waar-kan-je-in-nederland-met-bitcoins-betalen/zoo-frontpage.html">Nederland </a>en wereldwijd waar je met bitcoin kan betalen, maar in de praktijk wordt dat vanwege de hoge koersvolatiliteit, hoge kosten en lage snelheid waarschijnlijk weinig gedaan. Cijfers zijn moeilijk te vinden, maar game platform Steam heeft <a href="https://www.theverge.com/2017/12/6/16743220/valve-steam-bitcoin-game-store-payment-method-crypto-volatility">onlangs besloten bitcoin niet meer aan te bieden</a> vanwege deze redenen.</p><p>Totdat die problemen zijn opgelost kan je Bitcoin natuurlijk zien als “digitaal goud” maar die vergelijking is gevaarlijk. Van goud weten we dat het in tijden van crisis waardevol is. Bitcoin heeft die test nog niet doorstaan.</p><p>Dichter bij huis zijn er wel genoeg pilots in Nederland om te experimenteren met blockchain. <a href="https://www.blockchainpilots.nl/pilotronde3">De derde testronde is zojuist afgerond</a>.</p><p>Volgens <a href="https://bravenewcoin.com/news/gartners-puts-blockchain-at-the-peak-of-inflated-expectations-while-bitcoin-slides-into-the-trough-of-disillusionment/">Gartner werd blockchain in 2016</a> nog op het hoogtepunt gezet waarna een desillusie periode volgt alvorens we echte toepassingen krijgen. Het is dus best mogelijk dat we eerst een “blockchain en cryptowinter” krijgen alvorens de echte toepassing en waarde voor de massa ontstaat.</p><p><em>Disclaimer: de auteur schrijft op persoonlijke titel en bezit een kleine hoeveelheid van enkele in het artikel genoemde cryptocurrency.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ddbe0014b1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Het wordt een spannende zomer voor blockchain]]></title>
            <link>https://medium.com/@askibinski/het-wordt-een-spannende-zomer-voor-blockchain-9985dc6b87a2?source=rss-88d83dcd8e6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9985dc6b87a2</guid>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[litecoin]]></category>
            <dc:creator><![CDATA[Albert Skibinski]]></dc:creator>
            <pubDate>Wed, 12 Jul 2017 19:48:43 GMT</pubDate>
            <atom:updated>2017-07-12T19:56:14.829Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DC-hZN28XBFzRHf3UhyeEQ.jpeg" /><figcaption>Foto David Lezcano</figcaption></figure><p><strong><em>“Het voelt als het internet van de jaren 90” vertelde ik onlangs enthousiast nadat ik me verdiept had in de recente ontwikkelingen. Jaren terug, in 2013, kwam ik voor het eerst in aanraking met blockchain en was er maar een handjevol spelers. Dat is inmiddels wel anders.</em></strong></p><p>De afgelopen jaren is duidelijk geworden dat de blockchain-technologie veel potentie heeft. De hype lijkt momenteel op zijn <a href="https://www.frankwatching.com/archive/2017/05/17/de-blockchain-revolutie-feiten-fabels-obstakels-de-toekomst/">hoogtepunt</a> te zijn: in de media verschijnen berichten over hoe je slapend rijk kunt worden door te speculeren met <em>cryptovaluta</em>, startups halen door ICO’s miljoenen op en videokaarten zijn niet meer aan te slepen vanwege de vraag van <em>miners</em>. Maar deze zomer kan het weleens extra spannend worden.</p><h4>Hoe zat het ook alweer?</h4><p>Mocht je willen weten hoe het ook alweer zat: hierbij een korte samenvatting hoe blockchain werkt bij Bitcoin. Een decentraal netwerk van duizenden computers verspreid over de hele wereld controleert continu alle transacties in een “blok”. Elk blok bevat alle transacties over een periode van ongeveer 10 minuten.</p><p>Het doel van het netwerk is om <em>consensus </em>te verkrijgen over de transacties zodat ze vastgelegd kunnen worden (geverifieerd) in een blok in de blockchain. Simpel gezegd: alle computers moeten het erover eens zijn dat de transacties kloppen. Als ze daar eenmaal in zijn opgenomen, kunnen ze nooit meer aangepast worden.</p><p>Om die consensus te krijgen, wordt er een bepaalde hoeveelheid werk verricht door alle computers in het netwerk. Dit heet ook wel <em>minen </em>en gebeurt door middel van een zogenaamd <a href="https://decentralize.today/how-does-proof-of-work-um-work-f44642b24215">Proof-of-Work</a> algoritme waarbij een bepaalde <em>hash </em>gevonden dient te worden. Dat duurt ongeveer 10 minuten. Als we daar verder in duiken, wordt het nogal technisch maar als je benieuwd bent hoe dit precies werkt kan ik je deze <a href="https://anders.com/blockchain/">demo</a> aanraden.</p><p>Bitcoin was de eerste die gebruik maakte van blockchain-technologie, maar sinds het ontstaan daarvan in 2009 zijn er talloze andere toepassingen ontstaan zoals bijvoorbeeld Ethereum.</p><blockquote>Je hoort nogal eens dat Ethereum de nieuwe Bitcoin is, maar daarmee sla je de plank eigenlijk een beetje mis</blockquote><h4>Ethereum</h4><p>Wonderkind <a href="http://business.financialpost.com/feature/the-cryptocurrency-prophet/wcm/faf71b6d-df9b-42dd-9ede-ba35725957c5">Vitalik Buterin</a> bedacht Ethereum, dat in 2015 live ging. Net zoals bij Bitcoin is dit een publiek, open-source project, maar het grootste verschil is dat Ethereum bedoeld is als een gedistribueerd netwerk om <em>smart contracts</em> uit te laten voeren. Je kan dus scripts schrijven die door het Ethereum-netwerk worden uitgevoerd (daarover later meer).</p><p>Je hoort nogal eens dat Ethereum de nieuwe Bitcoin is, maar daarmee sla je de plank eigenlijk een beetje mis. Ethereum is namelijk helemaal niet bedacht als betaalmiddel. Er is weliswaar een munt “Ether”, maar die is eigenlijk alleen bedoeld als vergoeding richting het netwerk dat het werk uitvoert. Coins (of tokens, zoals ze soms ook wel genoemd worden) zijn sowieso niet noodzakelijk, het hangt vooral af van de <a href="https://medium.com/@pavelkravchenko/does-a-blockchain-really-need-a-native-coin-f6a5ff2a13a3">toepassing</a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FTDGq4aeevgY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DTDGq4aeevgY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FTDGq4aeevgY%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/40041bbfca368b93bcfba07cecb87851/href">https://medium.com/media/40041bbfca368b93bcfba07cecb87851/href</a></iframe><h4>Foutje, bedankt</h4><p>Ethereum heeft dus meer mogelijkheden dan Bitcoin doordat er <em>Turing complete</em> code uitgevoerd kan worden: complete programma’s. Maar daarin schuilen ook gevaren. Zo maakte in 2016 één gebruiker 168 miljoen dollar waard aan Ether buit door een <a href="https://tweakers.net/reviews/4437/all/the-dao-blockchains-en-ethereum.html">ontwerpfout</a> in zo’n smart contract. Omdat de blockchain <em>immutable </em>(niet te veranderen)<em> </em>is, kun je achteraf fouten in code niet corrigeren en de enige manier om de “gestolen” valuta toch veilig te stellen was een <em>hard-fork</em> van de code. Dat heeft ervoor gezorgd dat er naast Ethereum ook een Ethereum <em>classic</em> bestaat. Dit veroorzaakte veel ophef omdat het tegenstrijdig is met de gedachte achter een <em>immutable </em>blockchain.</p><h4>ICO’s: crowdfunding 2.0</h4><p>Dankzij de smart contracts is veel mogelijk. Je kan bijvoorbeeld vrij gemakkelijk zelf een crowdsale opzetten waarbij je zelfverzonnen tokens verkoopt voor andere cryptovaluta (op de Ethereum-site zie je een <a href="https://www.ethereum.org/crowdsale">voorbeeld </a>hoe zo’n crowdsale smart contract er in code uitziet). Zo’n periode waarin deze tokens (coins) verkocht worden, heet een Initial Coin Offering (ICO). Het afgelopen jaar heeft dit geleid tot een <a href="http://Op https://www.smithandcrown.com/icos">stortvloed aan organisaties</a> die hiermee enorme bedragen hebben binnengehaald. Sommigen van deze startups hadden niet meer dan een mooie website en whitepaper.</p><h4>Schaalbaarheid</h4><p>Eén van deze ICO’s bracht een ander probleem aan het licht: schaalbaarheid. Door de opzet van de ICO van <a href="https://blog.status.im/introducing-status-ethereum-918b1447274">Status </a>(een startup die een mobile OS voor Ethereum wil maken) werd namelijk het Ethereum-netwerk enorm belast, waardoor er geen transactie meer doorheen kwam en het netwerk een lange tijd onbruikbaar was. Het effect was ongeveer hetzelfde als een DDoS aanval op een website. Ook zorgde het voor een tijdelijke <a href="https://bravenewcoin.com/news/ethereum-difficulties-send-ether-tumbling">vrije val</a> van de munt.</p><h4>Inefficiënt</h4><p>Het probleem is dat de PoW methode zeer inefficiënt en slecht schaalbaar is. Zo verbruikt Ethereum naar schatting momenteel ongeveer net zoveel elektriciteit als <a href="https://motherboard.vice.com/en_us/article/d3zn9a/ethereum-mining-transaction-electricity-consumption-bitcoin">Cyprus</a>. Ook Bitcoin heeft hier last van. Was het in 2011 nog normaal dat <a href="https://www.cryptocoinsnews.com/death-zero-fee-bitcoin-transaction">transacties niets kostten</a>, anno 2017 kan een transactie makkelijk een paar euro kosten. Dat komt omdat een Bitcoin block standaard maar ruimte heeft voor 1MB aan transacties.</p><p>Doordat Bitcoin steeds populairder wordt en er dus steeds meer transacties zijn, willen steeds meer gebruikers dat hun transactie zo snel mogelijk geverifieerd wordt in het eerstvolgende blok. Dit leidt automatisch tot hogere <em>fees</em> en heeft ervoor gezorgd dat Bitcoin niet meer aantrekkelijk is voor micropayments. <a href="https://medium.com/@InstituteCrypto/why-we-switched-to-litecoin-as-our-main-cryptocurrency-e98d60eb3229">Sommigen</a> schakelen daarom ook al over op andere coins.</p><blockquote>Voor Bitcoin is het extra spannend deze zomer omdat er harde deadlines zijn</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*7J7yi5nkgUHIw2rPh037Vg.jpeg" /><figcaption>Foto Wikimedia Commons/ Guaca</figcaption></figure><h4>Spannende zomer</h4><p>Dit zijn erkende problemen waarvoor ontwikkelaars druk naar een oplossing zoeken. Voor Bitcoin is het <a href="https://bitcoinmagazine.com/articles/bip-148-and-bip-149-two-uasfs-activate-segwit">extra spannend deze zomer</a> omdat er harde deadlines zijn: linksom of rechtsom zal rond 1 augustus <em>Segregated Witness</em> (SegWit) doorgevoerd worden. SegWit is een uitbreiding die onder andere een basis legt voor verdere verbeteringen aan de schaalbaarheid. Doordat er verschillende partijen (miners en gebruikers) met andere belangen zijn, kan dit deze zomer zelfs leiden tot een opsplitsing van de blockchain. Als Bitcoin wel goed de zomer doorkomt, ligt de weg vrij voor verdere verbeteringen zoals <a href="http://themerkle.com/what-is-the-lightning-network">Lightning Network</a> (een methode om transacties te bundelen) en misschien ook <a href="https://paymentsmarket.com/rootstock-is-fusing-the-lightning-network-with-on-chain-scaling-on-a-sidechain">Rootstock</a> (een manier om via sidechains Ethereum’s smart contract mogelijkheden te “porten” naar Bitcoin).</p><h4>Kansen</h4><p>Andere altcoins zien kansen waar Bitcoin worstelt. Litecoin bijvoorbeeld heeft reeds SegWit <a href="https://bitcoinmagazine.com/articles/litecoin-has-now-deployed-segregated-witness">geïmplementeerd </a>en is hard bezig om ook zaken als <a href="http://www.coindesk.com/could-litecoin-be-the-first-major-blockchain-with-lightning/">Lightning Network</a> en <a href="https://bitcoinmagazine.com/articles/the-next-step-to-improve-bitcoin-s-flexibility-scalability-and-privacy-is-called-mast-1476388597/">MAST</a> (smart contracts) toe te voegen. Dit zijn allemaal verbeteringen die ook voor Bitcoin van toepassing kunnen zijn en Litecoin lijkt een ideale testomgeving omdat de code van Litecoin erg veel lijkt op die van Bitcoin. Litecoin is namelijk van origine een Bitcoin fork.</p><p>Van de andere kant is een nauwere samenwerking tussen altcoins en Bitcoin in de toekomst ook mogelijk dankzij <a href="https://bitcoinmagazine.com/articles/atomic-swaps-how-the-lightning-network-extends-to-altcoins-1484157052">Atomic Swaps</a> waardoor je coins die Lightning Network ondersteunen onderling kunt uitwisselen. Je zou dan bijvoorbeeld overal waar je met Bitcoin kan betalen ook met Litecoin kunnen betalen.</p><p>Ethereum denkt ook hard na voor mogelijkheden om de schaalbaarheid op te voeren. Tegelijkertijd ziet Vitalik fundamentele <a href="https://www.cryptocoinsnews.com/vitalik-buterin-ethereums-scalability-sucks/">problemen </a>die niet zo makkelijk op te lossen zijn. Misschien gaat het <a href="https://steemit.com/steemit/@darknet/ethereum-and-iot-is-a-partnership-for-the-next-industrial-revolution-or-steemit-crypto-mag-or-issue-5-or-8-august-2016">Raiden Network</a> uitkomst bieden? Hiermee komt ook weer een andere ontwikkeling van deze tijd in beeld: Internet of Things. Interessant!</p><p><em>Welke problemen gaat blockchain eigenlijk voor ons oplossen? Wat zijn de voordelen en willen we dit eigenlijk wel? En: hoe maak je nu eigenlijk zo’n app op de blockchain? Ik ben benieuwd hoe jullie daarover denken. Wordt vervolgd…</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9985dc6b87a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>