Hacker News new | ask | show | jobs
by oakaz 4789 days ago
Thanks for reply. The power of this concept is simplicity. It's based on a very simple API: publish/subscribe.

Anything that has these methods can be easily binded to DOM and can easily interact with data structures like new-list and new-object.

Frameworks are monopolistic. They don't let you take advantage of the open source at all. You can't replace the a core mechanism or data structure of a framework but if you use something built from small independent modules, you'll be able to optimize more, create more, reuse more, extend more, fork more.

This simplicity, the two methods interface, lets you create your own data structures that can be binded to new-reactive. Since your all dependency is publish/subscribe methods, you can easily replace each part of your code if you need to move on to another direction. But frameworks will force you to use or depend on only their own abstractions. That can be very expensive and dangerous your monopolistic framework gets out of fashion or starts implementing ideas that suck.

1 comments

Ok, you're just talking about plug and play. That's a separate topic about micro frameworks. What I'm asking about is a real world example where reactive programming solves a problem better than traditional techniques.

As an example, look at Promises. At first glance it seems like overkill to structure your code to return objects that get resolved later. But when you use examples of deeply nested asynchronous callback functions and how they get cleaned up with Promises, it's obvious why they are better.

What is an equivalent real-world problem where reactive programming is better?

reactive programming is nothing except abstracting more. think about how would you define a variable and bind it to HTML. Here is my reactive way;

  JAVASCRIPT

      today = attr("Thursday")

      bind('.today', today)

      after('1s', function(){
 
        attr('Friday')

      })

  HTML

      <div class="today"></div>
      

  OUTPUT

      <div class="today">Thursday</div>

  AFTER 1S

      <div class="today">Friday</div>
This is the simplicity level I would like to achieve with minimalistic and independent modules.