Suppose in a piston in which there is a gas, the gas exerts pressure P on surroundings, whereas the surrounding exerts a pressure $P[ext]$ on the gas.
In order for the gas to expand, P must be greater than P[ext]. So far I understand. Suppose initially that $P>P[ext]$ and the gas expands until $ P=P[ext]$ This is what I don't understand is that when you calculate the work done by the gas, you use the external pressure and not the gas pressure. This makes no sense to me. After all, if you calculate the work done on something, you should use the force or pressure applied on that object, or not the other way around, correct? So why do we use external pressure instead of internal pressure when calculating the work done by the gas?