News for hackers. Stuff that matters.
Re:Svelte – A UI framework that compiles into tiny standalon... by jerf on Wednesday November 30, 2016 @09:00AM (#13070691)
My understanding is that there are two issues with two-way binding that are structural, and will be difficult to fix no matter how you approach it.

First is that if you look at the system as a graph of updates, automatically closing all cycles between variable update and widget means that any additional two-way binding links you add become a cycle, which makes it difficult to implement, model, and debug. If the framework only initially links the variable to the widget or the widget to the variable, the graph is a lot less populated to start with and creating a cycle is much harder.

Second is that the developer ends up wanting more and more complicated transforms over time, and having to implement both directions of them at once is much more difficult than having to implement only one direction, because not only are you writing two transforms instead of one, you also really ought to make sure the transforms are able to be roundtripped without data loss, and also that any invalid states on either side of the transform are handled sanely in some manner. Very few developers think this way; it's one of those places in programming where you really need to approach it with a mathematical state of mind, but it's generally being written by the "I don't see how programming is connected to math" types. (Which is something a two-way binding advocate needs to keep in mind when writing their library; you're not going to get your users to deeply understand the way the library works before they can benefit from it, they're going to want to just dive in and get something useful going.)

These are not necessarily insurmountable problems, but they are fundamental problems to having two-way binding. I think these two things are why it has never really taken off despite the fact I've seen at least half-a-dozen attempts over the years. I can imagine programming language tools that could help with both problems, but as what I'm seeing getting sketched up in my head requires a type system at least as strong as Haskell's to be practically usable without so many holes as to be insignificantly different from what we already have, it's not going to take off anytime soon.

Re:Svelte – A UI framework that compiles into tiny standalon... by nitrogen on Wednesday November 30, 2016 @07:22PM (#13075933)
Two-way binding is being used without popular mention in some industry-specific areas. The area I'm familiar with is control software for audio processing hardware. Lots of different processing platforms allow the creation of control panels with a drag-and-drop UI, and all widgets assigned to the same hardware state variable are also linked to each other, in all directions.

I also implemented my own two-way/omnidirectional data binding system ages ago (before I knew what it would even be called) in Java Swing for another audio UI, and all the challenges you mention are real, but as you say, not insurmountable. Multiple copies of my UI can be controlling the same hardware, and they will all remain in sync without infinite feedback loops, but getting there took lots of work.

Re:Svelte – A UI framework that compiles into tiny standalon... by erydo on Wednesday November 30, 2016 @11:04AM (#13071799)
This is a really helpful way of describing the problem. Concretely describing behavioural coupling in terms of graphs is much less hand-wavy than the normal, "things become tightly coupled and which becomes hard to deal with."
Re:Svelte – A UI framework that compiles into tiny standalon... by Marazan on Wednesday November 30, 2016 @12:21PM (#13072603)
That's the core of it - 2 way data binding creates tight coupling.
Re:Svelte – A UI framework that compiles into tiny standalon... by mpweiher on Wednesday November 30, 2016 @07:58PM (#13076122)
That's a nice description of the problems.

Dataflow constraints with solvers like DeltaBlue solve these problems and allow you to incrementally add additional constraints.

I show how this works for a simple example in my paper "Constraint as Polymorphic Connectors"[1]. I also show that constraints are useful for expressing the high-level architecture of many interactive systems and suggest how to two might be connected.

[1] https://www.hpi.uni-potsdam.de/hirschfeld/publications/media...

Re:Svelte – A UI framework that compiles into tiny standalon... by OldSchoolJohnny on Wednesday November 30, 2016 @04:48PM (#13075025)
"...you also really ought to make sure the transforms are able to be roundtripped without data loss, ..." In my experience this happens inevitably; either you code it right the first time or end users discover it and it comes back as an issue that gets fixed later. There is little math involved in my experience and it's pretty hard to miss this kind of issue unless you're a complete cowboy coder or have never seen it before. Once it bites you in the ass it's not likely to recurr.
Re:Svelte – A UI framework that compiles into tiny standalon... by jerf on Thursday December 01, 2016 @08:56AM (#13079312)
I didn't say it involved math. I said it involved mathematical thinking.

You may have bodged together the relevant concepts by experience. That works perfectly fine. But there is a faster way to learn and teach it... if you can get people past the idea that there's some sort of virtue in bragging (for lack of a better word) about how math has nothing to do with programming and how little they know about the mathematics involved in programming. It's all way easier if you start with the concept of an isomorphism and learn how to compose them from the beginning, rather than having to rewrite the same concepts in your code over and over again without realizing it.

Re:Svelte – A UI framework that compiles into tiny standalon... by tomcam on Wednesday November 30, 2016 @04:23PM (#13074819)
Excellent overview. Definitely helped me understand the issues better.