On the first law of thermodynamics