Announcing Rust 1.84.1
Announcing Rust 1.84.1
Empowering everyone to build reliable and efficient software.
Announcing Rust 1.84.1
Empowering everyone to build reliable and efficient software.
One issue I've run into recently is with dependencies that need to be the same version as a transitive dependency. I wish I could specify a dependency by marking the package I need to use it with, and cargo could figure it out from there.
Yeah, I know crates could just re-export or accept a trait or something, but I don't control every crate out there.
Another issue is that my target directory gets huge. I just deleted mine and it was 17GB for a small project with a handful of dependencies.
Rust rocks in general though.
I agree. Maybe Rust should make crates automatically re-export dependencies if any of that dependency's types are publicly exposed.
Let us know when the borrow checker is optional so I can write it without hurting my brain.
lol just go write C instead
In a struct, you typically want only owned data types. If you're passing something as a parameter to a function, you typically want only references.
In a sense, that pushes your program to be very tree-shaped. Your data is initialized and held at the root of the tree (or a sub-tree) and only temporarily passed down as a reference.
In my experience, following this rule gets you there for 80% of programs. Only really more complex programs or libraries may need to deal with lifetimes and the various cop-out mechanisms.
If you're hurting your brain, that's probably because you're experienced in other languages and have design patterns in mind that don't work with this model.
Maybe use zig then? It's unsafe (i.e. no borrow checker) and really fast.
But honestly, after learning good patterns, I rarely run into borrow checker issues.
If you use it long enough, the borrow checker will change your brain. Embrace the change, it will help you.
What's the point of using Rust, if you don't want to think and program in Rust? If you seriously don't want to learn and deal with safe code and think every step of it in advance before compilation, then Rust is the wrong language for you. Either use a low level language like C and Zig, which gives you control over the system, but does not have a borrow checker. Or use a language with a runtime check that does this automatically for you without a borrow checker, like Go in example.
I am in the process of learning rust by creating software for my own use.
While the borrow checker feels like "fighting the compiler" at times (it took me a week before it started to land, and i have used my share of programming languages!), you will learn.
I compare this to the C world where you can have quite complex constructs with pointers and references. That used to be hard as hell as well. Until it clicks.
The only difference is that in C land, your software will segfault during runtime. In Rust your code will complain during compilation.
Rust without borrow checker is just a bad version of C in my opinion. Rust with borrow checker actually brings value.
In rust it is still possible to make circular references and cause memory leaks but it is very less likely.
So: i understand where you are coming from but give it a chance to land. I am glad I did.
The only thing which is bothering me at times is that the Rust community can come across as highly unfriendly/intolerant at times (comparable to the scala community, which in effect killed the adoption of scala).
The response to your comment should not have been burning it to the ground but to ask why the borrow checker does not click for you.
I can highly recommend the series "lets get rusty" on YT from Bogdan. He is explaining the main constructs in very easy to follow instructions videos.
Have a look and see if it makes it work for you!
I enjoyed Scala. I don't think they're what killed Scala. I think what speed down Scala adoption was that it was too related to Java and on top of that Java was adopting much of the functional paradigm taking a bite out of scala's dinner.
Scala was adopting functional enthusiasts and the JVM again was to related to Java for their tastes. And if not, then they could just go to Closure anyways.
But in my case it was Rust. With Rust I could also get into systems programming if I wanted to and didn't have to worry about the JVM.
The JVM is really the only reason I have yet adopted Jenkins as well.
It is. You just need to change the extension to .c
Or zig. Heard a lot about that one. Haven't really done any serious testing though.
There does exist a crate that allows you to turn it off. Unfortunately the compiler will still compiler your code assuming the same exclusive access rules imposed by the borrow checker, so any time you break the borrow checker rules you're basically guaranteed to segfault.
The rust compiler always assumes mutable pointers are exclusive. This is the crux of your issue with the borrow checker. If you don't make this assumption, then you can't automatically drop variables when they fall out of scope, thus the programmer would have to manually allocate memory.
You may prefer even then to allocate memory yourself, but if I was you I would just trust the rust compiler in its assumption that it can optimize programs much better when all pointers are exclusive, and learn to program in a compliant manner
Bait or not, I'm not sure why you're getting such a negative reaction. People are getting too sensitive!
Btw, do sanitizers hurt your brain too?
Isn't it already optional? Just put unsafe
on everything?