Is a PhD worth it?

In 2008, when I started my PhD, data science and machine learning were niche topics - not nearly as popular as today.

I worked on Monte Carlo simulations of differential equations to understand variability in biological systems at the Tidor Lab at MIT. The statistics and programming I had to do paved the way for my Machine Learning career. But was that worth it? Should anyone do a PhD if they don't want to be an academic?

The most relevant counterfactual is to do an MSc, and starting your professional career earlier. Here some reflections about a PhD:

If you do go for a PhD some of the upsides may be:

A PhD is a long commitment. We know it's hard to quit a PhD project midway, and most people stay for the duration (I admire those who changed course). Four or more years is a huge opportunity cost to pay.

If you embark on a PhD consider the alternatives, and beware not to do a PhD because you're expected to - I partially did this and I was lucky.

In any case, learning is a lifelong pursuit. A PhD is a unique way of doing it with many advantages, but there's room for all kinds of training in life. Comments are most welcome.