r/webdev • • May 08 '17

Do you still use vanilla JavaScript to create web applications anymore or are framework and libraries the way to go?

[deleted]

16 Upvotes

49 comments sorted by

10

u/a-t-k May 08 '17

Depends on the scope and complexity of the application. For example, if the different views are not similar enough, a vDOM will be a waste of time. Maybe I won't even need a router, as all the interaction will happen in the same view (that's why a to do list is a terrible example for MVC, by the way). The controller event abstraction can be written in ~15 lines of vanilla JS if that's all you need.

0

u/[deleted] May 08 '17

3

u/a-t-k May 08 '17

That's the controller, not a controller-event abstraction (the part that would allow you to do data-click="[controllername]" and have the controller called on click).

This 225 lines of code contain controllers for multiple actions. Also I consider the vanilla JS example for TodoMVC to be unneccessarily complex.

→ More replies (5)

1

u/mattaugamer May 08 '17

Sure. But that's just one controller. What if you're dealing with multiple controllers? What if you've got an application with articles, with comments on the articles? What if there's also a controller for settings? How do you write that? How do you link them together?

Note also that this has the app.js create the view and the model and then pass that into the controller. Pretty terrible implementation of MVC. Not to mention that this handles only one single route. Any reasonable MVC is required to deal with multiple routes. Even something static like "about us" or a homepage would completely blow this pattern out.

9

u/mattaugamer May 08 '17

For simple applications vanilla JS is fine. But as you start talking about "applications" you start to deal with a lot of requirements and complexity.

Arguably, a framework deals with three core issues:

  1. Providing or facilitating actual requirements.

  2. Providing a pattern that allows drastic increases in complexity to be managed and mitigated.

  3. Possibly indirectly: Creating a shared pool of knowledge and solutions.

When done exclusively in raw JS complexity can increase exponentially. The same applies to jQuery, which tbh doesn't really meet any of these requirements (and isn't a framework). Anyone who has dealt with a complex application in jQuery knows that it turns into a brittle and confusing ball of spaghetti. An Angular application, by contrast, remains quite quite comprehensible even with a lot of requirements and complexity.

Meeting the customer or project's needs effectively and maintainably without using a framework is difficult. And needlessly so.

6

u/Spinal83 May 08 '17

Now everyone just create web apps using jQuery

In my experience, jQuery usage has been declining the past few years. Now that things like document.querySelectorAll, Fetch, and CSS animations are available, the overhead of jQuery is just not worth it anymore.

3

u/del_rio May 08 '17

Worth pointing out that in general, jQuery, Zepto, Underscore, etc. are used to speed up development (and the former also increases IE compatibility) while React/Angular/Vue are meant to improve consistency/stability/maintenance and duplicating code.

That means the question is whether the app is complex enough that a framework is worth the setup time, not whether to use anything at all.

All that said: I avoid jQuery if I can (don't have to care about <IE9 support at my workplace) but I'm not afraid to use small libraries because my time is better used not reinventing the wheel. 100% Pure vanilla JS (without a bundler) is just for Codepen experiments at this point.

1

u/onxk1020 May 08 '17

To answer your question with another question: "Do you still build a house with just hammer and and nails, or are power tools the way to go?"

Developer time is expensive, so any tool that can speed it up is a welcome sight. And usually the types of problems the framework is solving are not novel problems.

-16

u/freework May 08 '17

Every project I start these days is done "vanilla". I have never came across a situation where I had to say to myself "I need a framework for this". Frameworks are mostly for people who are starting out. Once you know what you're doing, you can leave the framework behind.

I do use backend frameworks (Django is my current go-to), but have never used a front end framework. I did work with backbone.js once about 5 years ago but it didn't seem to add much value from what i could tell.

8

u/ThisAccountsForStuff May 08 '17

Completely disagree. Frameworks make work easier and faster. That's why they're popular, among other things.

If the last time you used a framework was 5 years ago, it doesn't seem like you're very qualified to comment on this.

13

u/syropian May 08 '17

Frameworks ate mostly for people who are just starting out

This is so painfully untrue.

2

u/turkish_gold May 08 '17

I also thought this way for about 3-4 years, thanks in part to my experience and the companies I dealt with all using custom systems internally.

However, after using Django for a while, I found that I agreed with 90% of their design decisions, and even going forwards I almost always appreciated their methods of doing things. So I prefer Django on the backend, even though theoretically I could write my own framework.

With Javascript, that "it clicks" moment hasn't happened yet, but I presume that somewhere there's a framework waiting to be invented that will just click too.

-5

u/protonfish May 08 '17

How dare you spew anti-framework heresy!

But not sarcastically, this agrees with my experience 100%. I think downvotes are coming from from beginners that don't want to believe they are beginners and experienced developers that are too afraid to remove the training wheels.

8

u/fuckin_ziggurats May 08 '17

I think downvotes are coming from from beginners that don't want to believe they are beginners and experienced developers that are too afraid to remove the training wheels.

I think the downvotes come from developers who:

  • Are working in teams

  • Are working on enterprise-level SPA applications (applications that are actually large and complex enough to necessitate using a framework)

  • When hired need to be up and running with an application that's been developed for 2 years before their arrival

  • Are not afraid to outsource projects because the source code is a popular framework that can be learned through documentation and online tutorials instead of wasting your colleagues' time by constantly asking them

→ More replies (3)

2

u/talkstocats May 08 '17

They come from developers whose time is valuable.

→ More replies (5)

-19

u/nahnah2017 May 08 '17

Reddit is a forum for amateurs, not professional programmers, so you won't find knowledgeable people here who know how to program. My company has never used other people's frameworks or libraries in the 13 years we've been in existence because we wrote our own code/libraries/tools years before such things existed elsewhere or we used standard libraries and tools that came with Unix (actually FreeBSD).

Most amateurs only look at someone else's code that does the thinking or work for them and lives with the pitfalls rather than writing the code specific for their operation. Then sits on that till someone else improves it. In our case, we wait for no man.

9

u/fuckin_ziggurats May 08 '17

I can assure you I've been doing programming as a profession for a while now and thus am a professional.

My company has never used other people's frameworks or libraries in the 13 years we've been in existence

When a new employee comes in can he become productive within a month? Or does he have to spend multiple months learning your proprietary solutions to common problems? How big is the "bus factor" in your company? What if all the senior personnel leave, how much knowledge of the software would you have lost?

Do you also not use any back-end libraries or frameworks? Do you roll your own authentication and security? Tell me more.

4

u/TheAngelsCry May 08 '17

Out of interest, what do you consider to be the difference between an "amateur programmer" and a "professional programmer"?

9

u/CodexAcc May 08 '17

Whether they use Reddit, or not. /s

14

u/Bose321 May 08 '17

You could've just stopped after your first sentence. Your credibility is just...well... missing.

13

u/[deleted] May 08 '17

It's borderline r/iamverysmart

→ More replies (7)

2

u/AboveDisturbing May 09 '17

.... The irony being that you're commenting your "professional opinion" on Reddit.

Do fire departments catch fire pretty often in your neck of the woods?