Hacker News new | ask | show | jobs
by carlmr 3076 days ago
While I generally agree with that sentiment, Rust's compiler is so hard to please that a lot of C/C++ developers find it hard to do it. I think for a beginner it's even harder.

C is so small a language that you can learn it much quicker. The problems surface later on.

4 comments

What do you mean by 'hard to please'? The joke about the compiler being some beast you need to sacrifice a goat to seems to put the blame on the wrong end of the computer imo.

Unless what you are doing is not fit for what guarantees Rust gives you, the compiler should just be a crutch in case you missed a step.

I thought the same until I actually tried Rust. The compiler will complain in a some places which are ok if you know what's happening. It was probably easier to implement the borrow checker that way. At the same time a lot of the error messages are very cryptic if you haven't seen them before. It is in that sense hard to please. A lot of this might become better with coming iterations though.
Now, this is true in many senses, as it's inherently how static analysis works, but I've also had many experiences where someone joins one of our IRC channels, shows some code and says "hey the borrow checker won't let me do this thing that's totally safe" and then I or someone else replies "well, what about this?" to which the answer is "...... oh. yeah." This is virtually almost always from C++ programmers.

It's hard to escape the mindset of languages we're used to!

> At the same time a lot of the error messages are very cryptic

You should file bugs! We care deeply about the legibility of error messages, and the whole --explain system is there to try and go above and beyond.

>You should file bugs! We care deeply about the legibility of error messages, and the whole --explain system is there to try and go above and beyond.

Next time I do some Rust I will. I also need to check out that --explain system. I didn't see that when learning Rust.

Take a program that doesn't work, like this one: https://play.rust-lang.org/?gist=2c7b672c6a211e3ab2f3995e37d...

> error[E0384]: cannot assign twice to immutable variable `x`

That E0384 is a link in the browser. Click it and you go to https://doc.rust-lang.org/error-index.html#E0384 which has a longer version of this error.

On the command line, you can run `rustc --explain E0384` and it'll print out the same text to the terminal.

Nice, thank you! I always Googled it until now.
I am so sick and tired of disgusting C code that I would argue that it is only easy to learn how to write a code in C that compiles but not to learn how to implement projects in C.

In fact if I could, I would like that writing in C was prohibited by law to permit holders only, the jury being rob pike and richard stallman themselves!

> While I generally agree with that sentiment, Rust's compiler is so hard to please that a lot of C/C++ developers find it hard to do it. I think for a beginner it's even harder.

I think it's hard for those who carry "mindset-baggage" from C/C++. My first attempt at Rust was a failure mostly because I thought it was sort of a "weird C/C++".

Mindset baggage is a valid criticism. However I think Rust is a lot noisier and less obvious about many things which you have to get accustomed to. It's a very different mindset baggage in Rust.
I guess even the most legible but slow C code is faster than the same code for javascript with all the speed tricks.