4 ms·
Yeah, that sentence surprised me too. While I generally would also consider React more a library than a framework, I think there are arguments to be made that
by hobofan 3y ago
Yeah, that sentence surprised me too.
While I generally would also consider React more a library than a framework, I think there are arguments to be made that it's a framework.
If we go by the common "your code calls a library; a framework calls your code" distinction, then you definitely have to structure your components in a very specific manner so that the React internals can "call your code" to e.g. render one component from it's parent component.
- leetrout 3y agoMy favorite quip (not mine): somethings wrong when express is a "framework" and react is a "library".
- diggan 3y agoOne vital distinction is that even if you define 100 components, nothing will happen unless you call .render from react-dom. Nothing is automatically setup for you. Compare that to Laravel or anything else that is obviously a framework. You write code and put it in a file in the right place, and it gets picked up automatically, most of the time. This makes me still consider React a library, rather than a framework. But then there are tons of frameworks that uses React, nextjs is probably one of the more common ones.
- bcrosby95 3y agoNote that by this definition Spring Boot isn't a framework - you call SpringApplication.run to start it.
- diggan 3y agoForgive my ignorance, I'm not super deep into the Java ecosystem, but is Spring Boot the same as just "Spring"? Or what is the difference precisely?
- bcrosby95 3y agoSpring Boot is a layer on top of Spring that makes it easier to use.
- diggan 3y agoSounds to me like Spring Boot is a library to be used with the framework Spring in that case, as far as I can tell.
- deleted 3y ago[deleted]
- bcrosby95 3y agoIt's more than just a library, there are "starters" that they've developed that will pull in everything you need for certain stuff (such as web, or database, etc), and it will auto-find and configure everything for you. Furthermore, you can hand configure Spring. If anything, the framework here is the Java servlet container, not Spring. Spring just usually lives within that context. And at this point I'm not sure if that's completely true either. It's common to embed the servlet container - this is how Spring Boot works. I assume you can do that with raw Spring considering that's what Boot does, but I never bothered trying because I would just use Spring Boot at that point.
- Sankozi 3y agoSome people jokingly call Spring Boot a framework to manage Spring - another framework. If having a entrypoint function/object is enough to call something a library then both Spring Boot and Spring are just libraries. But in reality they are not - so entrypoint rule is not correct.
- hobofan 3y agoThat's as arbitrary of a distinction as many other ones you could try to draw. With Rails nothing will happen unless you call `run Rails.application` or run the `rails server` command. That doesn't make it a library.
- diggan 3y agoObviously, you need to start the application somehow. But when you initially setup a rails project, do you write the code that bootstraps the application? Or do you just run `rails server` and the application figures out what to load, and starts the application for you?
- hobofan 3y agoBut when you initially setup a React project, do you write the code that bootstraps the application? Or do you just run (`pnpm create vite` +) `pnpm run dev` and the application figures out what to load, and starts the application for you? We can do this all day...
- diggan 3y agoWhen you initially setup a React project, you run `npm install --save react react-dom` or similar, create a HTML file that loads a JS file that you also need to write, that includes a call to `ReactDOM.render` somewhere. That's it, no more, no less. Contrast that with rails where you run `rails new $app`, then `rails server` and everything is made for you. Not sure why you're mentioning vite here, we're explicitly talking about React and Rails, not wrappers or tooling around them.
- hobofan 3y ago`pnpm create vite` is one of the modern alternatives of `create-react-app`, which isn't maintained anymore. It fills the exact same role as `rails new $app` does of scaffolding a project, which apparently is a hallmark of a framework. So where does "wrappers or tooling around them" start and end? Why shouldn't we count `create-react-app` (which was maintained by the React team), but count `rails new`? All this just goes to show that the "you have to call the entrypoint" distinction you are trying to declare is just as fuzzy as most other library vs. framework definitions. There is next to no difference in hand-writing an essentially fixed entrypoint of React.render vs. getting that file autogenerated vs. calling a "binary" (that is also just an interpreted script that contains the same entrypoint).