5 ms·
Plenty of comments have arisen while I slept, so rather than answering all over the place, I’ll just post this comment to cover most of it, with a little unsoli
by chrismorgan 9y ago
Plenty of comments have arisen while I slept, so rather than answering all over the place, I’ll just post this comment to cover most of it, with a little unsolicited commentary as well.
I’m presuming Overture has come up today because of its mention in our blog post yesterday, https://blog.fastmail.com/2017/12/18/using-the-modern-web-platform/ https://blog.fastmail.com/2017/12/18/using-the-modern-web-pl....
# Concerning the status of Overture:
I’ve been doing much of the maintenance work on Overture in recent months, involving things like updating the code style to use modern techniques (e.g. ES6 modules), and updating the build process to use more standard tools rather than a bunch of cobbled-together scripts and a makefile. (The tools directory contains various scripts of this nature used in the Topicbox and FastMail build processes, things like the C-style preprocessor of ifdef.js, and the localisation-handling functionality of localise.js.)
At this stage, the first phase of improvements are finished in Overture, and steadily progressing in Topicbox; for FastMail they’ll come next year; but as part of this, things like the documentation builder got mostly broken, and I haven’t fixed it in any way yet. (It’s a fair way down my list.)
We’ve been neglecting overturejs.com while making all kinds of changes, because we’re the primary user of Overture. When things settle down again, we’ll make sure things are updated (for our own sakes, if for no one else!). That will entail comparing it against other current libraries more as well.
I’ve been playing around with a few more experimental things, too, such as replacing the get() and set() methods with property descriptors. I have a working prototype, but some aspects of it are moderately complex to make work everywhere. This has been a common pattern with data-binding libraries: they all started with get() and set() methods (provided they’re old enough; some new ones come out now without needing it), but eventually switch to using property descriptors. Or proxies in at least one very recent example (their main benefit is allowing indexing of array-like objects without using a special method, ours being getObjectAt). Browser support and performance are the foundation of any such decisions: property descriptors are ~IE 9+, while proxies are recent-any-browser-except-IE. At FastMail, we currently mostly support IE 8+ and fully support IE 9+, but plan to drop IE ≤ 10 next year which will allow us to depend on property descriptors and the likes in Overture.
Another piece we’re playing with is moving more of the layout out of JavaScript (for historical and browser support reasons, it prefers a fair bit of absolute, precisely calculated positioning) into CSS.
# Concerning Overture versus other libraries like Ember, Vue and React:
Overture is essentially a full-stack framework. It’s thus decidedly heavier than options like Vue and React, but it includes a lot more as well—good support for localisation, dealing with dates, a solid data store with committing, undoing and more, intelligent handling of keyboard shortcuts (e.g. add `shortcut: 'Cmd-g'` to a button view, and ⌘G on Macs and Ctrl+G everywhere else will Just Work™), that kind of thing.
Overture doesn’t use a virtual DOM like React and Vue; it works directly with the DOM. Data dependency tracking is done with precise knowledge of which properties things depend on (its model is inspired by things like SproutCore—people that have worked with such a model will feel right at home).
Altogether, these things mean that Overture is typically harder to work with and more verbose than React or Vue, but so long as you’re sensible, it’s much more efficient.
Oh, and the state of Overture documentation means that unless you can spend a few days with Neil (who wrote it all in the first place) or me to work through things you’re likely to find Overture even more difficult to work with.
At present, the annotation of data dependencies is a little odd, blocking `{ foo () { } }` object shorthand:
const NameView = new Class({
Extends: View,
firstName: null,
lastName: null,
name: function () {
return this.get('firstName') + ' ' + this.get('lastName');
}.property('firstName', 'lastName'),
});
(This is the main thing that blocks shifting to class syntax wholesale, which is one of my experiements—not that it has been clearly and unambiguously determined that class syntax is superior to our current approach.)
One of my experimental pieces (well, a combination of a few experiments) heads in this kind of direction:
class NameView extends View {
firstName: string;
lastName: string;
@property('firstName', 'lastName')
get name (): string {
return `${this.firstName} ${this.lastName}`;
}
}
We’ll see how it all goes.
One last thing: Overture’s data store model is more conducive to offline support than most; combined with JMAP, we’re expecting implementing very robust offline support for FastMail and Topicbox to be fairly straightforward. (By “very robust”, I mean the robustness of a desktop email client, where you never expect anything to go wrong, as distinct from normal web apps which try to add data persistence on top of what they already have, which are hit and miss, mostly miss.)
- nikkwong 9y agoNitpick—based on your statements, I'm curious as to how you can claim manipulating the DOM be faster/more efficient than using a virtual DOM? I was under the impression that the very opposite was true, which is what gave birth to the virtual DOM. In any case, good work.
- chrismorgan 9y agoVDOM is cheaper than a naïve DOM approach, but a lot more expensive than an efficient DOM approach. Let’s use as our context TodoMVC (http://todomvc.com/ http://todomvc.com/), and the action of adding a new item to the list, after having typed something in the box and pressed Enter. The most efficient solution to adding an item is to craft a single new <li> and insert it in the right place into the list. One extremely inefficient DOM approach would be to replace the entire list in the DOM, iterating through all the items and making a new <li> for all of them. This will work OK for a very few items, but once you get lots of items, it makes adding items very slow, because the browser is having to throw away a large number of DOM elements and insert a new bunch of DOM elements, applying their styles and all. The VDOM approach is to have a virtual DOM that can be comparatively cheaply crafted, and rerender the entire list, but using that VDOM rather than the actual slow DOM; then, compare the old rendering and the new rendering, and apply any changes to the DOM—in this case, that will mean that it does finally craft that single new <li>, inserting it in the right place. The VDOM approach is inherently doing more work than is strictly necessary; but it does so and has become popular in recent years because it makes it decidedly easier to write that code, and makes it harder to make mistakes, because you’re only defining how to render a view, rather than how to render a view as well as how to synchronise changes in the data. So long as you’re sensible in what you do, Overture is much faster than anything that uses a VDOM. But you’re responsible for hooking things up so that it knows that, when such-and-such a property changes, it needs to be redrawn in such-and-such a fashion. That can be hooked up in many ways; the most blunt is to say “when any property changes, redraw the entire view,” and the most fine is to say “in a todo item view, when the text of the item changes, replace the contents of its text node (which we stored a reference to when we drew it in the first place)”—and you’re not going to get more efficient than that! But as you can imagine, there’s a lot more scope for making mistakes which lead the view being out of sync with the data. It’s all about tradeoffs. The VDOM approach lets you develop things faster, while the efficient DOM approach produces a result that runs faster and more smoothly. There are good arguments to be made in both directions; but I’m glad that we at FastMail focus on making it fast for the user. The Ember team’s work with Glimmer is an impressive hybrid of the two models; the Why Tracked Properties? section of https://glimmerjs.com/guides/tracked-properties https://glimmerjs.com/guides/tracked-properties is a really good summary of some of the issues around VDOMs, and how Glimmer engineers around them. I like Glimmer.