Hacker News new | ask | show | jobs
by throw10920 1368 days ago
Rust is literally designed to constrain what you can do much more tightly than C(++)/Python/Lisp. That's basically the opposite of the common definition of "freedom".

You can argue that what you give up in exchange for this freedom is more valuable, but don't twist the definitions of words.

3 comments

> That's basically the opposite of the common definition of "freedom".

It depends on which "common definition" you're working from. To make an analogy, both GPL advocates and MIT/BSD license advocates argue that their conception of freedom is "more free."

Rust is closer to the GPL here. By limiting certain things that you can do, you are free to do things that would be harder if you're allowed to do anything. The canonical example here is Stylo; the project was attempted with C++ multiple times, but was too buggy. But Rust's restrictions allowed the Rust version to succeed. You can argue it both ways: Rust limits certain kinds of code patterns (outside of unsafe, of course...) but that may enable you to do things that were too hard to do when there were no safeguards.

(A more generalized version of this debate is the distinction between "positive liberty" and "negative liberty," this debate transcends software.)

Yeah Rust forces your program to use certain patterns. But in return, other users can assume those patterns exist. In result, Rust is one of the best programming languages to do refactorings in that exist. You are less free to write code that can be refactored badly, you are more free to do refactors. A sensible trade in my opinion.
Rust is literally designed with the `unsafe` keyword that tells the compiler: "hey you won't be to prove this is correct, but I'm going to do it anyway, don't check it".

The restrictions merely apply to provably correct code.

I'm not sure how telling the compiler to disable the safety features so you can do your thing is unbearably limiting.

Indeed, but in a similar manner, lisp restricts you out of the low level architecture, and you operate in a higher free-er plane where most ideas will work fine. Rust constraints are mostly liberating because you're safe to assume things will work.