Javascript - all js devs just copy+paste anyway

Photo by Pankaj Patel / Unsplash

What's wrong with programming How-Tos today?

opinion Jun 1, 2024

I want to make a JS web app, and the last thing I did related to JS was about a year ago (my A-Level project). I want to use a different, and smaller stack to do things this time round, with a different authentication stack.

So I went around googling (or rather duckduckgoing) things surrounding JWTs and their possible integration into a JS web app, hoping to find some inspiration for program design and code snippets to understand how some libraries are designed.

While you can point out the obvious: RTFM, that only applies once you've decided what library to use, and JS happens to have a metric ton of libraries, from ancient, unusable, deprecated libraries (that still get thousands of downloads from npm), usable but slow libraries (that get hundreds of thousands of downloads), and fast but useless libraries (that get a hundred downloads). Searching for the ideal library of choice for the JS dev of today is reflected in the most recent dev.to/medium blogs where people gush about how their library is "blazing fast". (they never have been, aren't now, and never will be blazing fast, and isn't that a grammatical mistake? - shouldn't it be blazingly fast?), anyway I digress, the fruitless search of last year to find out what is hot is not fun.

First, solve the problem. Then, write the code.
- Something a JS dev has never said

So now I've justified my reading of medium and dev.to blogposts about someone's webapp stack, let's talk about why they are so useless.

black and silver laptop computer beside black computer mouse
I mean look at those notes, if you don't know the difference between an object and array, you should not have a job. Photo by Walling / Unsplash

Firstly, there is very little variation in the db they use - they love mongoDB. Even when their data would be suited for a normal SQL DB of some sort with ZERO noSQL elements, JS devs seem strongly attracted to using the same DB (or frameworks) as everyone else and copy-pasting the webpage's brags about why you should use their bloated software.

So now we are armed (sort of) with a lot of conflicting information about different methods of writing a website that uses a basic JWT token system. Oh wait, there was zero brief about how the technology works or the design of the webapp, and the only things in the blogposts were the code, copy-pasted chunk-by-chunk with a small description that the 50+ line "snippet" above is the login system, and you should marvel at it and use it, with no knowledge of how it works, if it is any good or not, and how it works with other parts of the system.

At this point, just give us the github repo and let us figure it out ourselves (half of these "tutorials" don't even have a link to source on a suitable version control server, and some have the cheek to ask for you to pay for access to the source code)

The best error message is the one that never shows up.
- A key part of JS dev philosophy, never mind bad program design

After hearing those ramblings, you may think - oh dear god we've got a load of web developers who won't know anything, and to an extent that might be true, but how do we solve this?

Make better tutorials.

Simple as that. Really.

  • Tell the reader what version of the library you're using, so people years later don't dig up your jank and use it, when you cobbled a really inefficient program together.
  • Make it clear what libraries you use and why they are better than others in this case (none of that copy-paste nonsense)
  • Explain the program design - what choices you made, and why you made them.
  • GIVE US THE SOURCE CODE - what's the point in a tutorial where you have the code all written out in chunks, when you don't provide the source! Are you really preying on inconvenience to make a quick buck?
Software engineering is not just about writing code. It’s about solving problems and making lives better.
- Something a lot of computer science students need to learn

To conclude, I really hope that people WAKE UP and give us better-quality programming tutorials, because learning something new can be difficult, and the multitude of poorly-constructed blogposts don't help the young developer get into programming, and if you are thinking about making a tutorial, please do a good job <3 thanks.


Quotes from GeeksForGeeks
https://www.geeksforgeeks.org/coding-quotes-for-software-engineers/

Tags

Matthew Townson

Not sure what to put here yet - but I'm sure I'll come up with something soonish.