I did some Rust training with Ferrous but by far the most useful way to learn was just picking up a project and building it.
I did some Rust training with Ferrous but by far the most useful way to learn was just picking up a project and building it.
I had experience with PHP, JavaScript, and Python, but when at first coding in Go it would take me as much as 10x as long. But with more practice it's now only about 2x as long as in other languages. Keep practicing ;)
By the way, I can write code very easily in Java/Kotlin/Groovy/Dart/JS/TS/Go/Lisp.
I think that most programs should be written in easier languages than Rust, since most of the time the engineering cost of creating a system is higher than the cost of running it. You can rewrite it in Rust once your system is large enough that eliminating the garbage collector will save you a few million dollars a year. By then you’ll have a complete understanding of the requirements, and you won’t have to experiment to get it right. Use a language like Lisp, which is designed for easy and fast experimentation, to write the first version of your software.
And most of the time the cost of _maintaining_ the system is higher than the cost of creating it. This is where Rust truly excels, it makes it much harder to write any hard to find bugs.
In principle you should be able to approach zero maintenance costs with any language, but writing your system in Rust generally means you have abandoned complexities like garbage collection. Garbage collection speeds up development by an order of magnitude or more, but at the cost of having to monitor the performance of the GC, tune it as loads change and computers get more and more memory but don’t get any faster at accessing it, etc, etc.
Exceptions are another thing that speeds up development at the cost of maintenance down the road. You have to log the exceptions that are happening and monitor them to make sure that they are rare otherwise they’ll silently become more common over time as your program gets more complex. Meanwhile Rust’s explicit error handling really makes you think at every step about exactly what odd conditions your program might encounter. If you use Rust’s type system correctly, you can encode very specific information about exactly which errors are possible or impossible at every point in your system. It’s more work up front but it saves a huge amount of time down the road.
Never gonna happen.
I consider those bugs. Please file tickets for that. The errors should provide enough context for an uncaffeinated developer to understand what went wrong.
For me, in large part, the borrow checker is encoding in the compiler rules that you should be following in C++ anyway.
A few hours debugging dangling references or iterator invalidation will make you appreciate what the borrow checker is trying to prevent.
You also have experience knowing the difference between pass by reference, pass by const reference, copy, and move.
Also, if you want to keep your sanity, you will learn to take ownership seriously. Deciding what owns what and whether objects will be owned by the scope (on the stack), be owned by unique_ptr, or be shared with shared_ptr is a large part of designing a C++ program.
Again these all map very neatly onto Rust idioms, and as a benefit are enforced by the compiler.
Coming from a garbage collected language where you previously did not have to care about things like that, and now, not only being forced to care, but having the compiler yell at you for every mistake can be a pretty big learning curve.
However, I would say that not knowing C++ doesn't mean that you can't learn Rust, only that it may take a little longer because you have to learn new concepts with regards to memory management and ownership, and so give yourself some slack and do not be discouraged.
My experience was sort of the inverse of yours: I knew a little C++ before learning Rust, and being educated by the borrow checker has really helped me writing C++.
I looked at C++ many years ago but never used it professionally. About 6-7 years ago, I learnt Rust and a few years later, I started working full time in a C++ team at Google. There are many things in the Google C++ Style Guide[1] that reminds me of Rust, from the ban on exceptions to the use of `std::optional` for optional inputs and outputs.
> Also, if you want to keep your sanity, you will learn to take ownership seriously. Deciding
> what owns what and whether objects will be owned by the scope (on the stack), be owned by unique_ptr, or
> be shared with shared_ptr is a large part of designing a C++ program.
I would love if you could expand on this. I've much experience with higher level languages such as Python, but as I get into C++ I find these nuggets of advise invaluable.https://www.youtube.com/watch?v=TJTDTyNdJdY
Agree with the quote: that's the biggest challenge with Rust... I have been trying to pretend Rust is like Java and I think that was my big mistake.
When you design anything in Rust, even the most basic stuff, you will need to decide "what owns what", unless you clone everything on every usage. Try some very simple code that requires allocation and you will quickly notice that. I am now back at Rust and redesigning all my code to make "what owns what" the first question I ask when writing anything, and that is already being very helpful.
But of course: if you don't need the performance of Rust or the small footprint, it's just not worth it spending time on stuff like that can be completely and utterly ignored in any non-systems language.
I felt a lot like that with Rust.
I'd encourage people to start their Rust journey with little web services.
I've never written linked lists the same way in other languages since.
Rust made me better in languages that aren't Rust.
https://rust-unofficial.github.io/too-many-lists/
You can skip her explanation of why the Linked List is a bad first data structure, and get straight to doing, but if you have no idea why a very experienced programmer would think this data structure is terrible (so terrible she tried but failed to have it removed from Rust's Standard Library before Rust 1.0) you should read her whole PSA too.
Before long you'll be running the compiler in your head and rapidly churning out code.
It makes you faster because you still don't have to handle errors but allows you to add context.
In the past, `&str` was just so huge block for me (now I wonder why!) and instead of getting stuck just ask about it. I think was a stream of a few question on reddit that unblock Rust for me after like 3 months of going nowhere.
After a short while, it gets really tiring... but like others are saying, now we have ChatGPT to ask and it never gets tired!
The more Rust proliferates, the better. It's good at client, server, systems, and so many other things.