I have studied measure theory and probability theory before, and we defined the expectation of a random variable $X$ with respect to some probability space $(\Omega,\mathcal{F},\mathbb{P})$ as the Lesbesgue integral of $X$ w.r.t. $\mathbb{P}$, that is, $$\mathbb{E}[X]=\int_{\Omega}Xd\mathbb{P}=(\lambda\otimes\mathbb{P}) \ \text{hyp}(X),$$ where $\text{hyp}(X)$ denotes the hypograph of $X$. This made sense to me, and we proved results about what happens when the random variable is discrete, admits a pdf, etc.
Now, I am reading a statistics book which isn't theoretical, which defines the expectation of $X$ in terms of the Riemann-Stieltjes integral: that is, letting $F(x)=\mathbb{P}[X\leq x]$, we have $$\mathbb{E}[X]=\int_{-\infty}^{\infty}XdF(x),$$
the Riemann-Stieltjes integral.
My question: Clearly these two must be equal, but (just looking in terms of probability theory here) does it hold for all random variables (e.g. functions of $X$) and all probability spaces? When would we prefer to use one over the other?
I suspect my book introduced the Riemann-Stieltjes version to me to avoid a bunch of measure theory, but if I am comfortable with measure theory, would I benefit from considering the measure theoretic definition of the expectation over the Riemann-Stieltjes definition?