389
borrow checker? (thelemmy.club)
you are viewing a single comment's thread
view the rest of the comments
[-] pewpew@feddit.it 56 points 2 days ago* (last edited 2 days ago)

Uses rust because it's memory safe but it is vibe coded and the developer doesn't know what a borrow checker is.

Just use a high level language at this point

[-] JackbyDev@programming.dev 4 points 2 days ago

Is rust low level? Genuine question, not trying to start an argument. I guess I sort of view it as low level but with a high level compiler lmao.

[-] CeeBee_Eh@lemmy.world 2 points 1 day ago

Is rust low level?

Yes, more or less. It's generally considered a "systems" programming language. But you can really use it for anything you want

[-] pewpew@feddit.it 8 points 2 days ago

Rust is very popular because is as low level as C but has memory safety features builtin, so it is considered the best of both worlds. So basically what you said is correct.

(Disclaimer: I am not a Rust programmer, I prefer C/C++)

[-] JackbyDev@programming.dev 2 points 1 day ago

I guess in my mind I just associate raw pointers with low level. But I guess Rust lets you do that with unsafe blocks still?

[-] calcopiritus@lemmy.world 5 points 1 day ago

Low level goes way beyond raw pointers. But yes, rust does have raw pointers.

Java does have raw pointers too I believe though. I wouldn't call it low level.

But low level is not well defined. At some point, the difference between low level and high level used to be whether you had to write a different program for each computer architecture. Under that definition, C is a high level language. Assembly (and very old languages) would be low level.

My own definition of low level is: if you have to care at all about memory management, it's low level.

Basically, if the language has a garbage collector or if it automatically counts references without you explicitly telling it so, it's a high level language for me.

[-] JackbyDev@programming.dev 1 points 1 day ago

Doesn't Rust's safety guarantees mean automatic reference counting? Or am I misunderstanding. I guess it means more like happening dynamically at runtime.

[-] calcopiritus@lemmy.world 1 points 23 hours ago

You can reference count, but you must do so explicitly, just like in C++ you have to explicitly use std::shared_ptr, in rust you must explicitly use std::rc::Rc.

Rusts' memory safety is managed at compile time, that's what the borrow checker does. It enforces a strict set of simple rules that guarantee at compile time that all the references are valid when they are used. This means that there is no runtime cost.

Q: "Why would you use Rc then? It would only introduce runtime overhead that is not needed because rust already checked that the program is correct"

A: the borrow checker ensures that your program is valid. However, not all valid programs are allowed by the borrow checker. That is what unsafe is for. unsafe allows you to skip some rust safety features if you want to make a program that is valid but rejected by the "safe" rust compiler. Rc uses unsafe internally to expose an API that is safe, but allows you to do things that would normally be rejected by rust.

Of course, the borrow checker is not all the safety features of rust. There are some safety features that actually do have runtime checks.

For example, you can try to access invalid memory by reading out of the bounds of a buffer/array. Most of the time, it is impossible/impractical to solve for this at compile time. Therefore, a bounds check is done on every array access, if the check fails, the program crashes. That check is done at run time. Many times the compiler will optimize those checks, but sometimes they just cannot be optimized out.

this post was submitted on 06 Jul 2026
389 points (98.7% liked)

Programmer Humor

32192 readers
1374 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 3 years ago
MODERATORS