Giter Site home page Giter Site logo

dodrio's Introduction

dodrio

dodrio is an experimental virtual DOM library for Rust and WebAssembly. It is a proving ground for a bump allocation-based virtual DOM architecture, that I believe is the best way to take advantage of WebAssembly's strengths in the context of a virtual DOM library.

Warning

I reiterate that dodrio is in a very experimental state. It has not actually been profiled or tuned for performance yet, so while I think the design should yield a very fast virtual DOM library, dodrio is almost certainly not fast right now. Additionally, it is probably riddled with bugs, and is assuredly missing features that are critical for actually building Web applications.

Design

Bump Allocation

Bump allocation is essentially the fastest method of allocating objects. It has constraints, but works particularly well when allocation lifetimes match program phases. And virtual DOMs are very phase oriented.

dodrio maintains three bump allocation arenas:

  1. The newest, most up-to-date virtual DOM. The virtual DOM nodes themselves and any temporary containers needed while creating them are allocated into this arena.
  2. The previous virtual DOM. This reflects the current state of the physical DOM.
  3. The difference between (1) and (2). This is a sequence of DOM mutation operations — colloquially known as a "change list" — which if applied to the physical DOM, will make the physical DOM match (1).

Rendering happens as follows:

  • The application state is rendered into bump allocation arena (1).
  • (1) diffed with (2) and the changes are emitted into (3).
  • JavaScript code applies the change list in (3) to the physical DOM.
  • (1) and (2) are swapped, double-buffering style, and the new (1) has its bump allocation pointer reset, as does (3).
  • Rinse and repeat.

Change List as Stack Machine

The change list that represents the difference between how the physical DOM currently looks, and our ideal virtual DOM state is encoded in a tiny stack machine language. A stack machine works particularly well for applying DOM diffs, a task that is essentially a tree traversal.

Library — Not Framework

dodrio is just a library. (And did I mention it is experimental?!) It is not a full-fledged, complete, batteries-included solution for all frontend Web development. And it never intends to become that either. Its highest ambition is to prove that its bump allocation-based design is a good one, and maaaayyyyyybe become a production-grade virtual DOM library that you could plug into a larger application or toolkit eventually. But it will never be a complete, batteries-included framework.

dodrio's People

Contributors

fitzgen avatar dependabot-support avatar dependabot[bot] avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.