Hacker News new | past | comments | ask | show | jobs | submit login

Hi. We actually do a different kind of diffing - which turns out to be substantially faster than React: http://somebee.github.io/todomvc-render-benchmark/index.html. The language has just been released, it is still very lacking when it comes to documentation. Working on it :)



Can you give some details about Imba's diffing?


What part of the diffing?

Imba only uses `===` for diffing. If you want Imba to re-use a DOM node, you must use the same tag object. Imba provides syntax for caching nodes as properties on the current object.

For instance, in order to re-use DOM nodes in a for loop you do this:

    for event in @events
      <event@{event.id} name=event.name>
The loop body compiles down to:

    (this['_' + event.id()] = this['_' + event.id()] || t$('event')).setName(event.name()).end()
The next time you render the view, Imba will find the tag objects that have been reordered (using `===`) and move them to the right place.

One thing to be aware of is that Imba doesn't automatically remove the cache for you, because we've found that it's tricky to determine when you actually want to purge it. For instance:

    if mouseOver
      <something>
    else
      <something-else>
Just because `mouseOver` becomes true for one frame doesn't mean you want the `<something-else>`-tag to be purged from the cached and removed. Keeping it around is nice for performance and convenience (e.g. state, jQuery plugins).

In practice it turns out you want to purge whole pages/sections at the same time, which is way friendlier for the garbage collector as well.


Fair enough, I guess you have other more important things to do then.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: