Your retinas will be perfectly fine, if you make sure the whole room is lit. Sunlight is significantly stronger than the backlight from a monitor.
Dark mode and a dimly lit room do make sense, if you're coding something in the evening and don't want to disrupt your circadian rhythm.