Help me stop hating rust
I think it might be time to get onboard with rust.
I'm a 20 year c/c++ developer and doing c since I was 12 and the idea of rust infuriates me but I want to deprogram my mind from that.
What does the community think is a good place to learn rust for someone with a strong c++ background?
27 comments
[ 2.7 ms ] story [ 67.2 ms ] threadBut since you’re already familiar with programming, perhaps just dive right in…?
I.e. start a new project in Rust. You could do something like Advent of Code, Project Euler or Cryptopals[0]. Or write a simple webserver or whatever you feel like.
Don’t forget that ChatGPT can be quite useful for stuff like this. You can use it like a mentor. Just ask it anything you want to, make it show you examples (and then more examples) and so on. The answers might not be correct all of the time, but at least it can give you an idea of what docs to read next.
If you’re looking for blog posts, an acquaintance of mine has written some: https://priver.dev/tags/rust/
For more links to code/learning resources, see https://github.com/rust-unofficial/awesome-rust
And if you get stuck you also have the official Rust chats on Zulip/Discord.
HTH. Best of luck!
[0] https://cryptopals.com/
on the light side of the force, nrc has provided https://github.com/nrc/r4cppp for some time, you may enjoy its accelerated approach.
Sounds like a lot of work for someone who does not want to use Scala, though.
There is no deprogramming hate without understanding it first.
Start with the Rust book.
https://doc.rust-lang.org/book/
Then do Rustlings until the syntax becomes muscle memory.
Then join the Discord and start doing little projects.
You won’t get up to the proficiency of other languages as quickly in Rust. It takes longer. For me it’s taking a lot longer, but I enjoy it.
Would you care to elaborate? There are some pain points that we're aware of, some of which we're actively working on, but there might be some you encountered that we don't know about and it would be helpful to find out about them so we can potentially address them in the future.
1) compiling is slowwwww, and something about my workplace environment (docker builds) means there's a lot of downloading and a lot of disk space used. cargo clean is helpful, and I blame docker more than Rust here. I am running in a VM, but I've had to increase the allocation to 150 G to run a fairly barebones Linux environment (no desktop) and not have to clean up my environment frequently. Some of my other environmental stuff is also super slow, so I'm pretty grumpy about speed in general.
1a) I've had cargo fmt eat my files when I was out of disk space. It created a new file, but the file length was 0, and my old file was gone. (I did not open a bug report)
1b) I hate how my dependency tree has about 700 items, but I still have to update h2 for a http/2 server security bug to make cargo audit happy, when AFAIK, we don't even use http/2 at all. (we do use hyper, and aws-sdk)
1c) There's about 7 different ways to get at epoll from Rust, but I don't think any of them let you set a sub-ms timeout, unless you use a timerfd (at least one of the 7 ways does do the timerfd for you, but that doesn't make it better, just easier). Why doesn't anyone make epoll_pwait2 available somehow. Although, really, this is more of a question of why didn't Linux offer a useful timeout in epoll_wait to begin with. If I were more familiar with Rust, maybe I'd be confident in just doing it myself, like I can in other languages, but it still seems scary.
2) It's pretty difficult to figure out what my system is doing from the outside. But I'm used to Erlang's introspection, and I was tempted to think that some of the features of Rust would make it Erlang-ish. Maybe I just need to use tokio_console, but it's not there by default, and I'm not sure how I would connect up to my running production system. This is probably more of a me problem or a my environment problem than a Rust problem.
I'm trying to figure out what how set_read_timeout on a UdpSocket works, so I'm here: https://doc.rust-lang.org/src/std/net/udp.rs.html#308-310 and click get source (which is nice to have! and is usually helpful) which takes me here https://doc.rust-lang.org/src/std/net/udp.rs.html#308-310
In this case, this is profoundly unhelpful. There's no way to get from this page to wherever it is I need to be; there's no way to navigate to any other file from here. I'm not really mad, I'm just disappointed --- you set me up for success with this great get source link, and then I gotta just go jump through the source on my own anyway.
- everything in Rust-land is named differently. They are not different, but use different names.
- nothing wants to be a value
- nothing is implemented by default.
If you can get those 3 items in your brain, you can start thinking in Rust. Coming from one c++ dev to another; You may still not like the language. I know I dont, even though I agree with the premise that defaults should be ‘safe’
Rust overall has a limited lifespan, just like most other languages, because at a certain point high level languages (or really probably just Python due to its prevalence in ML community) is going to get mapped onto extremely efficient machine code through pattern recognition, and you get all the advantages of fast development and fast execution, as well as memory and type safety (the latter enabled by ML powered type checkers, and intelligent unit tests that may very well likely be auto written for you).
The reason to chose Rust today is when you have critical code that is worked on by many people that also needs to be fast. The structure of the language is pretty good for keeping things clean and consistent (unless you get lazy and start using a bunch of unsafes... which is somewhat unavoidable if you end up extremely performant code that touches Kernel stuff, see Amazon Firecracker).
If you personally can code extremely well in C, learning Rust gives you no real advantage other than just expanding your skillset for potential niche jobs. And even then, most competent companies in hiring would recognize that if you are very proficient in C, you can probably pick up Rust pretty easy.
I find that highly unlikely.
I guess it's the right time to look into rust, learn the eco system and patterns before it gets too large to learn, as c# nowadays.
Strong assumption. Is this just an isolated opinion or a likely outcome that many HN'ers assume?
Just learn Rust if you would like to. It isn't as good as people pretend it to be, as with any technology, it has plenty of tradeoffs, even when compared to C/C++.
Well I had several sour run-ins with Ruby on Rails and I had decided that it was the worst thing ever and I hated it. And I valiantly defended that position for many years. However, recently I’ve had several roles that required me to use Rails in various ways and I managed to find one or two things that I found… interesting… about it.
So I decided I was going to learn Ruby on Rails just so I could see what all the fuss was about and then I could _know_ I was right and throw it in all those smug Ruby-ist’s faces!
Long story short, I’ve learned a great deal and I’ve come to appreciate many of the design decisions that Rails has made over the years. It’s very opinionated which can go either way, but what it sets out to do, it does very well. I am actually building a Rails application using turbo and it’s been mind-expanding and a total joy to use.
To that end, I can only recommend going in to “prove yourself right” and you may find that you prove yourself wrong.
I still hate Ruby as a duck-typed, dynamic language. I will jump ship at the first full stack web framework that is as comprehensive as Rails but has full-stack, native Typescript runtime. (Hoping for some deno project to fill that void!)
But until then, I’ve come to appreciate and even enjoy Rails.