4 ms·
I have been watching a Twitch streamer Tsoding for a while now. Recently he ported a very simple chat client (like a hello, world! chat app) from Go to Rust [1]
by zoogeny 3y ago
I have been watching a Twitch streamer Tsoding for a while now. Recently he ported a very simple chat client (like a hello, world! chat app) from Go to Rust [1]. Some impressions I have:
* I was surprised how naturally and easily porting the Go code to Rust was. I have been writing Go and I have been happy with it (to my surprise actually). And I have a stereotype in my head that Rust is more cumbersome. But in some cases, the Rust code was much more ergonomic than the Go code.
* Rust appears to be a quagmire of TIMTOWTDI (There Is More Than One Way To Do It). Just looking at the Rust docs for the standard library is a bit stress inducing. In some way Rust reminds me of the old Perl hacker culture which many love but I did not. When I first read the zen of Python stuff, and the idea that there should be one obvious way to do things I knew where my own heart lay.
* Rust is like the Dark Souls of programming. In the linked video there is a moment where the creator is audibly relieved. He did some mutable borrowing stuff across threads and he was deep in a rabbit hole of making the compiler happy. Finally he got it all to compile but he admits he wondered if he was going to find a dead-end. But there is something addictive about that kind of stress - I know it myself. You feel like you accomplished something when you come out the other side. It is some kind of dopamine inducing validation of your ability as a programmer. I think this is a very negative trait in the context of tools used to complete work.
* After implementing large blocks of functionality and getting the code to compile, it "just worked" as Rust programmers like to brag about.
My impression is still that Rust is over engineered. I have a lot of reasons to feel that way, but a recent one is a video from the CopenhagenRustCommunity where Jon Gjengset did a presentation on using `impl` traits in place of generics. It really feels to me that the ergonomics that I praised in my first point are a deal with the devil. I get the impression that maintaining this facade of "easy" is creating some demons under the covers. And things like `impl` trait and some of the decisions around it are layering on top to try to hide those demons. I don't want to call out this feature too hard since I'm just a tourist here and real Rust guys will probably have more useful opinions on it. But whenever I dig deep into Rust you end up with things like "Pin" or whatever and the guys behind it are almost apologetic. They recognize these are weird annoying things but in some sense earlier decisions are forcing them to do the best they can.
All that being said, I'm probably going to finally give Rust a decent try. I've been writing a small personal project in C and I think porting it to Rust is worth the time.
1. https://www.youtube.com/watch?v=BbIEuNscn_E&ab_channel=TsodingDaily https://www.youtube.com/watch?v=BbIEuNscn_E&ab_channel=Tsodi...
2. https://www.youtube.com/watch?v=CWiz_RtA1Hw&t=2234s&ab_channel=CopenhagenRustCommunity https://www.youtube.com/watch?v=CWiz_RtA1Hw&t=2234s&ab_chann...
- jjnoakes 3y agoThe best advice I can give is: go for it, and if you get stuck or feel like something in Rust is more difficult than it should be, reach out for help. Once in a while you may really be hitting an unpolished piece of the language, but in most cases I find that expert advice can clear up a lot of pain and make things much more ergonomic across the board. Having the proper types and lifetimes at API boundaries, for example, can make a big difference, and folks new to Rust don't often have the right intuition for some of that stuff.
- mplanchard 3y agoRust makes tradeoffs explicit, which means you often have to make decisions you don’t have to worry about in other languages. I suspect this is where your perception of its being over-engineered may be coming from. Traits are mostly well-trodden ground, being rather like typeclasses in Haskell. The ability to use them for both generic bounds and dynamic dispatch is lovely, but a source of confusion if you’re new to the language. In my experience lifetime management is the biggest hurdle when you’re getting started. I’ll admit that five years into learning rust, with half of that working with it professionally, I still sometimes get lifetime errors that I don’t understand. However, I have gotten much better at them over time (name your lifetimes well! it’s a lot more helpful for understanding for a lifetime to be named ‘frobnicator than ‘a, IMO). Anyway, only thing for it is to give it a shot! The feeling of easy performance wins and strong type safety is hard to give up once you’re used to it.
- estebank 3y ago> I still sometimes get lifetime errors that I don’t understand. I'd like to remind people that errors you don't understand are bugs and I'd encourage you all to file a ticket when encountering any: https://github.com/rust-lang/rust/issues/new?assignees=&labels=A-diagnostics%2CT-compiler&projects=&template=diagnostics.yaml https://github.com/rust-lang/rust/issues/new?assignees=&labe...
- mplanchard 3y agoThanks, esteban! I’ll try to keep this in mind. It happens much less often these days, and it’s always hard to disambiguate my own ignorance from the quality of the error message :)