5 comments

  • hingler3638 minutes ago
    I can see how multiple mutable references is fine in a single-threaded context, but surely this would cause UB in the multi-thread context?
    • Jweb_Guru15 minutes ago
      Given their &quot;shape stability&quot; design, not necessarily. The three ways that multithreaded access can cause UB are:<p>* changing the type of the underlying memory (e.g. because it&#x27;s part of an enum variant and you changed the tag, or because you changed the length of a vector) * data races (can be defined away by making [effectively] every access Relaxed, as Java does * use after free (resolved here by reference counting)<p>In Rust, any type specified like this (all accesses are Relaxed, &quot;shape stable&quot;, and reference counted) can <i>already</i> be used in safe code using &amp; references. In theory. But the first property (forcing all accesses to be Relaxed) is very annoying to achieve for arbitrary user data types--even if those types are Copy or other kinds of plain old data--which is a problem e.g. for specifying stuff like sequence locking. The example they give here with bare unions is also very annoying to use in Rust even though this mode of use is safe, because the type system doesn&#x27;t track which variant is active. So I definitely think there&#x27;s room to innovate ergonomically here.<p>(It does seem from the text like this is intended for a single-threaded context, where I think the arguments against Cell are a little less persuasive, but it&#x27;s still true that it&#x27;s very awkward to try to figure out how to safely project a Cell down to the exact fields you need to mutate, even though something like LambdaRust will tell you it&#x27;s safe to do so).<p>By accepting semantics like this you are, of course, opting out of a lot of potential optimizations around both shared and unique accesses, but you are already doing this in most langauges anyway, so if you&#x27;re willing to eat the performance cost this can be quite acceptable. The bigger problem (briefly noted in the post) is that the kind of recursive analysis they&#x27;re proposing doesn&#x27;t necessarily compose well. Rust explicitly opted out of most types of analysis that can&#x27;t be efficiently summarized at the function signature level to improve compilation speed. Historically, not being able to efficiently summarize functions that do this kind of stuff has been a big thing that killed attempts to automatically add borrow checking like facilities onto existing C++ code, too. But maybe a language designed for it from the ground up will avoid this problem.
    • reinitctxoffset23 minutes ago
      Not if you define the behavior. Many programming languages have robust memory models ranging from &quot;happens before&quot; style systems like those in Java or Modern C++ to the Software Transactional Memory system in GHC&#x2F;Haskell.<p>Correct, shared mutation is an extremely well-understood problem in the sense that there are points in the programming language design space that admit it with present technology.<p>As always, there are tradeoffs.
  • Xeoncross1 hour ago
    I&#x27;m really looking forward to the next generation of languages. Not only are the old 90&#x27;s languages like Java, PHP, and JavaScript now actually doing things correctly. The new languages like Zig, Go, Swift and Rust continue to figure out new ways of trying things like generics. Spinoffs like V, Ante, and others are perfect testing grounds.
  • HexDecOctBin23 minutes ago
    What is &quot;stable shape&quot;?
  • sureglymop1 hour ago
    What about Vale? Is this a rename of it or something new?
    • verdagon3 minutes ago
      Hi, article&#x27;s author here (Verdagon, Vale&#x27;s creator), and no, I&#x27;m just writing about someone else&#x27;s language (Ante) that I thought was interesting.<p>Ante is making some very intriguing steps forward in memory safety design and I thought others would find it interesting too.
  • FpUser1 hour ago
    &gt;&quot;I have to admit, this is beautiful&quot;<p>Terse it is, beautiful it is not (well my version of beautiful that is - easy to read and understand). this is not to diminish the language.
    • wild_pointer51 minutes ago
      That&#x27;s what I thought too when I first saw it. But then I actually took a moment to read it and eventually changed my mind.