I was just doing a project for a website and my team member excavated a standard pn-junction diode to see that inside the ceramic casing, the semiconductors of p and n doping merely abut together in close alignment. Shouldn't the case be that a single length is variably doped with n and p type impurities to form the junction? If I remember correctly, then textbooks tell that simply joining the two by their boundary does not make it a p-n junction since there are always irregularities on microscopic scale. Any insights on this?
Separately processed pieces of semiconductor mechanically joined won't work well as a pn junction because the facing surfaces need to be perfectly joined (as the crystalline structure level), and without and intermediate impurities (oxidation of the surface). In theory it would work, if you could align the crystals perfectly, but in practice it can't be done.
Generally a pn junction is formed by taking a bulk doped semiconductor (e.g. n-type), and diffusing p-type impurity at the surface. This creates a pn junction beneath the surface of the semiconductor. The p portion is actually counterdoped - it contains n impurities, but more p impurities, giving a new p-type characteristic.