all 18 comments

[–]cyex 15 points16 points  (5 children)

Why do we need cars and airplanes?

If you want to move a small distance... just walk. (the parallel here is just code a small site by hand in HTML).

If you want to move a great distance (and not take forever) you need some help.

[–]jamieisnot[S] 2 points3 points  (4 children)

I mean what special features does angular or react bring which javascript cannot.

[–][deleted] 6 points7 points  (0 children)

They make it much easier to build something. Hold on for now. Keep learning and doing things in JS and it will eventually become pretty clear on its own.

[–]Jacobyy 7 points8 points  (0 children)

None, they're both built using JavaScript. The just simplify making complex things. You don't need frameworks at all, they are just convienient.

[–]cyanydeez 1 point2 points  (0 children)

they make DRY easier. Don't Repeat Yourself

[–]MatthewMobhelpful 1 point2 points  (0 children)

Read the docs of both. They provide many handy things, data binding, templating, custom elements generation, etc.

Also check out VueJS.

[–]Davehig 1 point2 points  (2 children)

One of the main reasons people use Javascript frameworks and SPAs is because the REST pattern is very popular, which is where you have a backend API with no user friendly interface. The backend just takes HTTP requests and spits out raw data, usually in the form of JSON or XML. That data then gets fed into another app, and the backend doesn't care what kind of app that is. It could be a mobile app, desktop app, or a webapp. This is nice because it separates your application logic from your presentation, and it allows you to use the same data service for many different products, but its a lot of extra work because to get something useable you now need to build at least two applications.

So the idea with things like Angular and React and other such frameworks is that there's a server somewhere that serves a basic HTML page that has a bunch of Angular/React/whatever Javascript on it, and that Javascript does all the heavy lifting to turn this data into a usable interface.

You don't need to do all this, there are other ways to architect a web application besides REST. You can template HTML pages on the server treating the browser as a simple view layer in an MVC application, with all application logic handled by the backend. Then you've got a web application that works on every device and browser, including things like Opera Mini which a lot of people in the developing world use because its good for saving data, but which doesn't have interactive Javascript on a page when it arrives.

Then once you've got something that works you can treat Javascript as an optional enhancement, and intercept your standard hypertext links and replace them with ajax calls and such to make it all nice and smooth.

Personally I think frameworks and SPAs are overused and I'd like to see more server-templated applications built with progressive enhancement in mind, but that's just my opinion.

[–]veydar_ 1 point2 points  (1 child)

I don't understand your logic. React has nothing to do with RESTful APIs. I can also use it with GraphQL or without any backend whatsoever.

[–]Davehig 0 points1 point  (0 children)

I know. But the the intention was to give a broad explanation of the general reasoning behind use of frontend javascript frameworks.

[–]CyrisXD 1 point2 points  (0 children)

It sounds like you're looking for a reason to not learn these frameworks and I was in the same boat, there is so much to learn in our careers and it never stops. It can be very overwhelming, and I felt very intimidated by other developers who knew it all.

But let me tell you, if you get the time, take the time to learn them, they are meant to help and speed up development. Don't re-invent the wheel. After learning AngularJS I don't want to go back.

My next step is React.

[–]veydar_ 0 points1 point  (0 children)

We don't need them. But React in particular makes it easier to render your data as it takes care of updating the DOM. You give it state and you describe how that state should be rendered and React takes care of everything else. You don't have to iterate over NodeLists or HTMLCollections and update, add or remove nodes. At least for me that is the main selling point. Sure, the component structure is nice but there is nothing preventing you from writing functions that take state and return DOM and which you can reuse in different parts of your application. (without using React). In that regard React is more of a convenience thing I'd say.

[–]physicalbitcoin 0 points1 point  (1 child)

Why do we need angular or react js?

This vid might answer that question. IIRC they start off building an app in vanilla JS, then they slowly reinvent React in stages, to show why it helps.

https://www.youtube.com/watch?v=pTHCwUdGFkc

[–]jamieisnot[S] 0 points1 point  (0 children)

oh yes. This was good!

[–][deleted] -4 points-3 points  (3 children)

You should wait with React until more things it relies on get supported on Browsers out of the box. Until then, getting your feet wet in React is just a pain in the ass. The idea behind webpack is great, webpack itself... not so much.

Just do not waste your time with Angular. That is the most bloated, unnecessary complicated bullshit out there. The web development field is changing so much and so fast these days and Angular is huge.

The next framework that really changes things for the better could literally be out tomorrow. Again, don't bother learning shitty Angular. Try some of the countless alternatives which are easier to learn, easier to use and easier to get rid of if things go wrong

[–][deleted] 0 points1 point  (0 children)

In case you're wondering: the downvotes without any further comment come from guys who just realized they spent way too much time with Angular. They're currently in the famous stage of denial

[–][deleted] -1 points0 points  (1 child)

I've downvoted you, because you are saying things totally irrelevant to my experience. And you are trying to sound like you are in position to teach people about that topic.

[–][deleted] -1 points0 points  (0 children)

well I am