VanillaJs was doing fine earlier. So, what made developers to create frameworks like 'Angular' or 'React'? I mean VanillaJS is so easy to understand compared to these frameworks?
I don't understand at times why this discussion can become so complicated...
The answer is simple. At the end of the day, frameworks are code libraries just like when we do #include <strings.h>, #include <stdio.h>, etc... In C instead of implementing our own super low-level functions. Frameworks save time and make development easier. Plain and simple.
Whether or not they are "better" for you is completely dependent on how many resources (time, money, and developers) to develop a solution. 99% of startups will use these frameworks because they are small and don't have millions of dollars to spend on custom development costs.
I used to slam frameworks and it's true - I personally find "from-scratch" development more fun.
The problem is, what Todd considers fun and what a business actually needs are two very different things. This is why I code my own stuff from scratch on my own time and I use what is required for work on their time. There is no use constantly grinding gears with work over whether or not I personally like developing on a framework.
I do have several qualms with frameworks:
I don't particularly like anything that is used "to make things easy." Why? Because there is always a cost and I've found taking the hard way in life is often more rewarding. A good analogy is a nice premium car wax vs an all-in-one wash and wax. The car will do a lot better and look better if you take the time to apply a premium wash, clay bar it, and then apply a nice high-quality wax. However, people use all-in-ones to save time. Sadly, all-in-one wash and waxes are never as good as individually applied soaps and waxes.
Sometimes the dependencies of frameworks get wayyyyyyy carried away and they create HUGE inefficiencies and security holes in the system. Can you guarantee me that there's no vulnerabilities in your app's 45 dependencies? No you can't because simply auditing all of that code would require so many security engineers that it would be easier to just code your entire application from scratch.
I personally do not enjoy fighting with version issues and dealing with learning how 500 frameworks and their nuances work... I would much rather deal with actual coding logic issues at a more granular level.
Other than that, I have no real issues with frameworks.
Like everything else you can't really say this vs this without giving a proper case, the answers will be of a personal choice and non-specific.
So much trash talk being thrown around here and it all boils down to personal opinions. I doubt you haters have ever dug into a framework and studied the reasons behind it.
You clearly lack of understanding a business mindset too. Fine that there exists some programmer-friendly reasons such as it's not necessary and it could save you staggering 30kb. However try tell this to a customer or non-technical manager:
"I think we should deny using common business standards such as AngularJS, although it's well tested, documented and provides the organization with a broad understanding of coding regulations that makes know-how sharing easy. Instead we should fiddle our own little code library together because that would save us 30kb per new user request."
Not many customers or those managers would really buy in to your arguments.
For small personal projects I'm sure you can argue that not using a framework is a good idea or some not too complex projects. But as the project increases it's important to have community standards and it's a lot more work to start from scratch. It's not only the amount of work that is being done to coding, it's also documentation, standardizations, education and so on. The code part might end up being 30% of the process, where it potentially is around 90%-100% with a framework that already features all this.
Later on when you made a big project and your case has proven it's succes I'm sure you can start working out your own targeted source code.
Let's start with origins of these frameworks. They were created to address an issue of managing large scale JavaScript projects. As the frameworks got optimized, simplified, and improved they proved to be very good for smaller scale projects as well, with ability scale into a large scale application.
Let's take an example of start-up with a need for a simple landing page. It does matter much if you use a framework or not, matter of preference and your proficiency. Another months later, more developers join in, more features introduced like accounts, billing management, acquisition flow, support pages and more.
So, if you started with Vanilla JS, how maintainable is it? And if you were using a framework? There is clean, maintain JavaScript code out there, but it requires developers with similar understanding and styling preferences to keep it so. While a framework is opinionated, has certain ways of achieving things.
That is one of the reasons why frameworks have become a default choice for many. Other reasons, simplicity, wide community support, hype, support from a large organisation, and fun.
Wow. A lot of hatred towards front-end frameworks in this thread!
I'll try and keep it light and to the point.
Using a library like React enables you to onboard new developers a lot easier. If they've done React somewhere else, the likelihood is that they can do React at your workplace too. You also have a large community of developers with a lot of documentation out there. Check out the React and Redux docs. They're pretty well done! There's also some very nice tutorials like the ones that can be found on egghead.io
I should preface my next statements by saying that I predominantly use React at work, so the majority of my answers will be focused towards that.
To respond to some of the points made in this thread:
Or you could call a Vanilla JS fetch() and call it a day, or library like axios or Api. It is really sad that you need to include whole, huge jQuery just to do fetch.
A lot of libraries these days are moving to a modular way of doing things. You don't have to import the entire library. Compilers like Babel will just grab the bits that you need and leave the rest. Lodash is a perfect example of this implementation.
No, it doesn't make DOM/state management easier and more efficient. What is YOUR personal, honest life experience or do you just follow the hype, fake news and articles without doing any research? DOM is NOT slow and you DON'T need any new jargon like "state management" to deal with data, stop believing all that marketing bs online. Can you give me a real use case example and I will give you a simple JS code which will solve the problem.
A lot of anger here, but I'll address it. No, the DOM is not slow, but it's not as feature ready as it could (and arguable should) be. If HTML were capable of doing the things that React can do, people wouldn't use React. Unfortunately, it can't. At the moment.
Once you're up to speed with something like React and Redux, it makes DOM manipulation more predictable. I could of course use HTML attributes to achieve the same result, or even use methods like .innerHTML(), but that can get a bit messy. How does your app know that the change has been made? You could argue that it doesn't NEED to know, and that's true in smaller applications, but in a lot of the work that I do it is very much a necessity. If you know of a way to handle state management in a lighter, faster way than Redux then my dev team and I would love to know.
If JavaScript or HTML is missing something community really needs today, you make change in JavaScript/HTML standard itself
I agree. The problem is that changes for these standards are slow because the impact it could have is vast. A library can implement new functionality in a matter of months. Some decisions can take the W3C and ECMA Committee much longer than that to implement.
they don't understand accessibility or user experience
May I ask why you think that using a JavaScript library would affect accessibility or user experience? Do you mean in the case that they could have JS turned off?
If you are using any framework, you can directly hire a developer who is proficient in same and get started more quickly; which is very unlikely in VanillaJS apps.
So the Bus Factor and Organizational risks can be avoided or reduced.
Other than that, there is no huge advantage.
I use frameworks for throwaway projects.
When I am sure about the longterm, I would rather spend time in deciding what can I afford to have as a library or utility in my app.
I'm sure that you might know what VanillaJs is. I agree that we have to remember the importance of pure javascript and how it works. but, when we kick off a new web project, we don't have enough time to implement all the things we need. Also, if your customer request some modifications later, you have to manage them. Because of these reasons, you have to develop fast as well as considering maintenance of your project. To make this problem simple, MVC / MVVM Javascript frameworks such as Angular, React, Ember, Backbone, etc appear in the industry. They have different features but all of them help us to develop web applications better and faster!
Ignorance, apathy, and wishful thinking -- the majority of people using these garbage off the shelf "frameworks' are generally unqualified to be writing a single line of HTML or CSS, much less JavaScript. They don't understand HTML's purpose, they don't understand accessibility or user experience, and they don't know enough about general programming to even have a valid opinion if any of that crap is worth a flying purple fish!
When people talk about any of this junk as being "easier" or "makes you more productive" I genuinely have ZERO huffing clue what the f* they're talking about!
Though I suspect a lot of that is, well... take what I'm always saying about the mentally enfeebled half-witted trash that is jQuery. EVERYTHING I've ever seen done in jQuery clearly and cleanly falls into one of three categories.
Stuff that would be simpler, clearer, and faster loading without the dumbass framwork.
Stuff that's HTML or CSS' job and has little to no business even having JavaScript involved.
Stuff that has zero blasted business on a website in the first place!
... and that's just talking front end frameworks.
There's a reason I refuse to call my own little JavaScript helper library a "framework". I don't want to change how JavaScript works -- I sure as hell don't want to promote bad practices like jQuery and its ilk do... I just want to plug a few smaller gaps. probably why half my codebase is polyfilling some ECMAScript 5 and 6 stuff for legacy IE
But I'm one of those developers who when I see markup being slopped into a page innerHTML style, or even just building markup with strings instead of leveraging the DOM, I automatically assume I'm dealing with someone who still has their cranium wedged up 1997's rectum.
Why use any framework, library, or plugin? It makes your job easier. It does things you need that you don't want to build it yourself.
$.get() in jQuery and call it a day. At the end of the day, it's not impossible to complete projects without React, but it makes certain tasks easier or more efficient -- like state and DOM management.
I recently started dabbling in video game design on the web using Javascript, and I ended up using a framework called Phaser to make the game. I could have just coded everything I needed myself, like tilemap/sprite interpretation, collision detecting, or complex physics. But I realized by the time I finished coding the necessary classes, I'd have wasted weeks I could've spent coding the game using a pre-existing framework.
I wanted to be a game designer, not guy who designs game frameworks.
None.
People who invented those over-complicated and over-marketed garbage "frameworks" first of all were very bored (you really have a lot of time in Facebook and Google to do random useless stuff and they often forget about how much responsibility they have in front of the global community) and they, probably, just wanted to look smart with a lot of jargon and complexity nobody would understand fast, and they just didn't want to learn JavaScript and Web APIs itself and/or contribute to a Web Standards or Browsers.
If JavaScript or HTML is missing something community really needs today, you make change in JavaScript/HTML standard itself. If browser is "slow", you make it faster, but usually writing normal vanilla JS without frameworks will do so well already.
Now we have a lot of ugly projects, businesses fucked up and looking for Angular 1 developers for example and nobody wants to do this job. Facebook feed works slower and slower. A lot of projects were rewritten from Angular to React and then from React to Vue. At least Vue is like a real product I actually can start consuming after watching 5 min video on main page, but even in that case you do NOT need any framework to build modern web apps. So it's time to move from Vue to the most powerful JavaScript framework in the history.
The best JavaScript framework is JavaScript+Web APIs itself
Matt Strom
Software Engineer, TypeScript ninja
Jason
I had the exact same question after getting frustrated in learning Angular and the irritating inter-component communication that appeared to add needless complexity. Then someone pointed out to me that if I wanted to create a button using pure Javascript only, I would have to do things like:
var btn = document.createElement("BUTTON"); // Create a <button> element btn.innerHTML = "CLICK ME"; // Insert text document.body.appendChild(btn); // Append <button> to <body>Why wouldn't you simply get the HTML from the server? Then you'd have the loading and clunky interface that would feel more like a traditional website rather than a web application.
Front-end frameworks are designed to make your website look and feel like an app, that doesn't require loads per page because a lot of the work is done on the client side. It frequently means creating a "single page application" (SPA), and if you really had to build an SPA using vanilla JS only, that would be a tremendous feat indeed due to all of the ancillary stuff you'd need to build in order to make it work.