Doping and defect control in semiconductors are essential prerequisites for their practical applications. First-principles calculations of defects based on density functional theory offer crucial guidance for doping and defect control. In this paper, the developments in the theoretical methods of first-principles semiconductor defect calculations are introduced. Firstly, we introduce the method of calculating the defect formation energy and finite-size errors to the formation energy caused by the supercell method. Then, we present corresponding image charge correction schemes, which include the widely used post-hoc corrections (such as Makov-Payne, Lany-Zunger, Freysoldt-Neugebauer-van de Walle schemes), the recently developed self-consistent potential correction which performs the image charge correction in the self-consistent loop for solving Kohn-Sham equations, and the self-consistent charge correction scheme which does not require an input of macroscopic dielectric constants. Further, we extend our discussion to charged defect calculations in low-dimensional semiconductors, elucidate the issue of charged defect formation energy divergence with the increase of vacuum thickness within the jellium model and introduce our theoretical model which solves this energy divergence issue by placing the ionized electrons or holes in the realistic host band-edge states instead of the virtual jellium state. Furthermore, we provide a brief overview of defect calculation correction methods due to the DFT band gap error, including the scissors operator, LDA+<i>U</i> and hybrid functionals. Finally, in order to describe the calculation of defect formation energy under illumination, we present our self-consistent two-Fermi-reservoir model, which can well predict the defect concentration and carrier concentration in the Mg doped GaN system under illumination. This work summarizes the recent developments regarding first-principles calculations of defects in semiconducting materials and low-dimensional semiconductors, under whether equilibrium conditions or non-equilibrium conditions, thus promoting further developments of doping and defect control within semiconductors.