The JavaScript Midlife Crisis
Posted by maroun-baydoun 6 hours ago
Comments
Comment by Klonoar 6 hours ago
Alternatively, there's a pool of JS developers who shouldn't be maintaining critical infrastructure to begin with.
It's not a black box, those codebases are usually open and the only thing holding you or anyone back is learning anything outside of a small pond of JavaScript.
Write non-browser-things in fast languages. It is not a complicated concept - even less so in an era where stuff is getting written for you.
Comment by suplexer 19 minutes ago
The native languages are easier to get decent performance for sure but, braking the entire ecosystem and a generation of future contributors, for what should realistically be single or low double digit percent gains is not worth it.
Comment by devilsdata 5 hours ago
Why are people writing "critical" infrastructure in JS anyway, it is the wrong tool for the job.
Comment by jmull 4 hours ago
In reality, the tools this article is referring to were written in javascript because they could be and it was the best tool for the job (according to the people who matter: the people who did the work).
If someone wants to rewrite them for speed and/or to chase the next shiny language, that's fine with me, but let's not kid ourselves that there was something wrong with using javascript in the first place.
Using the right abstractions (including the right number of abstractions) and the right data structures and algorithms is always going to trump the constants language choice can optimize.
Comment by theowaway213456 38 minutes ago
I was with you until this paragraph, which is straight up incorrect. Language choice absolutely matters if your goal is performance.
The most obvious counterexample is that the TypeScript team pretty much did a direct port from TS to Golang, without significantly rewriting their core algorithms or changing their data structures, and it sped up the TS compiler by 10X, which is an enormous performance improvement that would be silly to dismiss as just a "constant." This is because JS is a bad choice of language for implementing a fast compiler, primarily due to its poor support for multithreading.
Comment by walt_grata 2 hours ago
Comment by yoyohello13 1 hour ago
Like 10 years ago? When you could get a 400k/yr job after a 3 month JS boot camp. The market got flooded with people who don’t care about making good stuff. Now it’s the “AI has commodified intelligence so why learn anything” crowd
Comment by msteffen 2 hours ago
See this post by Mike Pall, author of LuaJIT (which is comparable to or faster than V8 performance-wise, despite being basically a single-developer project), which explains why: https://web.archive.org/web/20180603053407/http://article.gm.... Basically, it’s much easier to add high-quality runtime-trace-aware recompilation to a JIT interpreter, which a non-trace-aware compiled language will often not be able to beat.
Comment by MiroslavPokorny 1 hour ago
The big diff between scripted and compiled languages is the former dispatches by name and the later dispatches by index. No surprises which is faster and which can be compiled in the faster native code.
Comment by suplexer 1 hour ago
But alas, many unskilled programmers use Javascript to make useful things - sometimes beyond their ability. Even a state-of-the-art virtual machine like V8 cannot hope to fix that class of peformance problems.
I will withhold my opinion on the "faster than compiled languages" part though. ;)
Comment by skybrian 1 hour ago
Comment by cisc 3 hours ago
Speed matters. WebAssembly is taking jobs from JavaScript precisely because it's faster.
The calculation engine for Google Sheets became twice as fast with the switch to WebAssembly: https://web.dev/case-studies/google-sheets-wasmgc
The Amazon Prime Video app became twice as fast with less variability in performance when they switched to WebAssembly: https://www.amazon.science/blog/how-prime-video-updates-its-...
Compiling to WebAssembly enables every language to run in the browser. Google used Java and Amazon used Rust.
Comment by nzoschke 5 hours ago
Large parts of the JavaScript application space too.
Language consistency, ergonomics, standard library and performance matters, and JS has major warts here. I bet when these languages are 30+ years old like JS is, the software landscape isn't dominated nearly as much by JS.
These days I intentionally start all projects with as little JS as possible, opting for Go and HTMX instead. Removing the layers of JS inconsistency and build tools makes my and my agents lives better.
More thoughts on my JS-less stack here: https://housecat.com/blog/the-hugs-stack-hypermedia-unix-go-...
Comment by hn_submit 2 hours ago
And yes, I ask myself the question: "Who in his right mind would run JavaScript on the server and even write business logic in it?" Lots of idiots in this world it seems. JavaScript is the reason our text editors need 16GB of RAM to run these days and a simple weather app 1GB.
In the ol' days assembly programmers probably could've written the weather app in a couple of KB (that's a MILLION times less memory people).
Comment by suplexer 1 hour ago
Modern Javascript has many low-level facilities and a great VM. You're conflating the low, average skill of the JS community to what the language is capable of.
Comment by shimman 4 minutes ago
Comment by MiroslavPokorny 1 hour ago
In todays of multi processors, its seems completely backward to adopt a runtime that is limited to a single thread.
Comment by LoganDark 1 hour ago
Comment by hexasquid 41 minutes ago
Comment by spankalee 3 hours ago
You can argue that high-throughput / low-latency dev tools are one of these environments. I'm not so sure. I think a lot of JS tooling is written in slow JS and gets fast with a rewrite to another language largely because of better structure.
Some environments really are tougher though. I started using WebAssembly a lot a year ago and the story for JavaScript and Python is just pretty terrible. And for JS, the things that make it hard to run in Wasm aren't universally good things to have in the language in the first place. The extreme dynamism of JS is something that so much JS tooling tries to limit.
But I think a lot of the language is quite good, and that there are possible variants of JS that are great even. I started one I hope will fit that one day (https://zena-lang.dev) and the first use cases for me are all tooling to try to make sure it's at least good for that: self-hosted compiler, formatter, regex engine, JSON parser, etc. It's quite a bit like JS/TS, but fixes a lot of things and runs forward with features that will take JS many years to get to, if it ever does (ie, pipelines, pattern matching).
I'm hoping that WebAssembly can slowly continue to gain a place on the web so JS can give up its near monopoly there. We'll see!
Comment by suplexer 45 minutes ago
Obviously - using native non-portable language/compiler features - you can reach some worthwhile speedup for certain workloads. But I have yet to see any of these "we rewrote our build system to Rust" type blog posts utilize any them.
It's always the apples-to-oranges marketing style drivel. Just because the some assertion comes from a very (very!) large company or well-known community member doesn't mean it is true.
In all my years of lurking this site, this port mortem is one of the few articles on this topic I trust: https://zaplib.com/docs/blog_post_mortem.html
This argument can also be applied to the separate, startup time performance axis. Though there are more tradeoffs there.
Comment by Kuyawa 2 hours ago
If you need a web app for CRUD, avoid frameworks, typescript, tailwind, nothing, just bare-naked node/html/css/js
If you need games in the browser or stuff where every byte needs optimization go with WASM
A programmer's life has become simpler
Comment by halfcat 1 hour ago
Why include node here?
Comment by MiroslavPokorny 1 hour ago
Comment by jan_m_savage 43 minutes ago
Comment by tannerr_dev 4 hours ago
when i first started learning programming i thought it was super important to pick one language to be really good at and that could do everything but you dont have to pick just one.
i honestly think learning it opened my mind to thinking about programming differently and is probably better in the end
Comment by dbt00 2 hours ago
Comment by hackersnooze1 5 hours ago
Comment by sublinear 6 hours ago
Found it.