Preface

I started using Riot.js few years ago and it has changed my style of developing web applications.

I was tired to learn every day new concepts and convoluted ways to create always the same trivial components (accordions, overlays, custom input fields…).

Working with Riot.js opened my mind, it let me understand that even the most complex feature can be achieved with elegance and few code relying on the power of web components.

Riot.js was initially created by muut.com and developed by Tero Piirainen in 2015. I became the main maintainer of it while I was working on its second major release. Helped by an incredible international team of contributors, we were able to massively increase its user base (from 3k npm monthly downloads to 70k).

However I was unhappy with its original core design and with the new v4 version I took the time (almost 2 years) to completely rewrite and redesign the entire framework and all its ecosystem.

The Problem

This year (2019) web components support across browser vendors has massively improved but their API doesn’t seem to help much developers solving their simplest problems.

Frameworks like AngularJS, Ember.js and React.js seemed to simplify our life in the short term. However handling the amount of new concept and their convoluted APIs is a price that not every developer is willing to pay.

To solve this issue many other libraries like Vue.js and Svelte.js proved that you don’t need a complex API to develop beautiful interfaces. Being that true on one hand, on the other they add an incredible amount of magic to your code (reactive properties, Proxy, two-way-data binding, computed, observable…) binding you (and your mind) to specific framework idioms and meta programming techniques that might change on any major release. This is definitely not a future proof approach! Another problem is that even if these tools look simple at beginning, as soon as your projects starts growing, you will need to handle and understand many of the tricks they use under the hood. You will often need to deal with dirty hacks here and there to let your code running on several browsers.

The Solution

Riot.js 4 aims to be the tiniest, simplest and yet most predictable framework for web components. It is designed to offer you everything you wished native web components API looked like.

Having worked a lot with Vue.js during the last 3 years I am really impressed by the simplicity of its API.

Evan You is an incredible talented developer and I was able to take many ideas from Vue.js bringing them to Riot.js 4.

I avoided any sort of magic or asynchronous rendering strategy to manage the Riot.js components. Observables, two way data bindings and “short cuts” meta programming techniques have no place in Riot.js 4.

The components interface is transparent and explicit and there are no Riot.js ways to achieve your goals: you can develop your components as you prefer.

The result is a beautiful API that will be beloved by functional programmers (like me) and at same time it's impressively simple.

Let’s have a look for example at a component skeleton: