4 ms·
I'm a C programmer, I began in ~1995, and I mostly wrote C for my entire career/hobby stuff, apart from assembly, and Python for scripting purposes. I tried Ru
by jylam 4y ago
I'm a C programmer, I began in ~1995, and I mostly wrote C for my entire career/hobby stuff, apart from assembly, and Python for scripting purposes.
I tried Rust, wrote a raytracer and a GameBoy emulator to learn the language. But I still find it VERY hard and slow to write on a daily basis. You can't just test anything with it. Either you thought the whole project well at the beginning, or you'll need to rewrite everything from the start.
I understand Rust is meant to be clean, no undefined behaviours, everything explict. But as a C programmer, that's just the opposite of what I am accustomed to.
Are there documentations, books, tutorials, whatever, that explain to someone like me how Rust works from a C expert's perspective ?
(To be clear, my brain is NOT a clean slate, and I think we are legion. I've spend sometimes days to understand how to clear a Rust compiler error, and it ends with the copy of a whole megabyte of a structure because I don't think how I should think in Rust)
- nfrmatk 4y agoIn case you haven't seen it already, Cliff Biffle's "Learn Rust the Dangerous Way" might be of interest to you. https://cliffle.com/p/dangerust/ https://cliffle.com/p/dangerust/
- dijit 4y agoThere is a certain irony that existing knowledge of low level programming is a detriment to learning rust. It’s almost as if you need to completely unlearn behaviours before you can learn the “the rust way”. I think the standard path is this “book” (GitHub repo): https://github.com/nrc/r4cppp https://github.com/nrc/r4cppp
- sbdncuvh 4y agoI had to learn some low level memory models before I could really grok rust. I understood a bit of C++ but it wasn't until I found the talk about memory structures for rust/c++ that I really caught on. I can understand why knowing existing programming techniques might cause a struggle. https://youtu.be/rDoqT-a6UFg https://youtu.be/rDoqT-a6UFg
- pjmlp 4y agoThe Rust way to do low level programming is easier for those that bring some experience from Wirth languages approach to systems programming, instead of being tainted by C. In a way it is like meeting an old friend, a kind of Ada/Modula-2/Object Pascal coupled with the borrow checker and more curly friendly syntax.
- zozbot234 4y ago> it ends with the copy of a whole megabyte of a structure That's actually a good start for just making things work but yes, maybe you can try to optimize that away much as you would in C. E.g. you can use std::borrow::Cow<> to abstract across "owned" and "borrowed" data, so that copies only happen when necessary.
- gxt 4y agoTook me 9 months of trial and error in 2018-19, trying it on and off again, before I could understand how to do with rust. Just writing a few programs weren't enough for me to understand, because I was just using what I knew and not what I needed.
- pas 4y agoMy usual way(s) of learning a new language is, depending on whether I like it or not, to start following related content (eg. the Rust subreddit, read articles that are too long https://fasterthanli.me/ https://fasterthanli.me/ and https://matklad.github.io/ https://matklad.github.io/ , and watch hours of https://www.youtube.com/c/JonGjengset https://www.youtube.com/c/JonGjengset etc), then eventually attempt writing something in it. And based on all this copying a megabyte might be perfectly A-OK. Computers are fast, life is short, keep structs simple because they can get problematic (https://matklad.github.io/2020/12/28/csdi.html https://matklad.github.io/2020/12/28/csdi.html).
- mamcx 4y ago> I'm a C programmer, I began in ~1995, and I mostly wrote C You are so lucky. I used around +12 langs, professionally, and learning Rust was the biggest slap on the face I ever faced. The major breakthrough on my learning was understand that Rust make A LOT of things easier, but start doing a fully formed system/app was not the way. ie: Get to know the real small stuff. Rust is: structs, enums, traits, iterators. Then learn the idioms: https://rust-lang.github.io/api-guidelines/ https://rust-lang.github.io/api-guidelines/ The most key thing about Rust is that everything revolves around trait and trait composition. For example. if you look at: https://doc.rust-lang.org/src/alloc/string.rs.html#366-368 https://doc.rust-lang.org/src/alloc/string.rs.html#366-368 You will wonder "where is all the functionality to deal with Strings???". And the answer is that that is not on Strings, but around several traits. Then you start seeing that traits everywhere, and suddenly, you see that learn X here means you already know how do Y there. Then, you start doing apps/systems, and now it will fly!