r/programming • • Sep 25 '20

Modern JavaScript Explained For Dinosaurs

https://medium.com/the-node-js-collection/modern-javascript-explained-for-dinosaurs-f695e9747b70
749 Upvotes

167 comments sorted by

View all comments

20

u/[deleted] Sep 25 '20

And this is how we used to make websites with JavaScript libraries! The good thing was that it was easy enough to understand. The bad thing was that it was annoying to find and download new versions of libraries every time they would update.

So I'm a dinosaur, and I like it like that. I do not want my JS (or any other) libraries updating by themselves, with potentially fatal consequences for my applications. I prefer to test any updates out myself before letting them loose in the wild.
Then agian, maybe I've just not understood how it works. Like I said, I'm a dinosaur. Rarw.

30

u/JW_00000 Sep 25 '20

Using npm, libraries don't update by themselves, you still specify a version or version range in the package.json file. I think what the author wants to say here is that with npm, updating a library is a matter of increasing this version number, running npm install, and testing whether everything still works, instead of having to manually go to the library's website to check for new versions and download them.

5

u/[deleted] Sep 25 '20

Ah, ok - thanks.

5

u/StillDeletingSpaces Sep 25 '20

They only update when told. You can specify which versions are acceptable in the package.json.

In addition, its easy for tooling to see if there's a problematic version being used. Not just in the "an update is available way", but in a more sensible "there is a security vulnerability for this version."

0

u/[deleted] Sep 25 '20

Yeah, ta. I'm also something of a dinosaur too in that I prefer to avoid "libraries" at all, where possible. I like vanilla JS. I like working out how to do things myself, w/o relying on some "black box" to do it for me. Obviously this isn't a good approach in some scenarios (where speed is important, for example) but that doesn't really affect me on the sort of projects I work on (mainly SME's and charities' websites). Besides, I'll retire in the not too distant future, and getting to the point where learning new tricks isn't really worth the effort any more, nor excite me as much as it used to. (Nor am I worried about leaving horrible legacy software for my successors to deal with; they'll just re-build from scratch (as I did) - by far the easiest approach on small/medium projects!)

5

u/[deleted] Sep 25 '20

Fellow dinosaur here.

Many of the libraries are huge time savers. Like in the article in mentions moment.js, which is a library for working with dates and times. If you have to do anything beyond super simple date/time stuff, using a library means you can do it in one or two lines of readable code instead of mess of native JS code.

0

u/[deleted] Sep 25 '20 edited Sep 25 '20

Yes, I'm not totally averse to them - of course they can be useful, but I do prefer not to use them if and where I can.