First-principles calculations of twin boundaries in 3C-SiC, Si, and diamond are performed, based on the density-functional theory in the local density approximation. We have investigated the formation energies and electronic properties of isolated and interacting twin boundaries. It is found that in 3C-SiC, interacting twin boundaries which are separated by more than two Si-C bilayers are actually energetically more favorable, implying a relatively frequent appearance of these defects. The effect of the spontaneous polarization associated with the hexagonal symmetry around twin boundaries is also studied, and we have observed that the wave functions belonging to the conduction- and valence-band edge states in 3C-SiC tend to be localized almost exclusively on different sides of the faulted layers, while there is no such feature in Si or diamond.