top | item 44976399

(no title)

hamaluik | 6 months 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.

discuss

order

masklinn|6 months ago

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

And iterators.

loevborg|6 months ago

And "for of" vs "for in" (the latter typically shouldn't be used)

jynelson|6 months ago

I think I disagree that you can have a Rust program that doesn't use all these concepts, at least outside of very basic tutorial material. You will very very quickly run into compiler errors that mention them the second you write your own program.

> The author conveniently left out all of the things needed to understand that JavaScript version, including async/await, promises, modules, string interpolation, [...] not to mention the runtime that is running this, etc.

These are also left out of the Rust version.

Spivak|6 months ago

I mean both languages (and programs) have modules, string interpolation, lambda syntax, and a compiler/interpreter. The only thing they really left out is Promises. And you're iterating over an array so there's no understanding of iterators needed. You can write Python for a long time without ever learning about __iter__. In the example Rust program the iterator is exposed. I think if the Rust version only used the for syntax you could say you don't need to know about iterators.

lmm|6 months ago

Javascript has exceptions (the article even mentions them, but seems to assume that they're somehow intuitive?) whereas Rust doesn't. And the Javascript "first-class function" syntax isn't really objectively simpler than the Rust lambda syntax, which the article seems to assume.

cratermoon|6 months ago

As I read it, the author is making a point about explicit vs implicit knowledge. In the Rust version the compiler will ~yell at you~ politely point out where your code won't work, while the js version will ... just run, but maybe not work?

norswap|6 months ago

Not really, he explicitly makes the point that it's easier to write useful simple programs in Javascript without the extra stuff, whereas in Rust you need to know about a whole lot of things to make the equivalent simple program.