Daily Learnings: Wed, Jun 14, 2023
The greatest mistake you can make in life is to be continually fearing you will make one. — Elbert Hubbard
Processor Word Lengths
In continuing my review of the Rust programming language course, the instructor wrapped up the portion on the number-based data types available by discussing the isize and usize integer types. These correspond to the given platform’s architecture, meaning that if they’re running on a 32bit architecture they will result in 32 bits, or 64 bits on a 64bit architecture.
This was interesting, and another indication that I’m treading into programming waters deeper than I’ve gone before, as the instructor proceeding to describe why this was important. Here was the key learnings from that section:
isizeandusizedata types are also known as “pointer-sized” integer types, as they match the size of a word in a given platform- In other words, these data types give the guarantee to be always big enough to hold any pointer or any offset in a data structure for a given platform
- I still have a lot to learn on this front, as this doesn’t really make a ton of sense to me yet…
- In other words, these data types give the guarantee to be always big enough to hold any pointer or any offset in a data structure for a given platform
- A word in reference to data storage / processors means the total number of bits or bytes that a CPU processes at a given time
- Modern processors don’t read data or memory in one bit or one byte at a time
- They instead read data in one word at a time, which varies based on the architecture
- A 32bit processor can read 4 bytes (or 32 bits) at a time
- A 64bit processor can read 8 bytes (or 64 bits) at a time
- AFAIK this all has to do with holding pointers to memory locations, which I’ve never had to manage directly in the programming that I’ve done so far
- I’m both excited and nervous to learn more about this by continuing my pursuit of understanding Rust better