Hacker News new | ask | show | jobs
by ryannevius 4055 days ago
I went through something similar...and then I found Mithril (http://lhorie.github.io/mithril/).

I may be alone on this, but I've enjoyed working with Mithril much more than I ever did React. If you haven't given it a shot, I highly recommend you do.

7 comments

A lot of people praise Mithril for its small file size and speed, but one of its greatest and perhaps most overlooked advantages is its small learning curve. You only really need to understand two things to get started: what a component is (a plain JS object with controller and view), and when a redraw happens (once on m.mount, and once after every event handler).

Why is a low learning curve important? Several reasons. If you're a developer, it's not a huge investment to learn (how difficult was it to learn backbone / angular / ember?). If you're a startup / company, you don't need to look for X developers, where X is a difficult-to-pick-up JavaScript framework. You also save money by having a shorter on-boarding period for those non-X developers.

I've worked in a hackathon group that picked Mithril up and created amazing results with it right away. I teach at a coding school, and by far Mithril has been the easiest JS framework for my students to learn and work with. For being so powerful, Mithril is quite easy to get started with – and that means a lot.

We went with Mithril over React too. Both are good, but React + all of the libs needed to match Mithril is a fairly large payload for mobile-optimized websites, whereas Mithril is tiny.

Mithril didn't quite have everything we needed, though, so we made a small wrapper that provides nicer templating, event delegation, etc.: https://github.com/dailymuse/mithril-coat

I like Mithril a lot, but the only thing that puts me off it over React and Angular is I don't really know how to tie in third-party libraries like d3 and dropzone.
http://mithril.js.org/integration.html shows how to integrate a Select2 field in a Mithril template (thus interoperaing with jQuery).

You can use the same approach for other libraries:

Add a function as `config` attribute to your virtual DOM element. That function gets the real DOM element as a parameter, and you can act on it with third party libraries.

I'm very interested in more modular, simpler alternatives to react / flux. Essentially I'm looking for reactive "isomorphic" component based, virtual dom solutions like react - mainly to integrate with a node.js workflow.

I was wondering if anyone had tried both Mithril as well as Deku(https://github.com/segmentio/deku) who would like to share their experience?

What makes you like Mithril more? I've been looking at it for a while, and it seems very nice and lightweight.

All I really want is an easy way to get performant DOM manipulations. With React I have to build the whole view around the component system, which isn't so flexible. Am I right in thinking that Mithril allows you to put the view together any way you want, as long as the end result is an object it can diff into the DOM?

D3 can do DOM manipulation a. It's more well known for its charting (SVG) functionality. But I've used it to build tables and other data-based DOM structures.

It's not ideal for all use cases. But for updating the DOM based on changes to the data, I find it to be a useful option.

Square built and fast library on top of D3 called Crossfilter. Speed is pretty amazing when you see the data source. http://square.github.io/crossfilter/

> Am I right in thinking that Mithril allows you to put the view together any way you want, as long as the end result is an object it can diff into the DOM?

That's correct. Virtual DOM nodes are plain JS objects with `tag`, `attr` and `children` attributes (the last two being optional).

The `m()` helper gives you some sugar on top of that.

Idiomatic Mithril view code, however, is more about declaratively generating vDOM nodes based on a model and/or a view model than, say, jQuery-style DOM manipulations...

Thanks for sharing. I went from Backbone to Angular to Mithril, so it's nice to hear about folks experience with React.
Next up - how I stopped learning how to be a real developer and accepted what framework farcebook ejected today. Tomorrow - abdicating database decisions in favour of whatever I read about on HN today.