DEV Community

George Jempty
George Jempty

Posted on

Why ReactJS is a Framework, not a Library

If ReactJS lets you program declaratively, it must be a framework

I have read one too many times that React "is a library", presumably by those who have an agenda to make it sound simpler than alternatives, or those who are merely parroting. But we also always read that React lets you create web UI's "declaratively". As we will see, these two statements are at odds with one another.

In my immediately previous post, "Accidentally Declarative" (which, I'm honored to say, made it "above the fold" as a most popular dev.to post last week), I noted that on Wikipedia it is posited that in declarative programming: "the programmer merely declares properties of the desired result, but not how to compute it". And I argued that implicit in this is the notion that another system must do the computation.

As to the difference between a library and a framework, I think this is very well stated in a couple of answers to a particular Stackoverflow question. The first of these answers states that "A library is a module that you call from your code, and a framework is a module which calls your code.".

The second answer I like is even more succinct, but I like one of the comments in particular: "In Soviet Russia, framework calls you" :) The logical conclusion then is, that if when you write declarative code another system/framework calls your code, and if React lets you create UI's declaratively, then React is a framework, not a library -- no matter what anybody would have you think, or repeats without themselves thinking.

Top comments (1)

Collapse
 
niorad profile image
Antonio Radovcic

Would you say Slick-Carousel is also a framework? You declare the Result you need, like

$(element).slick({
 animated: true,
 duration: 200,
 loop: true,..
});

Isn't React also "just" calling React.createClass with a bunch of methods?

I really never thought about React being one or the other, there's complex libraries and simple frameworks.