News for hackers. Stuff that matters.
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by dubcanada on Saturday July 16, 2016 @01:29PM (#12107122)
This is the library vuejs 2 virtual dom is based off of.
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by griffinmichl on Saturday July 16, 2016 @11:47PM (#12108943)
CycleJS recently switch to Snabbdom as well.
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by maattdd on Sunday July 17, 2016 @09:53AM (#12110167)
I really like this library. I've used it to implement a minimal React+Redux toy "framework" when I was spending hours in cranky trains in India.

It turns out in 200 lines of TypeScript I can have a view library which has everything I like from React/Redux/mithril/Elm:

* reactive (hopefully fast, I haven't benchmark anything but I trust snabbdom benchmarks)

* simple API (basically 2 functions) and simple workflow (event -> update -> render)

* hot-reloadable (thanks to Webpack HMR)

* time-travelable (inspirated by Elm Reactor)

* type safe-ish (I wish I could do more here but I think TS is limiting it - a const keyword would be awesome)

Disclaimer: I wrote that during my Asia backpacking so the code is ugly and not even named consistenly but as I'm looking for a job I will try to make it more presentable/usable soon. https://github.com/maattdd/AuberJS for those interested

Random interesting bits:

  function draw() {
    if (m && node) {
        const new_node = ballastView(r,m)
        patch(node,new_node)
        node = new_node
    } else {
        console.error("Unable to draw")
    }
  }
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by nojvek on Sunday July 17, 2016 @11:09AM (#12110402)
What's with the weird Vdom syntax. I'd really like if authors used something that can be used as jsx.

I want to copy my html snippet and only chance the dynamic bits.

There should be portability from other frameworks.

React's API Base is small. If we think react is slow, then there should be a lighter more performant version offering a descent migration path.

Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by btown on Sunday July 17, 2016 @11:48AM (#12110517)
The readme explicitly mentions https://github.com/yelouafi/snabbdom-jsx which allows the use of JSX syntax. While there are trade offs with choosing any virtual DOM library, syntax is not a limiting factor for this one.
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by awinter-py on Saturday July 16, 2016 @02:35PM (#12107377)
Is this unrelated to snabbswitch? Is 'snabb' a word I don't know? I thought it was someone's name.
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by Yaggo on Saturday July 16, 2016 @02:49PM (#12107424)
"Quick" in Swedish, probably the same in Danish as the author is Dane.
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by izym on Saturday July 16, 2016 @03:06PM (#12107491)
Nope, it's "hurtig".
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by vanderZwan on Sunday July 17, 2016 @10:36AM (#12110293)
Wait, "Hurtigruten" just means "fast route"?
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by izym on Tuesday July 19, 2016 @03:09AM (#12120282)
Yep :) Or more precisely "the fast route".
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by Oreb on Saturday July 16, 2016 @02:48PM (#12107421)
"Snabb" means "fast" in Swedish.
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by adamcik on Saturday July 16, 2016 @02:49PM (#12107425)
It's a Swedish word for fast, https://en.wiktionary.org/wiki/snabb
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by gima on Saturday July 16, 2016 @05:41PM (#12107986)
I'm kinda out of the loop with Javascript nowdays, but how would one react to changing data on some input element and receive it in Javascript, integrating elegantly with this library?
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by wrong_variable on Saturday July 16, 2016 @05:56PM (#12108033)
easy, using vanilla.js !

you attach event-handlers to each virtual-dom the same way you would do with a normal-dom.

and those event-handlers can react to change the way you want.

If you mean how to do auto-data binding

oldDom = patch (document.body,newDom)

newDom = h ('div','hello world')

patch (oldDom,newDom)

patch is the function that does the dom diffing.

The amazing thing is most web components do not need auto-diffing.

Sometimes you want fine grained control where you write your own update functions - making imperative changes to the dom based on your needs.

And for other web components where you want more auto-updates you can patch accordingly.

The thing that is amazing is that you can dial it up and down based on your individual needs.

A good example is table components with a lot of data.

You really do not want to incrementally update the table.

So for the divs with the data you patch

but other components that have a lot of interactivity you can simply not patch and do updates by hand.

Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by tobr on Saturday July 16, 2016 @06:06PM (#12108059)
There's an event module built into snabbdom, so you can add a handler for `input` events, change whatever state you want, then create a new vnode and patch the dom. The architecture is very much up to you, snabbdom just updates the dom.
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by wrong_variable on Saturday July 16, 2016 @04:50PM (#12107842)
Its surreal watching snabbdom on HN.

Snabbdom is a gem of a library, it makes microsoft ( angular) and facebook ( react ) look like idiots.

Whoever came up with dom diffing in Facebook is clever, but facebook took that idea and made it into a weird beast, which doesn't integrate well with the rest of the open web ecosystem ( I guess facebook has way too many downstream engineers )

Snabbdom implements the core dom-diffing algorithm and leave the architecturing to you and that is where its power lies.

Snabbdom is really powerful when you mix it with the rest of the small libraries that are written in the UNIX way.

Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by netghost on Saturday July 16, 2016 @10:11PM (#12108746)
So... Angular comes out of Google, Microsoft's key JS contribution is TypeScript.
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by griffinmichl on Saturday July 16, 2016 @11:49PM (#12108946)
RxJS is also from Microsoft and a huge contribution.
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by seliopou on Saturday July 16, 2016 @07:18PM (#12108256)
This, like React, is an inferior reimplementation D3. Whereas React is both slower, less expressive, and less compositional, Snabbdom seems to have settled for just being less expressive and less compositional.
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by continuational on Sunday July 17, 2016 @04:43AM (#12109490)
I'm not very familiar with D3, but the website doesn't really emphasize building reusable components and putting them together into an application.

What is the standard way of doing this in D3?

Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by andrewmcwatters on Saturday July 16, 2016 @01:48PM (#12107196)
I'm thoroughly convinced anyone writing a virtual dom library doesn't know how the DOM, nor a renderer for it, actually works internally.
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by eloff on Saturday July 16, 2016 @04:29PM (#12107770)
There are a number of performance advantages to a virtual DOM. That's why React uses a virtual DOM - unless you're also thoroughly convinced you know more than Facebook's engineers. Google the subject a little.
Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by andrewmcwatters on Thursday July 28, 2016 @03:03PM (#12182371)
But there aren't, there are performance advantages to reusing Nodes due to the specific way that browsers implement render reflow. If those implementations ever change, or you use React on a browser that doesn't suffer from implementation specific perf issues, you've introduced unnecessary complexity.

This is the type of rhetoric that is repeated without personal knowledge of internals or without understanding why the issue exists to begin with. You're basically saying that tree-based structures are inherently expensive.

Read implementing a browser a little. Read specs a little.

Re:Snabbdom – A Simple, Modular, Powerful, and Fast Virtual ... by caub on Saturday July 16, 2016 @02:07PM (#12107290)
examples of what is wrong?