Live data from Hacker News

Several core problems with Rust

bykozy.me

61–70 of 341 posts

Re: Several core problems with Rust

#61
post #33
post #21

Earlier quoted context omitted.

Node.js and Go are both memory safe, as are Python, Ruby, and Java. "Memory safe" is a term of art referring to susceptibility to memory corruption vulnerabilities in code written by an ordinary practitioner of the language. Almost invariably, attempts to show languages like Go and Python as memory-unsafe involve a programmer deliberately working to defeat the language. But you can do that in any language, including…

It's easy to cause memory corruption with Go while building a concurrent system, you don't need to learn anything about "defeating the language".

I agree, and I personally wouldn't call golang memory safe for that reason. Thomas's semi-definition includes the word "vulnerability", which narrows the scope so much that golang fits under the bar, since the common data race that causes memory corruption hasn't been shown to be exploitable without being contrived.

My personal definition of memory safety for a language like golang would specify that you can't cause this sort of memory corruption without an explicit call to unsafe, but there's no real definition to fall back on.

Re: Several core problems with Rust

#62

Mutable shared state is a feature, not a bug. It's true that it's easier to write correct async code using immutable shared data or unshared data. However, it's very hard if not impossible to do fast and low memory concurrent algorithms without mutable shared state.

Idk, it's a general rule of thumb that the more mutable shared state an algorithm has, the worse it scales. So if you're trying to scale something to be concurrent, mutable shared state is an antipattern.

Re: Several core problems with Rust

#63
post #25

The author would probably find joy in using Zig. Personally my biggest complain from Rust is that I wish it was more readable. I've seen function signatures that seemed straight out of C++.

> Personally my biggest complain from Rust is that I wish it was more readable. I've seen function signatures that seemed straight out of C++. There is always a trade-off. You really cannot provide enough information for the compiler without the current signatures. There is a certain point where you cannot compress the information without losing some features.

It's always an option to create type aliases, but there's a bit of "robbing Peter to pay Paul" happening when you do that.

You make the signature shorter but also take away the ability for the programmer to quickly understand what code is doing.

Re: Several core problems with Rust

#64
post #5

Totally wrong. > Its compilation is slow. I mean SLOW. Slower than C++. No way. Maybe Rust 1.0, but it's steadily improved and it's definitely faster than C++ now. > It’s complex. Just as complex as C++. True, but the problem with C++'s complexity is that you have to memorise all of it or you'll accidentally invoke UB. It's so complex that is basically impossible. Rust is complex but most of the time the compiler wil…

> I would love to hear what he thinks a good programming language is

Also, not the OP, but I bet it is Python.

- No compile time.

- Not as complex as C++.

- Memory Safety, while they don't care about this apparently, but nice to have.

- Plenty of ergonomic GUI style programming, like PySide (Qt for python).

Of course, I know there are many downsides to python. Such as interpreted languages, especially ones that are duck typed are very slow to run... but that's not one of the OP's complaints.

Re: Several core problems with Rust

#65
post #20

I think we’ve officially reached the inflection point where the Rust haters have become more annoying than the Rust evangelists. Maybe in a couple years we will finally be able to stop writing blog post about it.

> Rust haters have become more annoying than the Rust evangelists I disagree. There's a long road till that inflection point for me.

At least the Rust evangelist build shit.

Re: Several core problems with Rust

#67
post #12

I think we’ve officially reached the inflection point where the Rust haters have become more annoying than the Rust evangelists. Maybe in a couple years we will finally be able to stop writing blog post about it.

We really just need official/honest guidance on Rust for what works and what doesn't. The classic example is the dodging around cyclic datastructures. Tl;DR Rust doesn't support any form of cyclic datastructure without indirection or unsafe. The indirection tooling is weak, and most real examples simply switch to unsafe rust. Unsafe rust is completely fine if you know what you are doing with memory, and is ok to use…

A couple years ago I implemented a btree (technically order statistic tree) in a couple thousand lines of unsafe rust for a project. I wrote it more or less how I'd do it in C. Each internal node and leaf node was a separate heap allocation and internal nodes had an array of child pointers. It was surprisingly hard to program up. And complicated!

In my opinion, unsafe rust code is worse to use than C because rust is missing the arrow operator. And rust still requires strict aliasing to be followed even in unsafe code. This makes complex unsafe code very hard to implement correctly. Like, it’s easy for something to look right and work correctly but for MIR to still find subtle issues.

Eventually I rewrote my btree on top of Vecs. My node & leaf pointers are now array indices. The result? There is no longer any unsafe code. The code has become significantly simpler and it now runs ~10% faster than it did before, which is shocking to me. I guess bounds checks are cheaper than memory fragmentation on modern computers.

I have so many thoughts having done that. First, I think this is actually the right way to write rust. Yes, manually keeping track of which array slots are in use is inconvenient. But unsafe & pointers are also quite inconvenient in rust. Programming like this makes use after free bugs possible to write. But it’s still memory safe by rust’s definition. It’s impossible to get arbitrary heap corruption because there are no raw pointers. And the indexes are bounds checked.

I also don’t think the resulting code is any worse than the equivalent C++. Everyone talks about memory safety but IMO rust’s best features are enums, traits, cargo, match expressions and so on. Even when you do a run around the borrow checker, it’s these features which make me keep coming back to rust.

I agree better guidance would be nice, but so many words have been spilled on rust already. Would you find content talking about subtle stuff like this? Sometimes the only way to learn is by trying stuff out.

Re: Several core problems with Rust

#68
> We actually had a recent Cloudflare outage caused by a crash on unwrap() function

Oh boy, this is going to be the new thing for Rust haters isn't it?

Yes, unwrapping an `Err` value causes a panic and that isn't surprising. Cloudflare had specific limits to prevent unbounded memory consumption, then a bad query returned a much larger dataset than expected which couldn't be allocated.

There are two conclusions: 1) If Cloudflare hadn't decided on a proper failure mode for this (i.e. a hardcoded fallback config), the end result would've been the same: a bunch of 500s, and 2) most programs wouldn't have behaved much differently in the case of a failed allocation.

Re: Several core problems with Rust

#69

Earlier quoted context omitted.

Why do you think that?

lists, em dashes, headings and typical length of LLM response.

soon we ll hafta rite lyk dis and maybe தேவையே இல்லாம include other languages in the text, just so people won't automatically say it's AI written.

Re: Several core problems with Rust

#70
You really have to compare articles like this, which are just a bunch of hand waving around the author's biases, against articles with more concrete statements like the Android team finding a 1000x reduction in memory vulnerabilities compared to C/C++. Thanks for your opinion but I'm going to weigh the people who actually use the language more than you.
Post reply on HN