←back to thread

177 points signa11 | 1 comments | | HN request time: 0.264s | source
Show context
kstrauser ◴[] No.42160831[source]
Rust was a pain in the ass until I stopped trying to write C code in it and started writing idiomatic Rust. I don’t know the author of this blog, but he mentions extensive C++ experience which makes me wonder if he’s trying to write C++ in Rust.

Maybe not! Maybe it’s truly just Rust being stubborn and difficult. However, it’s such an easy trap to fall into that I’ve gotta think it’s at least possible.

replies(3): >>42160844 #>>42161027 #>>42161181 #
nicce ◴[] No.42161027[source]
I learned Rust before learning C properly.

Oh boy. I see bugs everywhere in C and why the borrow checker exists. It really forces you to understand what happens under the hood.

The most issues in Rust are indeed related the expressions - you don't know how to describe some scenario for compiler well-enough, in order to prove that this is actually possible - and then your program won't compile.

In C, you talk more to the computer with the language syntax, whereas in Rust you talk to the compiler.

replies(3): >>42161173 #>>42161240 #>>42162370 #
kanbankaren ◴[] No.42161173[source]
> Oh boy. I see bugs everywhere in C and why the borrow checker exists.

Any examples that you could provide? I have been dealing with C/C++ for close to 30 years. Number of times I have shot myself with undefined/unspecified behavior is less than 5.

replies(5): >>42161886 #>>42162308 #>>42162360 #>>42162444 #>>42164671 #
oneshtein ◴[] No.42162444[source]
Borrow checker checks memory safety. Undefined/unspecified behavior still present in Rust[1].

[1]: https://doc.rust-lang.org/reference/behavior-considered-unde...

replies(1): >>42162632 #
1. bombela ◴[] No.42162632[source]
Only from code annotated unsafe. In other words, if you do not use the keyword unsafe, you have no undefined behaviors.