Finding the good one: mithril

I have just read this insightful statement on this blog article about congitive load in Javascript

jQuery is undoubtedly useful when dealing with browser quirks, but once an application grows over a few thousand lines of code, unstructured jQuery code simply becomes too difficult to maintain, and you start needing the discipline of a framework to organize code. But when you’re at tens of thousands of lines of code, you start to run out of entity types to CRUD, and your application growth starts to build on top of existing concepts. This is when you need the mental shift from being a library consumer to being a reusable component author,

This clever guy is the creator of Mithril, a very small, well crafted javascript library a friend of mine pointed to (via github…):

Mithril is a client-side MVC framework – a tool to organize code in a way that is easy to think about and to maintain.

From my huble point of view Mithril is a all-javascript library, focused on MVC and minimal AJAX. In Mithril even the html part is built in Javascript. It seems a bad route, but I must admit it rocks a lot when you give it a try.

The second generation (jQuery) and third generation javascript library (ReactJS, AngularJS, knockout, etc) all suffers from a big dichotomy between the html template and the event code. It seems all clear on small use cases. Some library also “compile” templates. Sometime I think: “wait a moment, I am fighting with the GUI, or the GUI is part of my code?”.

It easy to think jQuery is unusable when your interface grows: you need some MVC system. So you pass to AngularJS. But The concept below angular a lot, and the reward seems always a bit less. I have no time and re-learning angular or KnockoutJS every time is a big deal.

Mithril is very easy to remember: a recursive, solid, functional-filter based approach.

I cannot stop to suggest you to give it a try.

Leave a Reply