I have traditionally used unsigned int types to store quantities known to be small integers, like days of the month and months of the year for example. To store such values I might use uint8_t. One of the perceived benefits of this is that my structures are more compact. So, if I have a structure with a lot of dates in it, the 8-bit types might result in memory use being a quarter of what it would be if I used generic ints. In the old days this could be important if I had structures taking up megabytes on a computer with only 1 or 2 gigabytes of RAM.
However, nowadays even low-end desktop computers generally have at least 8 GB of memory and 64-bit processors. So, I am wondering if I am doing more harm than good by using small, specific integer types rather than using word size integers. The potential harm is that processing power might be expended handling non-word-sized values and thus effect the speed of execution.
If saving memory is no longer a concern, then my second priority is to design towards computational efficiency, however I do not know whether small memory footprint or word-sized objects dominate with regards to execution speed. In other words, I know it is helpful to have a smaller overall memory footprint because more stuff fits into cache, but on the other hand cycles could be spent upcasting byte-sized integers to the native 64-bit word size. Which factor dominates?
Note that the kind of programs I am referring to here are ones that mostly move data around and do small amounts of adding and subtracting. These are not number crunching applications. So, for example, imagine a payroll system that is storing years worth of data for thousands of employees.
