An alternative to virtual DOM < 20x faster!

Hello guys,
Have anyone checked Imba?
It’s a very interesting programming language that compiles to Javascript.
It uses a technique that’s explained here and in this screencast which they call imperative DOM even though you write declarative code.

The concept itself is pretty simple, andthis DOM reconciler benchmark (yes, it was written by the writer of Imba) gives very interesting results. Also try editing the number of todos in the top left and for 60 todos, Imba is 40x times faster than React !!!

This technique is feasible in a compile-to-js language, and it might make Elm way faster.



This is extremely interesting. However, as far as I understand, it relies on knowing from the template syntax whether a piece of DOM is static or dynamic.

As such, I doubt that would be feasible for Elm, since Elm doesn’t have a template syntax and views are just functions.

However, I would love to be wrong about this. Perhaps there is some really neat compiler technique that could special case this stuff?

Here is how it tests if a tag is static

	def isStatic
		let o = @options
		!o:hasConditionals and !o:hasLoops and !o:ivar and !o:key

We can check for the same thing using ASTs, right?

1 Like

This is interesting…

If you can tell which parts of the don are dynamic or static from an AST, presumably you could make fairly smart server-side rendered pages, in which dynamic sections are automatically separated out to JavaScript.


At the moment, the elm compiler isn’t aware of the Html type, Html is just a package (that does use some JS).
So this transformation would require significant compiler changes.

The observation that there is more change at the leaves than at the root is interesting though. Does anyone know how this relates to Html.Lazy?

1 Like

Wow! Those are impressive numbers, I wonder what the trade offs are.

The most impressive thing about this ‘screencast’ is that I got half way through before realising it wasn’t a video and was in fact a live editor being updated along with the explanation, you can stop at any point and edit the code yourself and see how it works.

We really need something like this for Elm!


The tool for that is called Scrimba and it’s built with Imba (probably the only app using it in production). There is a ticket asking for Elm support. But for now, it only supports javascript and typescript.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.