I have been programming in Java since 2004, mostly enterprise and web applications. But I have never used short or byte, other than a toy program just to know
when we are programming for electronic devices like mobile phone we use byte and short.In this case we should take care on memory management.
I found I was using byte variables when doing some low-level image processing. The .Net GDI+ draw routines were really slow so I hand-rolled my own.
Most times, though, I stick with signed integers unless I am forced to use something larger, given the problem constraints. Any sort of physics modeling I do usually requires floats or doubles, even if I don't need the precision.
Apache POI was using short
quite a few times. Probably because of Excel's row/column number limitation.
A few months ago they changed to int
replacing
createCell(short columnIndex)
with
createCell(int column).
I used 'byte' a lot, in C/C++ code implementing functionality like image compression (i.e. running a compression algorithm over each byte of a black-and-white bitmap), and processing binary network messages (by interpreting the bytes in the message).
However I have virtually never used 'float' or 'double'.
On in-memory datagrids, it can be useful. The concept of a datagrid like Gemfire is to have a huge distributed map. When you don't have enough memory you can overflow to disk with LRU strategy, but the keys of all entries of your map remains in memory (at least with Gemfire).
Thus it is very important to make your keys with a small footprint, particularly if you are handling very large datasets. For the entry value, when you can it's also better to use the appropriate type with a small memory footprint...
The primary usage I've seen for them is while processing data with an unknown structure or even no real structure. Network programming is an example of the former (whoever is sending the data knows what it means but you might not), something like image compression of 256-color (or grayscale) images is an example of the latter.
Off the top of my head grep comes to mind as another use, as does any sort of file copy. (Sure, the OS will do it--but sometimes that's not good enough.)