Therein lies the problem with software. It’s common enough now that the lab scientists can write their own code. They may need a few dedicated programmers but most of the work is not writing the code. So instead we all keep optimizing news feeds.
Software launches and lands rockets. You think JPL just had a couple of rocket scientists writing some python scripts on the side for the perseverance mission?
But I agree Facebook has a ridiculous amount of engineering potential wasted on a pretty useless problem (serving ads even better!)
It's easy to get an entry level job as a programmer that pays very well, and you will be taught how to be an experienced programmer on the job.
Once you are an experienced programmer in a software company, you are earning a lot, and moving out of the software industry, where the prima-donna employees are physicists or engineers, you generally take a pay cut. A fusion company isn't going to hire an entry level programmer who hasn't proven himself.
So, to answer the question more explicitly, you need to be willing to follow your interests and not maximize the bottom line. This is my 28th year as a software engineer, and I've seen this pattern countless times. I've done the follow my interests, and also follow the money jobs, and prefer the respective good aspect of each approach over the other.
In my experience, there is quite a bit of untapped potential for applying engineering/cs/ml lessons in less traditional domains - not despite, but precisely because the other scientific disciplines are embracing and leveraging computation more.
I'm happy to elaborate on a more private channel, email/twitter is in the profile.
Source: Cofounded a startup in comp.bio space ~3.5 years ago, been busy supercharging our scientists and increasing pace of innovation and haven't really ran out of ideas yet.