latex how to write bar: \bar versus \overline. \overline is more adjusted to the length of the letter, the subscript or the superscript than \bar

Latex how to write bar: \bar

$$\bar{X}$$
\[\bar{X}\]

Latex how to write bar: \overline

$$\overline{X}$$
\[\overline{X}\]

Latex how to write bar: \bar versus \overline

$$\bar{X} \overline{X}$$

$$\bar{X_n}\overline{X_n}$$

$$\bar{XY} \overline{XY}$$

$$\bar{X^\alpha} \overline{X^\alpha}$$
\[\bar{X} \overline{X}\] \[\bar{X_n}\overline{X_n}\] \[\bar{XY} \overline{XY}\] \[\bar{X^\alpha} \overline{X^\alpha}\]

We can clearly see that \overline is more adjusted to the length of the letter, the subscript or the superscript than \bar