| > Isn't unsafe still bypassing the borrow checker, in the sense that you're mostly using it because you're doing something the borrow checker does not otherwise allow? Not really. But using raw pointers and converting to/from memory addresses isn't something borrow checker can check. It's a borrow checker not address verifier. E.g. you can take raw pointer, and set two mutable variables to point to it and borrow checker can't know they point to same address. > But again, I don't understand how that is a unique benefit of Rust. It's statically enforced by the compiler using Rust's type system. As far as I know Zig can't say well these two functions can run in parallel because they are at compile time guaranteed to never access same resources and it's impossible to bypass it (outside unsafe). And their content is thread-safe based on the type they satisfy. > I mean, I think it can't be taken for granted that preventing errors should be the top priority of every programming language. Douglas Crockford made a good case that every language should on some level try to prevent errors. > Python is another example: it's very easy to write an incorrect Python program Python is also older than Java, but even Python is memory safe (GC). Zig and new batch of better C aren't. In that way we definitely regressed. > I would argue the universal priority of programming languages is to enable the programmer to deliver user value through their program. If that is truly the case we'd be all programming in Excel and Access. Anything can deliver value, question is - can it be maintained, and at what cost. In lieu of that a language that makes a set of errors nigh impossible is better than a fast one where those errors are trivial to cause. |
That sounds an awful lot like bypassing the borrow checker.
> As far as I know Zig can't say well these two functions can run in parallel because they are at compile time guaranteed to never access same resources and it's impossible to bypass it (outside unsafe). And their content is thread-safe based on the type they satisfy.
Yeah but that's the point. Rust has one way of guaranteeing that two pieces of code don't mutate the same memory at compile time, but that's not the only way to write a correct program which guarantees that. Rust is going to force you to write your program in a certain way to achieve this. There are many other approaches you may be able to use in an unrestricted language which reach a correct and potentially more performant result which are correct, but which rustc cannot verify are correct.
> Douglas Crockford made a good case that every language should on some level try to prevent errors.
That's one opinion. There are many who disagree.
> Python is also older than Java, but even Python is memory safe (GC). Zig and new batch of better C aren't. In that way we definitely regressed.
That's not even an argument. It takes it for granted that lack of memory safety in a systems language is "a regression". That's not an established consensus.
> If that is truly the case we'd be all programming in Excel and Access.
How exactly do you come to the conclusion that Excel and Access are better at delivering value than other programming languages?
> Anything can deliver value, question is - can it be maintained, and at what cost.
Yeah exactly. The point is which language can deliver the most user value in your desired use-case at the least cost. For something like an operating system, where reliability is paramount, it may be a good tradeoff to use something like Rust which is unergonomic and slow to compile because the safety and correctness tools contribute to your use-case directly.
For something like a web front-end project, you're probably not going to choose Rust since it's going to be hard to find enough programmers who are willing or able to get over the Rust learning curve, and Rust's USP's don't do a lot for you.
For something like game-dev, where 30% of what you're doing is thinking about memory layouts, Rust's tradeoffs are actively working against you, and you might appreciate the faster code/build/run loop offered by something like Zig.