Some units are very precisely defined. Others much less. And you'll learn that some can have very different definitions depending on context or whoever you're talking to.
Supposedly, a pixel (picture element) is the smallest addressable unit on a screen. So your screen may have 1920 x 1080 pixels ("full HD"), with each pixel being able to have a different color. But RGB pixels are actually made of 3 elements (sub-pixels), one for each channel: one red, one green, one blue (sometimes one is doubled). And some technologies (e.g. ClearType) will actually use those subpixels individually to take advantage of the higher resolution for anti-aliasing purposes (this requires knowing how the sub-pixels are arranged, and in what order).
Some people will tell you each of those sub-pixels are dots. Others won't and tell you the pixels are dots. Some people (a minority, though) will even tell you that each of the sub-pixels are actually the pixels (this is most common coming from the actual display manufacturers).
It is worth noting that screens can vary the intensity of each sub-pixel. This is where the bits per channel come in. Each sub pixel is not just on (full red, green or blue) or off (black) — this would only give us a total of 8 colours: black, red, green, blue, yellow (red+green), purple (red+blue), cyan (green+blue) and white (red+green+blue).
Instead, each sub-pixel (channel) can take a number of values between the two. If you have 8 bits per channel (so a total of 24 bits for RGB), that means each of those sub pixels can take 256 different values (1 bit = 2 values, 2 bits = 4 values, 3 bits = 8 values, and you continue doubling until 8 bits = 256 values). So in total, you get 256 x 256 x 256 = 16 million colours.
The dot is more commonly used in print. Initially, on black-and-white printers, where each dot can only have two states: it is white (no print/no ink) or black (print/ink).
Note that on printers (especially inkjet printers), dots can be larger than the spacing between them and overlap (usually the opposite for pixels, which if you look very very closely may have a bit of space between them), though of course older dot matrix printers usually had spaces between dots.
Contrary to screens, printers usually don't handle anything but on or off (printed or not, ink deposited on the paper or not). You can't get a half-printed dot. So to get grayscale, or a large variety of colours, one will use patterns (called halftones). To have something quite dark, you set most dots to black. To have something quite light, you'll set only a few. Likewise to get any colour you want, you'll combine multiple patterns on top of each other, one each for cyan, magenta and yellow (and usually black for best results).
If you look at large billboards e.g. in subway stations, which are produced by expanding a smaller image, you'll see those patterns quite clearly.
To achieve the same kind of results you would on a screen (in terms of number of colours), you thus need multiple dots for each individual unit you want to assign a different colour to. For instance, if you want to have the same 8 bits per channel, you need to be able to print anywhere between 0 and 255 ink dots for each unit. That requires 256 dots, or a square of 16 x 16 dots.
Note that you may think that 8 dots are enough, with each dot matching one bit, but that's not the case. In an 8-bit channel, each bit has a different weight, while all the dots have the same weight. So you need a lot more.
This means that if all those dots where arranged in a perfectly rectangular fashion, you need 16 times more dots in each direction to achieve the same result as a screen (in term of number of colours). That's one of the reasons why professional printing usually uses resolutions of about 1200 or 2400 dots per inch. In the end, this is not much better (for pictures) than a screen at 75 to 150 dpi (but it makes a whole lot of a difference for cases where you're printing pure black and white, like text, because you don't use halftones for those). The resolution once you take into account the pattern size is measured in... lines per inch.
This is the reason why, in print, in you want a specific colour but also need fine detail, you won't print in regular CMYK, but actually have a separate channel using a predefined colour with will use a specific ink. So if you want very readable purple text, you won't print it as a combination of cyan and magenta (which will give a very fine grid of dots mixing the two, and you'll end up with "fuzzy" text), but directly using purple ink. That's where Pantone colours and other palettes come in, they're actually inks (of course this is for professional offset printing, usually not on your home laser printer which can only use the standard inks).
You'll notice that I mentioned "dots per inch" (dpi) both for printers and for screens. Yes, "dots per inch" for screens are actually pixels per inch. Same thing for your screen's "dot pitch".
If that wasn't complex enough, some units also have standardised sizes. As for a long time computer screens had vaguely similar resolutions (in dots per inch) usually in the 70-90 dpi range, programmers often measured things in pixels rather than more absolute units like points (1/72 of an inch), mm, cm, picas, or whatnot.
The problem? When higher-resolution screens (e.g. the "Retina" screens) came along, anything that was measured in pixels would become a lot smaller if the relationship with the physical pixel was maintained, not the intended effect.
So some technologies (like CSS) define a pixel as being something which is not a physical screen pixel! They actually define it as 1/96 of an inch.
This gives quite interesting discussions between CSS pixels and actual physical pixels. This page for instance will show you the difference between "points" used by programmers/designers (which are not actual 1/72 inch points, and in the context of CSS, are the same as CSS pixels), rendered pixels (using an integer ratio), physical pixels (after bit of downsampling the match the actual number of screen pixels) and physical size.
Welcome to the wonderful world of pixels and dots!
std::atomic
, and database transactions (either fully happens or not at all, and other queries can't see an in-between state). Can num++ be atomic for 'int num'? / en.wikipedia.org/wiki/Atomicity_(database_systems)