The Elm you know
Same syntax, same type system, same friendly errors, same Html library. The upstream TodoMVC compiles without a single change.
The Elm you know
Same syntax, same type system, same friendly errors, same Html library. The upstream TodoMVC compiles without a single change.
No virtual DOM
The compiler sees the shape of every view. The static part becomes a template that is cloned once. Only the values in the holes are checked and written.
JavaScript as people write it now
ES modules, const and arrow functions, async/await. Http is fetch, a Task gets an AbortSignal.
Dead code is gone
Code nobody calls is removed across all modules, packages included. You ship what your program uses.
The counter init writes, and the code dartea makes from its view. This is real compiler output. Only the list of hole paths is shortened.
view : Int -> Html Msgview model = div [] [ button [ onClick Decrement ] [ text "-" ] , text (String.fromInt model) , button [ onClick Increment ] [ text "+" ] ]const $$form0 = { tag: "div", attributes: [], children: [ { tag: "button", attributes: [], children: [{ text: "-" }] }, { hole: 1 }, { tag: "button", attributes: [], children: [{ text: "+" }] }], holes: [/* direct paths to the three dynamic spots */], guards: 1 };
const $$r0 = ($$b, $$put, $$v) => { const model$1 = $$v.a0; $$put($$b, 0, Decrement); if ($$b.deps[0] !== model$1) { $$b.deps[0] = model$1; $$put($$b, 1, $$String.fromInt(model$1)); } $$put($$b, 2, Increment);};
const view = model$1 => ({ TAG: "block", form: $$form0, refresh: $$r0, a0: model$1 });The div and both buttons are built once. On every update the runtime asks one question, is model the same value as last time?, and touches the text node only when it is not. Elm values never change in place, so that question is a single reference check.
Weighted geometric mean of slowdowns on js-framework-benchmark, keyed. Lower is better.
Add the compiler to a project.
npm install --save-dev @dartea/cliStart one.
npx dartea initBuild a page and open it.
npx dartea make src/Main.elm --output index.html