I have a master's degree in software engineering. I honestly never felt that the two years to do my master's degree added much on top of my bachelor's degree that I couldn't just as well have learnt in two years of working in the industry instead. To be fair, I think the content of my bachelor's degree was quite good, setting me up with a foundational understanding of algorithmics, program analysis, interpreters, processors, AI (no ML, this was pre-deep-learning), concurrency, networking and linear algebra (and probably other topics that I don't even think of, but just take for granted). There's a bunch of things like that, where I think fully self-taught coders might tend to miss out on a depth of knowledge that can be useful as a foundation in your understanding of computing. But setting up that foundation doesn't need to take more than a couple years at most, and after that it's much more important to learn the trade, the tools, the techniques, the best practices, that a real-world programing job is the best way to learn.
So at the end of the day, whether a master's degree is worth it, I think depends on whether you've got a good enough foundation already - if you have that (from a bachelor's degree or otherwise) then a master's degree only really makes sense if you want your career to target the kinds of companies (typically enterprise) where where there's a bias toward promoting mostly people with master's degrees.
In OPs example, they have a bachelor's degree in physics, so I think it makes sense to add a couple years of computer science on top.
The major hurdle in a Master's degree is the thesis. Spending half a year writing and defending a scientific work requires and trains skills that are usually not acquired in the industry. Master's degrees that do not require a thesis defense are imo not really "master's" degrees since the student has not demonstrated "mastery" over any particular subject.
So at the end of the day, whether a master's degree is worth it, I think depends on whether you've got a good enough foundation already - if you have that (from a bachelor's degree or otherwise) then a master's degree only really makes sense if you want your career to target the kinds of companies (typically enterprise) where where there's a bias toward promoting mostly people with master's degrees.
In OPs example, they have a bachelor's degree in physics, so I think it makes sense to add a couple years of computer science on top.