Replacing JavaScript
On this page, I explore what the possibility of a safer, more declarative alternative to JavaScript. As of 2020, I have made some updates and revisions to tie it a bit less to the year of 2018, but in its essence, it is still the same article that I published originally.
Table of Contents
Abstract and introduction
This article explores the possibility of replacing JavaScript with a safer alternative, built to provide all the user-friendly functionality of JavaScript, but constructed in a way that makes user-hostile practices impossible – and, finally and crucially, designed to be opt-in.
Automatically executing untrusted code from untrusted and unknown sources is a bad idea. Even though dangerous exploits, like the Meltdown and Spectre bugs of 2018, are no direct fault of JavaScript, it is the only front-end language on the web through which such bugs are exploitable. The fact that the vast majority of JavaScript is executed without the user’s knowledge makes the bugs more dangerous than they would otherwise be. Furthermore, JavaScript is increasingly being used in ways that are fundamentally user-hostile – ranging from The Pirate Bay’s non-consensual cryptocurrency mining to advertising companies’ intrusive tracking of users across the web.
Replacing JavaScript may not only make the web safer and more user-friendly; it also represents an opportunity to make front-end development more streamlined. In the company of the two declarative languages HTML and CSS, the imperative, all-purpose JavaScript is the odd one out. This is a chance to design a new standard, inspired by the declarative nature of HTML and CSS, providing the desirable and user-friendly functions of JavaScript, while leaving out the dangerous parts – all through a much more pleasant interface.
I will present one possible solution, in the form of two separate extensions to HTML and CSS respectively.