The Core of Rust

39 zdw 7 8/21/2025, 4:27:22 PM jyn.dev ↗

Comments (7)

khuey · 19m ago
Ironically the "simple" JS program has a bug in it. The documentation for fs.watch is very explicit that the filename in the callback can be null and that you need to check for that. In Rust that fact would be encoded in the type system and the programmer would be forced to handle it, but in JS it's easier to just write bad code.

https://nodejs.org/api/fs.html#filename-argument

Waterluvian · 12m ago
Typescript would require you to check for null before use, which I think makes this a good example of how TS is oftentimes a fairly gentle step up from JS. Or, at least, closer to the correctness of Rust without all the heavy stuff.
quotemstr · 2m ago
But you don't get manual memory management then. No GC, safety, and simplicity: pick any two
Waterluvian · 29s ago
That’s true, two different tools have different pros and cons.
sestep · 15m ago
True, but also the loop syntax is simply incorrect, which would have been caught by running it; so probably a better interpretation is simply that the author didn't spend much time thinking about that JavaScript code because it didn't matter for their point.
hamaluik · 3m ago
This feels like a fairly uncharitable take. The author conveniently left out all of the things needed to understand that JavaScript version, including async/await, promises, modules, string interpolation, lambda syntax, not to mention the runtime that is running this, etc.

You also don’t have to start with a program that invokes 20 concepts at once, every one of those rust concepts can have its own hello world, introducing one concept at a time. Frankly several of them are just fundamental CS concepts.

andrewmcwatters · 4m ago
A smaller Rust just sounds spiritually like Zig to me. Like C++ to C.