3 ms·
If you read this article and thought Hyperscript might be something you wanted to try, please check out Mithril[0]. It's an excellent project, pretty decently
by hardwaresofton 8y ago
If you read this article and thought Hyperscript might be something you wanted to try, please check out Mithril[0].
It's an excellent project, pretty decently fast (checkout the js-framework-benchmark[1] code, or more specifically the results of round 8[2]) -- but is currently suffering from a lack of recognition. It's the kind of project that absolutely doesn't care about that kind of metric (as in, the team seems to be more focused on slow, steady improvement of the library rather than chasing stars on github), but I figured I should say something.
Shameless plug: I recently really wanted to contribute something (and kick the tires more) so I wrote an article that goes through replicating a simple mail design I saw[3] -- it might be a decent overview of what mithril is like to write (though I'm certainly not a mithril expert).
This brings me back to the point at hand -- as others have noted, in my opinion one of the best things about hyperscript is the straight-forwardness with which you construct the render function. I'm not convinced it's necessary to segregate stateless/stateful components -- and mithril is simpler in that it doesn't introduce this dichotomy -- in the end there's the render function, and that's it. If you want to use state, go ahead -- if you don't, then don't. It's the simplicity I've wanted from component frameworks (and mostly get with Vue) without any of the posturing/looming complexity.
Also there's the fact that you could write a completely vanilla es5 application with hyperscript (arguments whether you should or not aside) -- JSX is/was revolutionary, but is basically required in practice, which often makes people jump into bed with webpack without thinking, and makes frontend development harder than it has to be.
[EDIT] - Another point for mithril is that it's self contained -- routing and ajax calls some with the framework. When people these days talk about "react" or "vue" what they're really talking about is react/vue + react-router/vue-router + flux/vuex and some other odds and ends. Mithril is by far the simplest and most feature-complete of these frameworks despite being smaller (both conceptually and on-the-wire).
One of my only current gripes with Mithril is the lack of controllable subtree rendering (it isn't as much of a problem in practice, but more me wanting to optimize early).
[0]: https://mithril.js.org https://mithril.js.org
[1]: https://github.com/krausest/js-framework-benchmark https://github.com/krausest/js-framework-benchmark
[2]: https://www.stefankrause.net/wp/?p=504 https://www.stefankrause.net/wp/?p=504
[3]: https://vadosware.io/post/mithril-systemjs-and-rollup-getting-started-guide/ https://vadosware.io/post/mithril-systemjs-and-rollup-gettin...
- plopz 8y agoMithril doesn't yet support ES Modules, so you have to take in the whole framework which probably includes things you don't want, like their ajax alternative or promise polyfill. If you just want a vdom library, I would recommend something like https://github.com/snabbdom/snabbdom https://github.com/snabbdom/snabbdom
- lhorie 8y agoThat's not quite true. While it's true that it doesn't export treeshakeable exports, you can import things piecemeal like `import h from 'mithril/hyperscript'`. The rationale is that mithril always tries to be explicit, whereas treeshaking is a form of compiler magic.
- hardwaresofton 8y agoContext: I'm pretty sure the parent (to this comment), lhorie, is the creator of Mithril: https://github.com/MithrilJS/mithril.js/graphs/contributors https://github.com/MithrilJS/mithril.js/graphs/contributors Thanks to you and the team of contributors for your continued hard work on Mithril! I'm having a blast using it.
- panoply 8y agoI enjoyed your article very much. I'm a huge fan and proponent of this framework. Since I come across Mithril I have used it exclusively on all internal projects at our agency and haven't looked back. Adopting Mithril also opened me up to a whole list of lesser known but vigorously thought through projects like BSS, Patchinko and the beautiful Meiosis pattern which changed the way I went about developing resulting in far better productivity.
- hardwaresofton 8y agoThank you very much! I really wanted to see more writing on the internet around Mithril -- it seems it's like lisp in the way that most people who are using it productively are just doing heads down working on stuff. > Since I come across Mithril I have used it exclusively on all internal projects at our agency and haven't looked back. I'd love to see some writing on some of the patterns you've developed with it! Also, it might be cool for mithril to have a "trusted by" section on their main page to showcase some companies that use mithril to increase trust for people who wander in (though I'm also OK with mithril not having this section -- it's a bit overly-prodcuty and distracting). > Adopting Mithril also opened me up to a whole list of lesser known but vigorously thought through projects like BSS, Patchinko and the beautiful Meiosis pattern which changed the way I went about developing resulting in far better productivity. > Adopting Mithril also opened me up to a whole list of lesser known but vigorously thought through projects like BSS, Patchinko and the beautiful Meiosis pattern which changed the way I went about developing resulting in far better productivity. Thanks a ton for the references, looking up all those things right now, looks like more pieces of the Mithril ecosystem that I've never heard of. Patchinko looks super useful (I'm surprised I've never needed something like this in the past...), and Meiosis looks like a simpler version of the reactive/flux pattern, and looks interesting to me since it's cross-framework!