4 ms·
What IS the glimmer VM? I didn't see any links on the page. Is this it? https://github.com/glimmerjs/glimmer-vm https://github.com/glimmerjs/glimmer-vm It i
by chubot 10y ago
What IS the glimmer VM? I didn't see any links on the page. Is this it?
https://github.com/glimmerjs/glimmer-vm https://github.com/glimmerjs/glimmer-vm
It is JavaScript code or native code?
- steveklabnik 10y agoThat is it. It's TypeScript.
- chubot 10y agoOK, my confusion is why it's called a "VM": Glimmer is a flexible, low-level rendering pipeline for building a "live" DOM from Handlebars templates that can subsequently be updated cheaply when data changes. This sounds like something written on top of a JavaScript VM, not a VM itself. Is it implemented with VM-like techniques? What does the instruction set look like?
- whichdan 10y agohttps://github.com/glimmerjs/glimmer-vm/tree/master/packages/%40glimmer https://github.com/glimmerjs/glimmer-vm/tree/master/packages...
- steveklabnik 10y ago> This sounds like something written on top of a JavaScript VM, not a VM itself. You can write VMs in languages that are implemented with a VM. > Is it implemented with VM-like techniques? More than that, it is literally a virtual machine. > What does the instruction set look like? IIRC, it's a stack-based VM. Here's the opcodes, I believe: https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/wire-format/lib/opcodes.ts https://github.com/glimmerjs/glimmer-vm/blob/master/packages... (I have mostly a high-level understanding on this, after talking to lots of people and watching presentations; I don't hack on Glimmer myself.)
- abecedarius 10y agoThanks. Up to this point I too was scratching my head wondering what the fuss was about -- if this was a JavaScript-in-Typescript VM, or what. It's a custom virtual machine for a domain-specific language for filling templates, right?
- steveklabnik 10y agoYes, this is a good succinct way to put it. It compiles handlebars templates to its VM, and then as the machine executes, it updates the DOM appropriately. You can think of the Glimmer VM as a VM interface to the DOM rather than the direct DOM interface, and handlebars templates as programs that compile to that VM.
- eric_the_read 10y agoI like that one of the opcodes is "FixThisBeforeWeMerge". Looking this over, I can see why my initial reaction of "why aren't you using WebAssembly?" was facile; this really is a VM optimized for templating languages. I'm reminded of the Bad Old Days when I was a ClearCase admin; we ended up building what my boss at the time called a Revision Control VM on top of it, so that our developers never really learned ClearCase per se; instead, they learned our system that happened to use CC under the hood. Since then, I've treated the term "VM" with a looser interpretation than usual; clearly, I should have applied that here (though it is, strictly speaking, a VM in the classical sense as well).
- chubot 10y agoOK so I guess the VM outputs a virtual DOM tree from a handlebars template, rather than text? I don't really see why you can't do that with a simple tree interpreter, but sure why not. I've implemented template languages in multiple languages. I've also thought of compiling different languages to the same VM with string instructions (IIRC the old Cheetah template language compiles to Python bytecode). I sort of see where this is going but the docs weren't particularly clear to me. If anything it sounds like there are a lot of other components besides the VM, which weren't really described in the blog post, and I couldn't find any links.
- bluegene 10y agoGlimmer intro video, https://youtu.be/i2rwIApjz-4?t=175 https://youtu.be/i2rwIApjz-4?t=175 might have some answer for you.
- gavinjoyce 10y agoHere's a playlist of technical videos which explore the Glimmer VM internals: https://www.youtube.com/playlist?list=PLpAr6J-75N24C-XQgIUDMtcgaurV4GDTZ https://www.youtube.com/playlist?list=PLpAr6J-75N24C-XQgIUDM...