3 ms·
I don't think anyone believes the “if it compile it works” phrase literally. It's just that once it compiles Rust code will work more often than most languages
by littlestymaar 11mo ago
I don't think anyone believes the “if it compile it works” phrase literally.
It's just that once it compiles Rust code will work more often than most languages, but that doesn't mean Rust code will automatically be bug free and I don't think anyone believes that.
- emilbratt 11mo agoYeah, even the official Rust book points it out and if my memory serves me right (not punintended) also gives an example in the form of creating a memory leak (not to be confused with memory unsafe).
- spookie 11mo agoA memory leak can be unsafe though.
- 201984 11mo agoThen why is Box::leak not marked unsafe?
- estebank 11mo ago"unsafe" or `unsafe`? One is the general meaning of the word, the latter is "it invokes undefined-behavior".
- spookie 11mo agoAs "unsafe". An example would be of how AMD GPUs some time ago didn't free a programs' last rendered buffers and you could see the literal last frame in its entirety. Fun stuff. Could've been clearer above.
- yuriks 11mo agoThat is not a memory leak though! That's using/exposing an uninitialized buffer, which can happen even if you allocate and free your allocations correctly. Leaking the buffer would prevent the memory region from being allocated by another application, and would in fact prevent that from happening. This is also something that Rust does protect against in safe code, by requiring initialization of all memory before use, or using MaybeUninit for buffers that aren't, where reading the buffer or asserting that it has been initialized is an unsafe operation.
- embedding-shape 11mo agoThere are definitively people in the ecosystem who peddle sentiments like "Woah, Rust helps so much that I can basically think 'if this compiles, everything will work', and most of the times it does!", and that's the confusing part for many people. Examples found in 30 seconds of searching: - https://bsky.app/profile/codewright.bsky.social/post/3m4m5mvn6r22b https://bsky.app/profile/codewright.bsky.social/post/3m4m5mv... - https://bsky.app/profile/naps62.bsky.social/post/3lpopqwznfs2g https://bsky.app/profile/naps62.bsky.social/post/3lpopqwznfs...
- littlestymaar 11mo ago> "Woah, Rust helps so much that I can basically think 'if this compiles, everything will work', and most of the times it does!" I think is is a fairly bad example to pick, because the fact that the person says “I can basically think” and “most of the time it does” (emphasis mine) shows that they don't actually believes it will makes bug-free programs. They are just saying that “most of the time” the compiler is very very helpful (I agree with them on that).
- spoiler 11mo agoI don't know the authors of those posts, so I don't want to put word in their mouth, but neither seem to be delusional about the "if it compiles, it works" phrase. The first one qualifies it with "most of the time", and the second one explicitly mentions using type state as a tool to aid correctness... But I don't doubt there are people who take that phrase too literally, though.
- muixoozie 11mo agoI read the comments you linked and don't really think they literally believe Rust is magic. I dunno though I guess I could imagine a vibe coder tacitly believing that. Not saying you're wrong. I just think most people say that tongue in cheek. This saying has been around forever in the Haskell community for decades. Feels like a long running joke at this point
- binary132 11mo agoThere is no hint of irony in the linked posts.