Mental fatigue reduces one's cognitive and physical abilities. In tasks requiring continuous attention, such as driving, fatigue is a well-known risk. However, when fatigued during daily tasks, such as programming, the nature of risk is more diffuse and accumulative, yet the consequences can be just as severe (e.g. defects in autopilot software). Identifying risks of fatigue in the context of programming can lead to interventions that prevent introduction of defects and introduce coping mechanisms. To character and predict these risks, we conducted two studies: a survey study in which we asked 311 software developers to rate the severity and frequency of their fatigue and to recall a recent experience of being fatigued while programming; and an observational study with 9 professional software developers to investigate the feasibility of predicting fatigue from interaction history. From the survey, we found that a majority of developers report severe (66%) and frequent (59%) issues with fatigue. Further, we categorized their experiences into seven effects on programming tasks, which include reduced motivation and reduced ability to handle tasks involving large mental workloads. From our observational study, our results found how several measures, such as focus duration, key press time, error rates, and increases in software quality warnings, may be applied for detecting fatigue levels. Together, these results aims to support developers and the industry for improving software quality and work conditions for software developers.