Hacker News new | ask | show | jobs
by Achshar 2934 days ago
I find myself defending myself a lot these days here. I use vanilla js. Never had any trouble, I literally have no bundle, no dependencies, the amount of code I have to write is basically the same either way, no trouble syncing state with DOM either. Have done so in two moderate projects (40k, 15k). Everyone I meet looks at me like I'm crazy. But in the same breadth say the site feels so smooth and responsive. No shit.

Catch being you he to learn how to write js but that's true for any framework as well. And frameworks have smaller shelf life anyways.

4 comments

I agree you can do that but I feel like frameworks are more about teamwork. I can't imagine having a team of 10 with varying levels of JS experience/passion and telling them all to "just write nice simple vanilla JS that we can all agree is clean and simple" and expect that to happen.
I don't have a ton of experience leading team's using react, angular etc but I assume you are referring to the fact that there are multiple ways of doing things in vanilla js world whereas only one way in react world. That can make things easier for teams but I believe that's a lazy excuse. Choice is never a bad thing and it's literally the job of a tech lead to establish conventions, tell devs what flow to follow. If that turns out to be too difficult then it's not the code or framework's fault. Staying strict about how to do things is a concept that exists irrespective of framework or no framework.
Have strict team conventions and being afforded the time to try an enforce them is great. Agreed. It doesn't always end up working like that in my experience though. Frameworks often have a community that provides some convention guidance. Rails, for example, is huge on this. You can tell a developer "stick to the general Rails way of doing this" and they will often be able to follow that instruction. Is that lazy? Sure, probably. But I also consider it to be a feature of a framework.
Do you have any advice for developing this way? I've found myself too sticking in the VanillaJS camp, but not being able to talk about React seems to dissuade potential employers.
My only advice would be to stay consistent, find patterns and genralize stuff. I do see the irony of making a framework of my own in the process of doing all that. I just embrace that. Everything is exactly how we want it and we know each line that executes on the machine. Makes development a breeze. There is nothing that react can do that vanilla js can't with reasonably same amount of effort. But stay open-minded. What helped me was that I worked with angular first to see how not to do front end (angular.js). I also regularly check out how react, angular, Vue, etc handle the same problems that I have. That usually gives an inspiration.

In the end it's hard to believe how fast JavaScript can be even on smaller devices.

I agree with you and I do most of my stuff in vanilla JS these days, but if I have a complex UI state it can be nice to have a DOM diffing library rather than tracking and editing nodes explicitly.

Mithril is, in my opinion, React done right. The entire framework is contained in four methods. It doesn't have any awkward leaky abstractions like Angular, and it is super light and responsive.

React is a great abstraction, but some projects abuse the virtual DOM concept and you end up with a lot of unnecessary reconciliation (VDOM diffing) going on that slows components down.
Not a snarky comment, but have you had to share this code with other developers? If so, how did you find getting them up to speed without shared conventions?
I have a team of 4 devs working for me. It took them a week to get up to speed with and work with full efficiency. Everyone knows JavaScript. It's nothing new, we're just using it without any added syntax. Everything is familiar.
Curious are you writing newer style javascript with polyfills or just plain old school javascript?
Es2018 all the way. Web workers, classes, Isomorphic code, generators, async await, etc with a splash of Babel Devs have never been happier. Everything just works and online documentation is Rich and plentiful.

Plus as I said, core logic works on both server and client and we have offline support as an added bonus.

No bundle but you use Babel? How does that work?
Babelified code sits in another directory, I hotswap it if I think they are not on a modern browser (IE or older version of mordern browsers). So any normal Joe using chrome or ff or edge will not get a bundle. But if I'm not sure, the backwards compatible version is sent instead. So I think I can claim that there's no bundle since most of my users don't get one.