JS Hot Takes You'll Actually Agree With

After more than 10 years of working with JavaScript, I’m becoming a grumpy old man with some rather strong opinions. Opinions however are like butholes - everybody has one and they usually stink, so don’t take this feature too seriously.

First thing’s first - I still use, and enjoy using jQuery. This one goes hand in hand with my belief that you don’t need a framework like React or Angular for everything, and that the DOM and Vanilla JavaScript are more than enough for more than 50% of the projects out there.

The DOM is fast enough these days, and for some DOM querying I enjoy the support offered by the jQuery slim version.

$(document).on("click", ".register", function () {
  const $this = $(this);

  const $fields = $this.parents("form").find("input");
  $fields.each(function () {
    const $field = $(this);
    validate($field.attr("name"), $field.attr("value"));
  });
});

Don’t get me wrong, frameworks are useful, but working with Vanilla JS or TS is way more fun. Coincidently this is also the direction pushed by some of the big names in the industry as well (‘I now recommend abandoning the libraries, which have grown into bloated platforms, and instead using the DOM and plain JavaScript together’ - Douglas Crockford).

Next, you’ll probably find this really questionable but I’m never using classes in JavaScript… Like never, ever. Let me explain. I get all the benefits of using them, but, in my opinion, there are very few use cases for strong OOP in frontend development. On top of that, the “this” keyword is a mess, and I prefer to simply avoid using it all together. Classes were really hyped up when they were first released in ES6.

class Rectangle extends Shape:

  #height = 0;
  #width = 0;

  constructor(name, height, width) {
    super(name);

    this.#height = height;
    this.#width = width;

  }

  calcArea() {
    return this.#height * this.#width;
  }

  get area() {
    return this.calcArea();
  }
}

Everybody was using them for a while but, in the meantime, the community shifted towards simpler approaches. Also, I dislike the private class members syntax, and I believe it goes against the simplicity JavaScript can achieve.

Following the same idea, I’m also staying away from prototypes, and inheritance in general. This is a way broader topic, but it is enough to say that there are legit reasons for modern languages to completely dump the idea of inheritance all together.

So what do I use instead of classes? Well… object literals to create data structures, and functions for everything else. Yep.. it’s that simple…

This leads me to my next opinion - we really need type safety on the frontend. I feel like this was common sense until a few months back, but apparently TypeScript is really controversial these days. To be fair, I was lucky enough to see some projects where TypeScript is overused, and I get how the dev experience and the resulting codebase can be ruined by some rocket scientists.

Good type systems are non intrusive, and they are simply augmenting the developer experience to provide better quality and results. Things turn sour when TS is used as a hard guard rail for people who don’t really know what they are doing.

Simplicity is yet another topic where I believe we, as a community, are failing. Everything is too damn hard for all the wrong reasons. Most frameworks are bloated, and a lot of libraries introduce unnecessary complexity in your project. Sure, there are scenarios where you’d need to compose async events, but handling a plain fetch call to the server via observables is a bit too much for me.

So I accept it - I’m too dumb to understand the intricacies of modern web architectures that can scale up to teams of hundreds of developers, and at this point I’m too afraid to ask why we need all these in a 10 man dev team building an obscure enterprise app.

We are making things more difficult than they need to be and that we are creating complexity where simple solutions are more than enough.

Finally, here is my most outrageous take - JavaScript is actually an amazing language as long as it is not used by JavaScript developers. It has a really low barrier of entry and, as a consequence, you’ll see some horrific code bases out there. However, the JS ecosystem is really great if you are following a few healthy principles and you are avoiding the JavaScript bad parts.

Let me know in the comments what is your JS hot take, and, until next time, thank you for reading!