One big difference between a diesel engine and a gas engine is in the injection process. Most car engines use port injection or a carburetor. A port injection system injects fuel just prior to the intake stroke (outside the cylinder). A carburetor mixes air and fuel long before the air enters the cylinder. In a car engine, therefore, all of the fuel is loaded into the cylinder during the intake stroke and then compressed. The compression of the fuel/air mixture limits the compression ratio of the engine -- if it compresses the air too much, the fuel/air mixture spontaneously ignites and causes knocking. Because it causes excessive heat, knocking can damage the engine.
Diesel engines use direct fuel injection -- the diesel fuel is injected directly into the cylinder.
The injector on a diesel engine is its most complex component and has been the subject of a great deal of experimentation -- in any particular engine, it may be located in a variety of places. The injector has to be able to withstand the temperature and pressure inside the cylinder and still deliver the fuel in a fine mist. Getting the mist circulated in the cylinder so that it is evenly distributed is also a problem, so some diesel engines employ special induction valves, pre-combustion chambers or other devices to swirl the air in the combustion chamber or otherwise improve the ignition and combustion process.
Some diesel engines contain a glow plug. When a diesel engine is cold, the compression process may not raise the air to a high enough temperature to ignite the fuel. The glow plug is an electrically heated wire (think of the hot wires you see in a toaster) that heats the combustion chambers and raises the air temperature when the engine is cold so that the engine can start. According to Cley Brotherton, a Journeyman heavy equipment technician:
Smaller engines and engines that do not have such advanced computer control use glow plugs to solve the cold-starting problem.
Of course, mechanics aren't the only difference between diesel engines and gasoline engines. There's also the issue of the fuel itself.