Not a fair comparison because one is exposed to real life market forces vs. academic inertia.
ReactJS devs will retrain when the market dies. Professors still publishing theories/experiments costing large amounts of public monies better spent elsewhere.
There is no more inertia in the academic sector than in the software developer sector.
You have tons of software developers that cling to their preferences for ages. They have their beloved language, or beloved paradigm, and they will invent any excuse to explain how relevant it is. It is also visible with current LLM, where there are plenty of software developer islands where they blanket ban LLM usage as an emotional response. There is a big contrast with the academic sector where the most sceptical people did not blanket banned it, but find way to put guardrails (and I'm sure you can find anecdotal places that are emotionally against LLM in academia, but it is an order of magnitude lower than in the software development sector).
Same about "real life market forces". Especially when at the same time people criticize, correctly, the "publish or perish" hyper-competitiveness problem in academia. The reality is that a physicist need to retrain plenty of time, probably as much as a ReactJS dev. But that reality flies high above the head of people who jump into the first caricatural idea they have about the sector.
As for "costing large amounts of public monies", you don't seem to even know what you are talking about. String Theory probably costs society way less than plenty of other useless things, and still managed to provide very useful tools that are used in mathematical physics outside of string theory (not that I'm saying it was worth it, but it is just not fair to pretend that they did not produce anything). In contrast, the software development sector has a huge contribution on enshittification, stealing user data, making porn, creating social media addiction and creating financial bubbles that splash in the whole economy. Between the two, there is clearly one that is way more toxic on the society.
Don't get me wrong, I'm not interested in "taking side" and particularly defending physicists. I'm sure they are making mistakes and wasting money, like any other sectors, and that we still should find these places and fix them. But your depiction is so caricatural that I had to rebalance the situation by reassessing the facts.