←back to thread

452 points birdculture | 2 comments | | HN request time: 1.498s | source
Show context
mdwhatcott ◴[] No.43979711[source]
[flagged]
replies(13): >>43979747 #>>43980029 #>>43980452 #>>43980582 #>>43980897 #>>43981065 #>>43981118 #>>43981329 #>>43981636 #>>43981787 #>>43981862 #>>43982909 #>>43992716 #
melodyogonna ◴[] No.43981636[source]
Rust design decisions are pretty hard to understand sometimes, Mojo is another language with a borrow-checker but it is not nearly as hard to learn as Rust due to making a few decisions. First is value semantics, in Rust people are told to always clone when learning, why isn't this semantics built into the language? It is what you have in most static languages - C, C++, Go, etc. This is the mental model many people come to Rust with.

Secondary, Mojo's lifetime does not tell the compiler when a value is safe to use but when it is safe to delete, in this way the lifetime is not scope based, references will extend the lifetime of the value they reference, but values will be destroyed immediately after their last use. In Mojo you'll never see "value does not live long enough".

Just these two design decisions defines away so many ergonomic issues.

replies(3): >>43982040 #>>43983851 #>>43991263 #
1. dsego ◴[] No.43983851[source]
> but values will be destroyed immediately after their last use

Is this reference counting?

replies(1): >>43985733 #
2. melodyogonna ◴[] No.43985733[source]
Nah, deterministic compiler analysis. Something they call ASAP memory management