• 12 days ago
"Each method is defined on this Context type that carries some common state, and the methods tend to call one another."
This is classically a problem of GUI systems, where you have a large number of interlinked on-screen objects constantly undergoing modification.
ReplyI have only a small dabbling in Rust and it was to create a Postfix milter. What was awesome was that someone had already written a Rust crate so that I didn't have to do anything too horrific. The compiler on Ubuntu just worked as expected but, of course, as something that is not standalone, Rusts strong type-checking did not save me from writing something that didn't work.
Part of the confusion is the very confusing (for a noob) difference between String and &str and as someone who has written C and C++, I don't have a problem with understanding references and addresses but I didn't find a very good explanation. This led me to writing code using the only way I could get it to compile that didn't crash at runtime (which was nice!) but it also didn't work.
The second issue was that being something plugging into an external daemon, at the interface level, we were getting a raw pointer and had to convert it into a string to use it. I tried so many combinations but couldn't get it to work but thanks to the maintainer of the Rust crate (who obviously knew what he was doing) he told me where my code was wrong and I fixed it.
So I guess good in that there were probably no horrific bugs, although this is much like C# or possibly Java. But yes, the strong checking doesn't stop things from not working.
ReplyRust's safety features have never been its main selling point for me. Modernity and (recently) momentum are. That it's impossible to author certain classes of bugs is a nice bonus.
That said, I never want to see another rounding bug in financial statements that happened because some piece of code implicitly converted a string to a float and it kinda almost worked every time. To quote a cliche, I'm too old for that shit.
ReplyWhen I was first learning Rust, it was exactly this sort of lifetime issue that tripped me up and frustrated me, until I finally saw the light and understood how things work.
Yes, the article is overly technical and detailed, but it captures very well the eureka moment of understanding Rust’s memory management. Some aspects are subtle yet profound.
I am always happy to take a little more pain at code-writing and compile-time in exchange for more safety guarantees at run time; Rust is great in this regard.
ReplyThis article is super overcomplicated. All it had to say was that rust tells you when you keep reference to on stack variable after it goes out of scope. Context provided adds nothing.
I must say - as someone who doesn't use rust - I haven't had this type of issue in years, and when I did it wasn't hard to debug. You get corrupted data, set data breakpoint and in the provided example you will see it being modified by unrelated operations on stack. From there there is only one conclusion. Authors reactions seems to be a bit exaggerated.
ReplyIf only his webserver were written in Rust.
ReplySo many words to describe a simple issue of using reference to out of scope data. Anyways I am using C++ a lot and this types of bugs are easily caught by analyzers or straight up by modern IDEs like CLion (you get a warning).
ReplyA garbage collector has saved my brain from overfrying many times.
ReplyFrom the article:
It’s pointing out that we are pushing into this vector
which needs references into “the AST”, but we haven’t
declared in our signature that the ast::Ty must actually
from “the AST”.
I think someone needs to write a typechecker for English to help out the author of this sentence.Reply I've used Rust and I like it alright but it has the ugliest syntax of any major language since Perl
ReplyIf only rust caught blogging security errors.
It's a terrible idea to post a photo of your child with her name on your public blog.
It's one of those subtle security things that the rust compiler helps with; but not here, sadly.
ReplyYes... but before you start feeling too sure about Rust protecting you from creating bugs, also consider this more cautionary (and very entertaining) tale posted on HN today: https://hacks.mozilla.org/2022/06/fuzzing-rust-minidump-for-...
ReplyI was looking for some kind of story related to cooking bacon with Rust -> disappointed. Bacon is only used once - in the heading...
ReplyRust is undoubtedly a step forward in correctness, but boy, the article's code is so thick that for me, that I am a C++ programmer, is almost unreadable, especially for a quick reading...
I skipped all the code and only read the text. I got to the point where it mentions that the language prevented them from storing a pointer to a stack object in a heap object, and that's really great, but boy oh boy, the code presented, and the error messages, where very difficult for me to grok even after the first few times...
It seems to me that the more sophisticated the safety a language provides is the more complex its error messages/code are. It would be so nice if we could solve both problems at the same time...
Replysite design / logo © 2022 Box Piper