progressive pride flag

a

i

c

h

a

n

.

m

o

e

Why I Hate JavaScript

It is well known that JS is a shitty programming language. It is a recurring meme how bad it is, and even those who use it do so behind the shielding of one of many frameworks to avoid having to touch it directly. And even so, all our web infrastructure is based upon it.

My hope is that some day WASM gains full access to the DOM, so that it becomes possible to have a web without JS. Below I list the reasons why I cannot wait for this.

Terrible handling of numbers

Let's start with a small joke. Just for once on this site, I will use JS. I know, I know, sue me if you want. But, just to demonstrate live how horrible it is, check this out:

function showSum() {
    const a = parseFloat(document.getElementById("numA").value);
    const b = parseFloat(document.getElementById("numB").value);
    document.getElementById("sumResult").innerText = a + " + " + b + " = " + (a + b);
}                    

Ever tried adding floating points in JS? You'll get nonsense like 0.1 + 0.2 = 0.30000000000000004.

numA

numB

 

Yeah, no shit. If you don't believe me, you can open the Inspector in your browser (F12 or Ctrl+Shift+I) in any tab, go to the Console and directly type 0.1 + 0.2, then press Enter.

Am I being fair? No. This happens to the best of us, check 0.30000000000000004.com.

You can find more funny examples like this here.

Monopoly: the programming language

As of this writing, the only officially sanctioned language for the web is JavaScript. As part of the holy trinity of the HTML / CSS / JS stack, the DOM is only directly exposed to JS. This means that even if a new programming language is developed, it cannot be used on the web without requiring some amount of JS to tunnel through. Given the enormous amount of options we have for coding languages, it is such a shame that it is all centralised to one single option.

Browser vendor dominance

JS is owned by the big vendors, the large corporations. JavaScriptTM is a trademark of Oracle. Fucking brilliant: https://ecma-international.org/technical-committees/tc39/. Oh and don't forget the contacts for the ECMAScript chair group:

  • Chris de Almeida (IBM)
  • Rob Palmer (Bloomberg)
  • Ujjwal Sharma (Igalia)

Just add one more framework

"Just try this other framework bro. Trust me bro, this one is good and easy, and it will be mainstream forever bro trust me."

Let's see, we have: React, Vue.js, Angular, Svelte, SolidJS, Preact, Alpine.js, Lit, Ember.js, Backbone.js, Mithril, Hyperapp, Marko, Stencil, Riot.js, Dojo Toolkit, Inferno, Meteor, Ionic, NativeScript, Onsen UI, Framework7, Weex and I could keep going.

The creator problem

Created by a fascist homophobe. On top of the rest of the issues, there's Brendan Eich, the guy behind JavaScript who has a beautiful history of being a fascist homophobe. Back in 2014, when he was appointed CEO of Mozilla, it came out that he donated to anti-gay marriage campaigns. The backlash was so strong that Mozilla dumped him within two weeks. Instead of fading away, he co-founded Brave Browser, the crypto-pilled adware "privacy" browser.

Addendum: Fuck Brave Browser for this reason too.

Conclusion

JavaScript is everywhere, but that doesn't mean it deserves respect. If I could, I'd never touch it again.

As I mentioned at the beginning, my hope is that support for WASM comes some time in the following years. For the time being, WASM execution is already possible with a JS wrapper to initialize it. Projects like Rust Yew or Rust Macroquad among others are examples I can recommend. A future web without touching JS is possible, and I want it badly.