Thirty years in, the JavaScript ecosystem would like to see other languages. They're younger, leaner and faster. What could possibly go wrong?

56 points•maroun-baydoun•8 days ago•75 comments•

75 comments

Klonoar8 days ago
> Rewrite a bundler in Rust and you haven't only made it faster. You've also shrunk the pool of JavaScript developers who can maintain it. The new tool still looks like a duck and quacks like a duck, but it's a different beast altogether. Its internals retreat behind a black box that fewer people hold the keys to. The source may still be open, but the door to contributions is closing.

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.

devilsdata8 days ago
Absolutely agree. If a JS developer doesn't know Rust, Go, Zig, or something, then they probably aren't going to do a good job at maintaining critical infrastructure, even if it were written in JS.

Why are people writing "critical" infrastructure in JS anyway, it is the wrong tool for the job.

jmull8 days ago
Why are people writing critical infrastructure in [any language]?

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.

walt_grata8 days ago
When did the love of learning disappear from this field? I remember when everyone i talked to was learning something new just to better themselves?
yoyohello138 days ago
> When did the love of learning disappear from this field?

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

suplexer8 days ago
Or just write faster JS using it's lower-level language features. Nothing about whatever collection of build tools the JS ecosystem uses "requires" rust/zig/c++/go for performance. It's a closed text transform problem.

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.

Klonoar8 days ago
> Or just write faster JS using it's lower-level language features.

You are simply ignoring the history of these tools and why people have begun to reach for the languages in question.

whakim8 days ago
I think there's a huge spectrum between "pokes around in source code occasionally" and "maintains critical infrastructure." Learning to read and understand the open source software that powers a lot of the toolchain is a big part of the development of a lot of engineers, and said toolchain mostly not being written in a language you're familiar with is a barrier to that (not an insurmountable barrier, but still a barrier, to be clear).

I agree with you that the juice is worth the squeeze here, but I don't think it's right to pretend that there's absolutely zero cost in terms of the learning pathway for the next generation of open source contributors and maintainers.

pjmlp8 days ago
I had to laugh about the Tiger Beetle history when hearing about it on one of my podcast feeds.

Although it is now famously one of the Zig written production deployments, the founders thought JavaScript would be a great option to write a database server, like really?!?

pan698 days ago
> In the month of July 2020, we developed a prototype of TigerBeetle in Node as a performance sketch to measure the basic components of the design (batching, TCP protocol, cryptographic checksums everywhere, fsync journalling, in-memory business logic and hash table operations).

https://github.com/tigerbeetle/tigerbeetle-history-archive/b...

cisc8 days ago
> I start wondering what we're supposed to do with all those precious milliseconds it just handed us back

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.

suplexer7 days ago
1) Google Sheets use case

Long story short they are comparing the performance of server-side Java to client-side JS (Java transpiled through GWT/J2CL). So something like: Java -> Hotspot -> native vs Java -> GWT/J2CL -> JS -> V8 (in Chrome) -> native

Apples to oranges.

They then used J2CL (I presume, not clear from the article) to port Java to Wasm and eventually got around 66% of the server-side Java performance. The Wasm performance story also was nowhere near straightforward - hence the immense efforts spent on optimizing WasmGC and validating the transpiler output.

The root of the problem is likely the GWT/J2CL transpiler output. There shouldn't be that much of a peformance drop off between to high-level languages if you're transpiling with speed in mind. I bet there are probably lots of expense runtime checks in the generated output, among others things.

2) Amazon Prime Video use case

Blog seems mostly fine on the surface. But my complaints are always the claims about the limits of performance one could get from a JS-based system - especially in environments where you can call out into native audio/visual libraries.

"In those experiments, code written in Rust and compiled to Wasm was 10 to 25 times as fast as JavaScript."

What does the JS versus Rust code look like? Are they using the similar libraries/graphics apis/techniques? Did they exhaust every possible low-level tool in JS (Worker Threads, SharedMemory, etc). I feel there are a also rainbow of optimization opportunities available if one controls V8 and the underlying C++ stack.

Not that their eventual Wasm architecture is bad per se, it's just layering Rust+JS -> Wasm/C++ is much more complex than simply JS -> C++ back and forth.

As a side note, it very annoying that SIMD was taken out of development for JS. Big TC39 wants wants JS to fail.

https://github.com/tc39/ecmascript_simd

cisc7 days ago
In both cases the WebAssembly result is twice as fast as the JavaScript version.

How do you account for that?

suplexer8 days ago
It's late for me. I've commented plenty on this thread but I'll revisit this particular comment tomorrow with my assessment of these two blog posts.

Just skimming the Google Sheets wasm one, looks like pure technical debt chaos so I'm already plenty suspicious.

Suffice it to say that all these pseudo-technical but actually marketing blog posts should be taken with a truckload of salt. Apples-to-oranges unless proven otherwise.

cisc8 days ago
Here's a presentation on the Amazon Prime Video stuff. The talk's about 50 minutes long: https://www.infoq.com/presentations/prime-video-rust/
msteffen8 days ago
Heterodox argument: a big part of the reason JavaScript has been so successful is that interpreted languages actually can be extremely fast—competitive with, and in many cases, faster than compiled languages, with V8 arguably the fastest interpreter in existence.

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.

MiroslavPokorny8 days ago
Javascript only becomes fast because most of the CPU time is spent in native code rather than actual compiled or interpreted javascript.

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.

jauntywundrkind8 days ago
JavaScript only becomes fast because it continually is making tradeoffs to decide what level of work to put into running any given bit of code. For a while this was three or four different targets on V8 (which I think maybe is down to just 2 now again).

Compiled vs interpretted is viewing this through the compiled language lens. I think the interesting part is that some runtimes are dynamically deciding how to run the code. The contrast versus those folks who decide and bake every single decision in ahead of time, where the only thing that happens is totally pre-scripted, is strong.

Stop Writing Dead Programs is such a lovely talk that hopefully can shake a couple of these sleepers awake, get us to see how absurd compiled code really is. And is quite fun and funnily said. https://news.ycombinator.com/item?id=33270235

skybrian8 days ago
It's mostly fast enough for most apps and that definitely helps. It's not as consistently fast as some languages that don't rely on an JIT. That matters more for tooling than your average website.
suplexer8 days ago
There's no need to even contextualize your argument, it is the reality. The whole point of spending such heroic efforts on a fast VM implementation is so that even faster peformance becomes a niche use cases.

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. ;)

hn_submit8 days ago
JavaScript is an abomination that never should've been left alive.

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).

LoganDark8 days ago
From experience... It was really amazing to share TypeScript protocol definitions between the server and client. The client side would get all the autocomplete and intellisense and typed goodies, the server side used a compiler extension called typescript-is to validate the request bodies in one go, using the types as the source of truth. I loved not having to duplicate the validation logic in a separate way and manually maintain it to be consistent with the types. To this day I think that was the most natural way I've ever written a server-client pair and to this day nothing's compared, even supposedly cross-language things like protobuf. Ugh, TypeScript is so good at what it does. Sometimes I hate the lack of nominal types, but it really is up there with Rust as one of my favorite languages.
suplexer8 days ago
A programmer that can write a small efficient weather app in assembly can also easily do so in JS. Especially writing it in a c-style imperative way.

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.

shimman8 days ago
People say this yet still are served some of the worse performing apps from supposedly the "best" corporations in the industry.
hn_submit8 days ago
We shouldn't be using scripting languages for anything but animating something on a web page. The idea behind NodeJS is idiotic. We shouldn't allow low-skilled programmers to write server software.

If A.I. code generators put a stop to this then it will have served its purpose IMHO.

MiroslavPokorny8 days ago
Exactly!

In todays of multi processors, its seems completely backward to adopt a runtime that is limited to a single thread.

suplexer8 days ago
JS has Web Workers in the browser and Worker Threads module in nodejs for parallelism. Most apps don't need to them to be fast, but many slow apps would be less slow if Workers were used more often.
agos7 days ago
come on, you can do better than hurl insults at fellow programmers
nzoschke8 days ago
> Rust, Go and Zig are taking over increasingly large parts of the JavaScript toolchain...

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-...

Read the full thread on Hacker News →

Related stories