Hello,
I’m working on an article comparing the latest rendering engines of React, Angular and Ember. Therefore I’m trying to understand the internals of the Glimmer VM better. I came up with some questions on advanced features, which were discussed in its early days. It seems as they haven’t landed yet. Was wondering about their current state.
I watched two talks about it from 2017: A talk by Tom Dale at ReactConf 2017 and a similar one by Yehuda Katz at Ember San Franciso meetup in the same year. Both mentioning these advanced features of the Glimmer VM, which doesn’t seem to be used in Ember yet:
- Sending templates as byte code over the wire. This was claimed to provide two benefits: 1. Avoid costs of parsing JavaScript or JSON at all and 2. have a smaller bundle size.
- String interning. It’s only mentioned in Tom’s talk if I recall correctly. It was claimed to reduce the bundle size for apps with a lot of templates as a shared dictionary of static strings is used for them.
- Writing parts of the Glimmer VM in WebAssembly. Yehuda said that this will help to prevent performance pitfalls, which are easy to make when writing JavaScript.
Here is a compiled template with latest Ember:
Ember.HTMLBars.template(
/*
<p>Count: {{count}}</p>
<button {{on "click" this.incrementCount}}>increment count</button>
*/
{
id: "7uhCW8v2",
block:
'{"symbols":[],"statements":[[10,"p"],[12],[2,"Count: "],[1,[34,0]],[13],[2,"\\n"],[11,"button"],[4,[38,1],["click",[32,0,["incrementCount"]]],null],[12],[2,"increment count"],[13]],"hasEval":false,"upvars":["count","on"]}',
meta: { moduleName: "ember-hello-world/components/hello-world.hbs" },
}
);
This template shows that bytecode is not used as wire format. The template meta-data is encoded as JSON in the block
property. That JSON is lazy parsed when needed.
Also string interning doesn’t seem to be used. There isn’t even a separation between instructions and static strings in current wire format.
A new ember app also doesn’t use any WebAssembly as far as I can tell.
What is the current state of these three features? Are they still planned? Or did you figgured out that they come with trade-offs which aren’t acceptable? Maybe they are even useable through a feature flag? Or in latest Glimmer standalone library?
Didn’t want to make any pressure. Totally understand that it’s complex to land such stuff into an existing ecosystem. Just wondering if I should discuss these features as something still planned or better not mention in the article.
Best Jeldrik