HNHacker News
TopNewBestAskShowJobs

sindreaa

49 karma · joined August 4, 2015

Developer of Imba. http://github.com/somebee
submissionscomments
sindreaa··on Imba: A new programming language for web apps
As you can see from inspecting the examples, any non-standard tag will use standard tags in the dom, with a class denoting their imba type.
sindreaa··on Imba: A new programming language for web apps
React and Imba can both optimize using shouldComponenUpdate (in Imba you would add the same logic inside node#commit). Utilising shouldComponentUpdate (in React and Imba) requires additional logic by the developer, not the framework. This is not an optimisation at the framework level - but an endpoint where the developer can write their own custom optimisations. Adding your own manual checks all around your app to check for statechanges is inelegant, cumbersome, and bug prone. In my opinion it defeats much of the purpose of a virtual dom, if you are expected to do your own diffing before sending it through. Also, the relative performance difference is about the same when turning it on.

I fully stand behind the benchmark, and would even go as far as saying that it is more relevant for real world applications than benchmarks like dbmonster where everything in the view updates on every render. This effectively tries to calculate how quickly each contestant can reconcile the whole view (synchronously), but when only parts of the view has actually changed.

Here is some additional discussion about the benchmark: https://github.com/somebee/imba/issues/9

sindreaa··on Imba: A new programming language for web apps
Imba is still lacking when it comes to devtools, but it does have full support for source mapping, and the sublime text plugin includes inline error messages from the compiler.
sindreaa··on Imba - create complex web apps with ease!
Yes, more like LiveScript / CoffeeScript. I don't think apps written in Imba really need anything like Redux/Flux, nor any other framework for that matter, since the way you define tags etc structures your code pretty well. We still don't have an official recommended way to do routing, as we're still experimenting with different approaches in real apps to see what sticks. You can check out the full source for the website at https://github.com/somebee/imba.io. It is not documented at all yet, but at least it gives some impression.
sindreaa··on Imba - create complex web apps with ease!
It compiles to standard js, and it's entirely unproblematic to interoperate with any/all js libraries. I myself use Imba whenever I need to write something for web/node, even if it is only a small library to be used in a larger javascript project, but obviously I'm quite biased. If you're thinking about specific libraries / cases I'm happy to write up an example.
sindreaa··on Imba - create complex web apps with ease!
The benchmark where mithril was much faster is very flawed, see comments from creators of vue: http://vuejs.org/perf/. Mithril was faster because it rendered asynchronously once every frame, while React rendered on every single simulated event. We will write a blogpost describing why Imba is in fact so much faster. I stand by the benchmark, and would love to explain it in detail. You can see some more discussion about it here: https://github.com/somebee/imba/issues/9
sindreaa··on Imba - create complex web apps with ease!
This is the new website for Imba. I'd love to get advice and constructive feedback regarding both the site itself, and the learning material.
sindreaa··on Imba – A new programming language for the web
> Also, I'm not sure I agree with claim of readable output js: http://somebee.github.io/todomvc-render-benchmark/todomvc/im.... (look at tag.prototype.render). It's not exactly clean, although it's not terrible either.

You are absolutely right, and I agree. When you use static tag trees in Imba (with inline caching) the code is not readable. If you only use it for regular things you would write in js (classes, functions, etc) I still think it is quite readable.

BTW, I really love the simplicity of Mithril. It is a very impressive project.

sindreaa··on Imba – A new programming language for the web
I now ran the benchmarks with the this['_' + i] change (which disables per-task caching, but does not really remove any/all caching alltogether. Imba is still 35x faster than react on the 'everything' benchmark (and even faster on the others). I still would write my apps exactly like they are in the original benchmark, but do you agree that the ['_' + i] change removes what you call 'sneaky code'?

UPDATE: Since the performance was just as good with this dumber type of caching I have changed the actual benchmark to work this way. Would you still consider that caching sneaky? If so, I'm not sure what to say. Yes, Imba caches dom nodes for reuse. That is the whole philosophy behind its 'virtual dom'. Now it does not 'leak memory' anymore either, even though this 'leak' is a feature (ref comment about manual pruning) and not a bug.

sindreaa··on Imba – A new programming language for the web
See comment: https://news.ycombinator.com/item?id=10095990. Thanks for taking the time to looking through the benchmark. I think you are misinterpreting things. Yes we do caching, and yes IF your app created a million tasks every second you would need to manually dereference them at some point. But you could change the caching (as mentioned in the comment) to never cache additional tags (instead of disabling all caching - which would be like going into the code of Mithril and React and remove all checks in the virtual dom).

I'm really glad to hear that it is still faster even when removing caching. That, to me, is quite insane. But if you wrote a TodoMVC app in Imba, you would do it _exactly_ like the one that is benchmarked. We have even considered adding asserts to warn users if they use uncached nodes in rendering that happens very frequently.

You are actually right that Imba does not dereference these automatically (see other comment re purging by judofyr: https://news.ycombinator.com/item?id=10092454). We could dereference unused tags once every second or so, but for now we think it is better to have manual control of this. Again, how much is usually happening during a render-cycle? Basically nothing. This benchmark is trying to look at how expensive it is to rerender the whole view. Maybe I should make the "Unchanged render" benchmark the main attraction (as it is the most important) -- but it is quite boring to look at.

sindreaa··on Imba – A new programming language for the web
Hi there.

This is utterly wrong, and if you had cared to read about what the benchmark is trying to achieve, you would understand (https://github.com/somebee/todomvc-render-benchmark).

You cannot simply remove caching and reusing nodes from the benchmark (which you do with that change). This is the way Imba does diffing, and it would be akin to removing the React virtual dom!

As we mention in the readme: "Even though it looks incredibly boring, the "Unchanged Render" is possibly the most interesting benchmark. All of these frameworks are plenty fast if they only render whenever something has changed. But if the frameworks are fast enough to render the whole app in 0.01ms, you could skip thinking about all sorts of tracking to keep the view in sync."

In a real world app you do not create 1000000 todos. The actual data rarely change that much. As for purging the cache, see comment: https://news.ycombinator.com/item?id=10092454. Quote:

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.

If you _really_ want to not cache things this way, you can change the line to:

    res.push((this['_' + i] = this['_' + i] || t$('todo')).se ...
Which would only ever cache as many dom nodes as there are tasks, but change which nodes are used for which tasks.
sindreaa··on Imba – A new programming language for the web
Thanks for the feedback. What do you mean with global variables for class state? We do consider moving class-bodies inside an actual function (again) - but there is a virtual scope there in the compiler. So

    class A
	var i = 10
    var i = 20
Compiles to

    function A(){ };	
    var i1 = 10;
    var i = 20;
So they are actually scoped even though it does not look like it in the compiled js. I'm looking really forward to improving the sublime plugin to show much more stuff from the compiler and warn about calls to undefined methods etc. There is a lot of analysis from the compiler that can be used to improve the ide-like experience.
sindreaa··on Imba – A new programming language for the web
Yes, it can. Serverside rendering is still not very well tested, but it does work. I will create a simple example soon.
sindreaa··on Imba – A new programming language for the web
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 :)