Gasoline is often thought of as being a single chemical, but it's actually a complex mixture of hydrocarbons that generally have 4 to 12 carbon atoms in their molecules. In the case of gasoline made from Oklahoma crude oil, "5 compounds make up 29% of the gasoline fraction, whereas 20 compounds make up 59% of the gasoline fraction" (reference 1). Diesel fuel is a light oil that is heavier than gasoline, composed of hydrocarbons generally having between 10 and 20 carbon atoms in their molecules (2). The point is, gasoline and diesel fuel aren't the same.
Gasoline is typically burned in spark-ignition internal combustion engines, in which a source of energy (a spark) is required to start the ignition process. Simply put, these engines mix gasoline vapor and air, compress the result, apply a spark to initiate combustion, and then force the byproducts of combustion out as exhaust. Gasoline is well suited to this process, although sometimes either it or engine operating conditions can cause "knock," an unwanted and destructive condition in which a portion of the fuel ignites spontaneously due to compression alone, without the aid of the spark.
Knock is a serious problem for gasoline engines. The resistance of a particular gasoline blend to knock is given by the octane number, with a higher value indicating greater resistance. Over the years the public has come to think of higher octane numbers as indicating higher energy/more power. That's not really true, but a detailed discussion of the topic is worthy of its own article. Suffice to say that self-ignition is a pivotal difference between gasoline and diesel engines. In a gasoline engine you don't want