Question: Is Rust a language for beginners?

I'm trying learn Rust language.
In the C and Rust programming languages, error messages scare me.
Because I don't understand and I can't find help about errors.
For example,
from tutorial

After
cargo c
I have error

cargo:rerun-if-changed=/home/user/RUST/demo/src/cxxqt_object.rs

  --- stderr
  thread 'main' panicked at 'Could not read path {} to string: Os { code: 2, kind: NotFound, message: "No such file or directory" }', /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cxx-qt-gen-0.5.3/src/syntax/qtfile.rs:44:57
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

I asked AI from deepai and

The build process failed due to an error caused by not finding a file or directory at the specified path (/home/user/RUST/demo/src/cxxqt_object.rs).

...

It's true, Had name cxxqt_oject.rs , but should have name cxxqt_object.rs

So the question is, should I learn Rust if I don't understand the errors?
Or should I just continue to learn and forgive because Rust and I are new?

It sounds like you understood the error ok enough?

To be fair to Rust, this isn't the compiler giving you an error message as such, but a build script; so the errors are as good as the code in the script. There's quite a few libraries dedicated to producing prettier and more helpful errors, if you want your own errors to be nice:

I would suggest to at least start off with something a bit less involved than trying to build a desktop app in Rust though: other than UI just being hard inherently, there's several properties of Rust specifically that make doing UIs notably harder than in other languages, at least for the initial development. Doing what you find interesting is more important though, so don't let this discourage you!

Answering the literal title, though: when similar questions have been asked before the consensus seems to have been that "Rust is hard, but for a new developer maybe not any more hard than any other language", there might be something in these threads (that I randomly picked out of a search):

4 Likes

These kind of errors will stop you in your tracks whichever language. Had you attempted to do the same thing in Javascript or Python or the like it would have just crashed and died when you ran it, leaving you to figure out why. Or perhaps it would have produced some unexpected and wrong result when you ran it, again leaving to figure out why.

As it happens, having used many languages that actually compile to executable code rather than being interpreters, I find Rust detects a lot of silly errors we can make and that it errors messages are some of the best ever.

However, I do see they can be intimidating at first. One gets used to them as one gets more familiar with the language and the messages.

I suspect that in your case things are a little more different than usual as you are mixing Rust and Qt which is written in C++.

In your given example the error message does say "No such file or directory" and prior to that gives the path to that file "/home/user/RUST/demo/src/cxxqt_object.rs". I really think that should be enough clues to figure out what has gone wrong.

Anyway, in short, I think you should persist with Rust for some more time, you will get the hang of it.

In your given example the error message does say "No such file or directory" and prior to that gives the path to that file "/home/user/RUST/demo/src/cxxqt_object.rs". I really think that should be enough clues to figure out what has gone wrong.

Maybe.
In first line I pasted the file name accidentally, because was error below this line.
I'm guessing some kind of protection worked.
I guess Rust found that his variable was empty and it knew there should be a path there.
But it probably can't check whether the path above exists.
I suspect that missing a condition in "cargo" to check if the file exists.

Just to be clear, this error is coming from the build.rs file you added from that tutorial, not Rust itself; and specifically from code inside the cxx-qt-build crate it calls. Specifically, it is using the 0.5 version of the crate, and 0.6 looks like it improves error messages.

You probably want to check out Build Scripts - The Cargo Book for more information about what build.rs does.

2 Likes