let me start with the hugest advantage JavaScript has over literally every single language in the world: you already have it on your computer.
JavaScript being available on everyone’s computers makes it a super-accessible programming language to learn: all you have to do is open your web browser and go to the console in its Developer Tools.
moreso, if you are building a website and would like to embed a language interpreter (like me,) you already have JavaScript for that.
yes, you could in theory embed Lua, but for most cases JavaScript is Already There and there is nothing wrong with it. apart from the fact that it’s kind of hard to sandbox.
this is precisely why tairu is written in JavaScript - not because it’s a particularly good language for the task, I think for game development C++ is a lot better - but I really wanted to build a blog post environment with interactive code examples, and JavaScript is the only way to do that without pulling in any dependencies.
the 2nd best part of JavaScript is that if the author wants it (and you should!) it’s extremely easy to inspect
.js
files and learn from them.if you’re an independent blogger and you believe that having a more open Web is something you’d like, you should also avoid minifying your
.js
files.gzip or brotli compression can already do wonders with compressing your text files - according to PageSpeed Insights, I could shave off around 48 KiB of transferred CSS and JS in the treehouse just by compressing it.
when you do get to the language… it’s really not as bad as many people paint it
the biggest quirks of JavaScript lie around the type system.
if you really hate the type system, there’s always TypeScript. I choose not to use it in the treehouse codebase, because I don’t like additional build steps slowing down generation.
the TypeScript compiler is slow enough to require me to perform incremental compilation, which complicates builds a lot.
arguably there’s swc but that still requires parsing and reemitting the JS
-
parsing is slow.
one thing I tried was to automatically make all links in the generated HTML have something akin to a
?cache=
query that would make the server inject a “cache forever” policy, but it extended build times pretty much twofold.
also I was using html5ever which uses hash maps everywhere and produces non-deterministic HTML files
-
parsing is slow.
one thing I tried was to automatically make all links in the generated HTML have something akin to a