What are the exact demerits of two way data binding?

View other answers to this thread
Tomislav Pesut's photo

Basically what Mayank said. I have nothing more to add on that level just want to give a concrete example with Angular. Angular became super-popular exactly because of it's two-way binding. However it brings a lot of performance problems.

When you think about it for a bit. How can a framework know that a value has changed? Really it boils down to 2 ways. You can do it through a setter, which is already half-way towards unidirectional data flow...or you can do dirty checking. Dirty checking means constant checking if the value has changed at any point when it could have changed. That's a ton of work all the time and most of it is pointless.

This is why Angular apps start becoming sluggish when you hit ~ 2000 bindings on a page. This sounds like a huge number but it doesn't take much to get there. Almost any medium sized app will easily hit 2000.