I'm somewhat amused at the bit in the Rust book where it discusses arrays. It proudly explains that Rust protects against accessing memory by stopping you from accessing elements past the bounds of an array. Apart from a tiny bit of C I don't really remember, I don't think I've ever used a language that didn't throw some sort of out of bounds error for arrays. It's good that Rust does this, but the text makes it sound like Rust is one of the few that bothers.
@alexhall Love reading your immersion into rust through a book, what book are you using? What are other programming languages that you learn using books as one of the ways of learning it?
@alexhall I just tried a quick program with gcc/Linux and reading out of bounds of an array returned a 0 without any error. (I guess that's uninitialized memory or something.)
Rust will panic, which by default will halt the program. The Rust book is comparing with C (many would say because Rust targets programs where traditionally C would be used), so it's quite different in that regard. Although this is the behavior in many other programming languages.
@alexhall bizarre fact I always love to mention. In C, a[b] is nearly exactly the same as b[a], because indexing into an array is adding the index to the memory address, and addition is conmutative.
C is raw in most regards. Rust adds bounds checks. Which means by default array access is a tad slower in Rust. But what might cause a problem in C will halt a Rust program instead of doing bizarre, possibly harmful stuff.
@coder I've used only a very small amount of C. My daily language is PHP, and I'm comfortable in JS and Python. I am familiar with a few other languages, but not enough to do much with them without some research. I'm probably not the primary audience for Rust, having never had to worry about the low-level access C offers.
@alexhall yeah, that's completely fine. Rust has many niceties that are uncommon in other languages, so Rust fans reach for it even when they don't need low-level features... but it's still a bit painful if you're not very good with it.
Most software I work with is better done in Java/Python/etc.
@coder I'm learning it mostly to learn it. I won't use it at work, and I don't do much coding outside of work. Sometimes it's fun to learn a new language just because.
@kaveinthran It's just called The Book. https://doc.rust-lang.org/book
What I know of Swift, Python, and Javascript I learned myself using various resources. I learned the basics of PHP in a college course. Same with C++, Java, SQL, and probably others. Though this is called a "book", it's really just another online tutorial. I like it quite a lot.
@alexhall Thanks for sharing, appreciate it so much. Do you have any python resources that you go back to a lot?
@kaveinthran Not these days. I know the basics enough that all I have to do is look up something specific I don't remember or haven't done before. This comes up in new Python, since I learned when 2.x was still common. I'm not overly familiar with type hints, for instance.