The properties of native defects and impurities in diamond and SiC are investigated via large-scale band structure and Car-Parrinello calculations. In diamond, the activation energy for self-diffusion is very high in the intrinsic material (9 eV) but decreases by up to 3 eV in either p- or n-type material. Phosphorus, lithium and sodium are shallow donors, but their solubilities are very low, which makes them unsuitable for incorporation into diamond via in-diffusion. Instead, kinetic trapping during growth or ion implantation must be used. Considering the stability at the dopant site, substitutional phosphorus is expected to diffuse by the vacancy mechanism and to have a high activation energy by analogy to self-diffusion. Both lithium and sodium diffuse through the interstitial channel. Lithium is a relatively fast diffuser while sodium should be stable up moderately high temperatures. For nitrogen in diamond, the well known (111) distortion is found to be due to the interaction of the fully occupied nitrogen lone pair with the dangling bond of the C(111) atom. The single electron associated with the center resides in an antibonding orbital formed from the dangling hybrid and the nitrogen lone pair. This orbital has most of its amplitude on the carbon atom. In SiC, the lowest energy defect in n-type and intrinsic material is the electrically inactive silicon antisite, while the lowest energy defect in p-type SiC is the doubly positive carbon vacancy. The electrons released by the vacancies compensate acceptor dopants, leading to strong self-compensation effects when doping occurs during crystal growth. In carbon-rich SiC, the dominant defect for all Fermi level positions is the electrically inactive carbon antisite. In boron-doped SiC, B(C) is preferred for silicon-rich material while, in carbon-rich SiC, B(C) and B(Si) have similar formation energies.