Experience report: Rocket lander in Elm
blog.wearewizards.io
blog.wearewizards.io
Not true. the nature of the virtual-dom is that it doesn't rerender if nothing changes. The implementation in elm is extremely efficient. It doesn't even diff the actual DOM, it diffs the inputs to the DOM. It can do this because of the pure functional requirements of Elm.
It's possible that only applies to HTML and not to canvas. If that's the case then I would hope the technique will be applied to canvas soon.
That's the hard part. The virtual-dom takes care of this for you, but in the case of canvas, you'd have to determine whether or not anything actually changed, which involves keeping around a previous state and comparing it to the new state. It's certainly doable, but nowhere near as simple as using the virtual-DOM.
I've never come across this problem in a real life project, and this is a pointlessly contrived example that diminishes the rest of the article. This is not hard. It might be slightly baffling at the beginning, then after ten minutes you get used to it.
Arbitrariness is a constant mental penalty a programmer must pay for while reasoning in a language. It is not insurmountable, but one must wonder what could happen if the arbitrariness tax were reduced or lifted. It could be that whole realms of greater, more trustworthy abstraction are obscured by mental barriers such as this.
On the other hand, errors in logic because of truthiness/falsiness do occur pretty regularly in real code (I'm sure every JavaScript developer has at least once forgotten to check whether an argument is really undefined and then not very gracefully handled `0` being passed to that function)... and these problems do all have the same root cause: JavaScript's type system.
You can seldom do any validation given the ratio developer/on-site devs.
EDIT I guess this[1] answers my question. Gonna have to get into this...
[1] http://package.elm-lang.org/packages/elm-lang/core/1.1.0/Htt...
HTML5 offers now few ways to get easily to rock-solid 60fps considering that the graphics are very simple.