In very simple terms: a gas in a closed body is heated up on one side. The gas, which expands due to the heat, is cooled down on the other side and contracts. The expansion and contraction causes a continuous movement. The process follows the so-called PV diagram.
Stirling Free Piston.
The original Stirling engines were crankshaft driven. This principle appeared to have its limitations over time, due to seal tightness, lubrication of moving parts etc. Maintenance at regular intervals - preventive and corrective - was required. These issues do not hamper the so-called free piston engine, invented by William Beale in 1964. Applying gas bearings, natural frequencies, tightly produced parts and hermetically sealed with a linear alternator it can run in theory for an indefinitely long time.