Hacker News new | ask | show | jobs
by rank0 1778 days ago
Am I the only one who still has a preference for vanilla js?

Maybe it’s just my use cases, but every time I try to use a high level framework like vue or react I am immediately bogged down by unnecessary abstraction and complexity.

Again, I’m no UI dev so please correct me if I’m wrong! I have pretty simple needs for web app UI usually…I’m not trying to build Facebook. Why do I need react/vue/whatever?

7 comments

Have you tried Vue? It’s very different than React because you can just augment your HTML with what you need, it’s not all or nothing. What’s complex and usually overkill for small projects is the "modern" build tool chain, but you can ignore that and just add the <script src> and be done with it (same with React BTW). You can get familiar with AlpineJS which is kind of a minimalist Vue.
That’s for the tips! I’ll take a look at alpineJS. I tried vue a long time ago but would definitely give it another look. My complaints really come from using react and I assumed vue had similar issues
Working without a framework in a team, you can easily have a situation where each developer comes up with novel solutions to various basic and essentially common problems. I've seen it happen that each dev invents their own way of working, their own micro-framework, and the others are mostly unable to work productively in the others' particular styles.

This can of course be countered by pair work, extensive reviews, creating best practices, etc. However, there's a value in adopting something that already comes with those, instead of inventing them from scratch. The correct answer really depends on your situation and team size, I guess.

> vanilla js?

you either:

1. write spagetti

2. make your own abstractions, utilities, structures etc

No comment on 1.

On 2. I know you think your code is so elegant and blows people' mind away or whatever, but trust me, give it to someone else to have a read. They'd probably disagree with you more than they would ever disagree with a framework.

At least the frameworks have tests and documents for their functions

The only UIs I create are pretty simple. For simple interfaces I would much rather deal with spaghetti and homegrown solutions rather than massive overhead and complicated abstractions.

A lot of people just blindly build everything they write with their framework of choice. I argue that react is overkill for 9/10 web apps.

Where do they teach this "people do things because they're dumb, I'm special I see the truth" thing? Let me sign up.
Honestly if you just pay attention to the constantly shifting fads and “best practices” you’d have noticed by now.

Example: object oriented programming was THE WAY the write code a few years ago. Now functional programming is all the rage even though it has existed for decades. In fact, idiomatic react code just recently made the same switch.

I think it’s important to think critically and frankly having a discussion about the efficacy of contemporary design choices is the starting point.

I agree with that, but what you advocade isn't efficacy, "just write good vanilla js" is as useful of a statement as "just write clean code".

In practice I've never seen anyone capable of writing clean vanilla js except for myself.

Of course that's just me jerking off to my own standard. "Vanilla" is an useless approach when it comes to finding a common ground to work in a professional context. It's in-efficacy in that sense.

You don't if your User Interfaces are basic. But for web applications theses frameworks with the ability to quickly define your own web components are incredibly useful. It can still be frustrating sometimes, but when the app gets more complex, doing this without a web framework is probably insanity.

BTW, Vue 3.0 uses Typescript, but you can still programm with plain Javascript. That it what I am doing (I may be part of a minority).

Yeah I never really make crazy interfaces so maybe I’m not the target audience for these frameworks
I'm somewhat in agreement with you. My experience was vanilla js first, then jquery, then angularjs. When I first used angularjs I was annoyed by having to learn about providers and services and factories and an alien templating system. But for all its questionable design decisions, it does provide one very significant benefit: composability.

Jquery had wonderful composability through its plugin system. If I want a tree widget, I just go to the jquery website and find one. (And of course you can do the same thing with vanilla js, but where are you going to go to find a tree widget if you don't want to build one yourself?)

The problem with jquery was that the "glue" was procedural javascript. That made it very difficult to use it from an html editor. With newer frameworks, the templating system is the glue. Where angular/react/vue/others differ is what that glue looks like.

So yeah, you can do all the same stuff with vanilla js that you can do with a framework, but you lose composability of widgets out of the box, and if you have composability, then you've just built a framework.

Someone mentioned Alpine, so I'll mention htmx:

https://htmx.org/

Vanilla js does not exist. You either make a mess or you write your own, undocumented, untested framework.