Ordinary sunglasses. A serious limitation of ordinary sunglasses that is not obvious to the average user is that they degrade the vision by reducing the amount of light entering the eye, making everything darker and harder to see. Pinholes do not darken the image in that way.
Traditional pinholes as sunglasses. Conventional, hole-type pinhole glasses also reduce the brightness of the sun, just like ordinary sunglasses. But they do so by creating a SMALLER pupil. This is also a simple thing to verify. Just put on a pair of pinholes on a sunny day and see how the brightness of the sun is reduced.
Modern pinholes as sunglasses. But the most extraordinary use of pinholes in place of ordinary sunglasses is with the modern pinhole glasses that look like sunglasses. In addition to the light reduction that is provided by the small holes, the lenses have built-in UV protection. These are really the ultimate in eyewear. They are inexpensive, stylish, function as sunglasses, can be used indoors or outdoors, and can last a lifetime. However, they should not be used for driving or any moving activity where good peripheral vision is required.
Ultraviolet protection. People who spend a lot of time in the sun should have glasses with ultraviolet protection in order to prevent damage to the lens and retina. Here is a comparison in order of increasing protection: