Here's what your Mithril examples looks like with Aberdeen:
let count = proxy(0);
function Counter() {
$('div', () => {
$('h1:Counter'),
$('p:'+count.value),
$('button:+', { click: () => count.value += 1 }),
$('button:-', { click: () => count.value -= 1 })
})
}
$(Counter);
// Or just Counter() would work in this case
The '.value' is needed because we can't proxy a number directly. This extra step goes a way if you have more data to store, like `person = {name: 'Peter', age: 42}`.Besides that, looks pretty similar yeah! Works rather differently though. :-)
Thanks for the example. I agree they look very similar, which is what dsego saw intuitively and commented on.
The difference in the two examples is essentially whether things need to be proxied or not.
If someone does not mind that proxying, then Aberdeen has an advantage over Mithril by avoiding the complexity of the vdom internally. So, presumably the rendering code is simpler, which may have some benefits in performance and also debuggability in some cases. You can get surprising vdom-code-related errors from Mithril sometimes for something misconfigured in a hyperscript "m" call. Also the vdom regeneration can sometimes have issues if you don't specify a "key" for each m() widget, needed sometimes so the vdom can be sure to replace DOM nodes efficiently and correctly.
If someone does mind the proxying requirement (like me), then Mithril has the advantage in that regard of seeming simpler to code for (without the data wrappers). Mithril applications also may be easier to debug in some other cases -- because you don't have an extra proxy levels as indirection in viewing your data model.
So, both approaches have their pros and cons depending on preferences and priorities.