3 ms·
To anyone coming from Python and wanting to try out Rust: If you haven't worked with C before I highly recommend spending a weekend hacking something in C befor
by valzam 7y ago
To anyone coming from Python and wanting to try out Rust: If you haven't worked with C before I highly recommend spending a weekend hacking something in C before starting Rust. It really made me appreciate the borrow checker and super restrictive type system.
- capdeck 7y agoNope. That's a 7 mile "shortcut" for 100m bridge. It really takes time to feel the pain of all the foot guns in C. Just read Jim Blandy's awesome "Why Rust" summary instead https://www.oreilly.com/programming/free/files/why-rust.pdf https://www.oreilly.com/programming/free/files/why-rust.pdf
- valzam 7y agoThx for the link, it looks useful. However, I disagree. The experience of trying to make something work when the compiler gives grief for no obvious reason or doesn't give any errors but you segfault for the 10th time cannot be substituted by reading a book.
- skohan 7y agoI would highly recommend everyone who is serious about programming to spend some time with C. I find it really useful for building a mental model of what your computer is actually doing.
- ChrisSD 7y agoI find assembly is better for that. The trouble with C is the model it uses is 30 or 40 years out of date by now. Computers have changed a lot in those years.
- skohan 7y agoWhich parts do you find out of date?
- ChrisSD 7y agoIt's not a case of parts being out of date. It's the C abstract machine that is a different model to the machine's. More specifically, C was designed in the PDP-11 era. Hardware has evolved since then which makes it a poor choice if you are wanting to build a mental model of what your computer is "actually doing".
- skohan 7y agoYes but I am asking in what way the abstraction is no longer accurate. Your computer is still more or less doing the following no? - allocating/deallocating memory - reading and writing values from/to memory locations - performing arithmetic and logical operations on values
- ChrisSD 7y agoYes the machine can do those things, you're right. If that's all you meant then sure the abstraction is enough. But you can learn those broad concepts using Python if you want to. However, what the machine is actually doing can differ substantially from these naive models. An algorithm that should be slower according to the C model can in reality be fast. Registers, cache levels, vectorization, etc are all concepts that C doesn't teach. Compilers often have extensions to C that enable more direct access (and also do things like adjust memory layout) but at that point you're no longer using the C model. Optimizing compilers (and even cpus themselves) also do a good job of trying to uphold the abstraction but at the end of the day it's still leaky. So knowing what the machine is actually doing is helpful.