I guess this commonly occurs in many fields at a certain level of seniority - the "managing a large system involving many people" aspect can dominate the domain-specific part, be it software engineering, accounting, manufacturing etc. As such I'm really glad I chose medicine rather than SWE (even though I've been writing and loving code for >35 years, and it was a real toss-up when I went to uni) because:
1. You can still stay very hands on, even as a senior clinician, especially procedurally.
2. If you so choose, there's a lot of variety in what you find yourself doing as a doctor (my mix looks like making clinical decisions / talking to patients / families / doing procedures / performing and interpreting ultrasound / going to other hospitals to retrieve super sick patients and bringing them back in ambulances / mentoring / teaching / coding / managing a clinical service / etc - but there are lots of other options too). I'm not sure if this kind of variety is as easy to arrange as a SWE? (though I suspect I'm about to be corrected, thanks in advance.) Variety is quite important if you're easily bored, which is a common problem for bright people.
3. Although AI is coming to all fields, I do think the impact will look more like "better tools", rather than "job replacement", or "vast reduction in number of people needed", for longer in medicine (at least in my area). As a breadwinner this is a not inconsequential consideration.
Hope you find the career you love, and that it leverages the work and study you've already done in some way.
I can relate; I chose Wall Street (the finance side, not the IT side) and now work for myself. While I used and use my tech skills every day, I have never wanted to write code for money. <https://news.ycombinator.com/item?id=36027171>
Your medical domain knowledge can be a very big asset. Where are you based ?
In reverse the guy that took my tonsils out started out as a software developer and hated that work in the corporate world. He went back to school and became an ENT surgeon and is great at it. He has his own practice and is doing very well. The trick is that he realized he hated it while still in his 20s and had the balls to spend a ton of money starting over in an unrelated career. I am so envious.
I got advanced with Microsoft Excel over the years, then started learning Python in my first clinic after graduation to automate some stuff the front desk was doing every day. Didn't know anything -- what exactly Python was (my friend told me to learn it based on what I wanted to do), what front end or back end were, etc. But I started and quickly fell in love with it. A little over two years later, I'm still programming almost every day, currently building a full stack JS-based web app of my own with modern technologies (T3 stack, MUI design system, etc.), and have already built a couple others. Still loving it as much or possibly more than when I first fell in love with it, as I become more “powerful”, capable, and efficient with experience/knowledge.
I realized that while I always enjoyed learning about biology/science (and actually just anything… math, graphic design, etc. etc.), and even optometry while in school, the actual day-to-day life of a clinician is not very enjoyable for me, or at least not the right fit for me. In a more pessimistic light, you could describe it as a combination of adult babysitting and assembly line work, while also often being behind schedule. My mind/sense of satisfaction is much more suited for engineering type work -- continuous learning, problem solving, detail-oriented work, etc. (but it took me time and experience to discover that). That reality stressed me out for a while, having “wasted” all of that time and money, but I’ve been learning to handle that while also realizing that I can still make big career changes if I put in the required hard work (which I've done before) to make them happen.
I'm in my early 30s, and while I do plan on fulling transitioning to SWE in the near-ish future, having optometry as a default or backup is actually nice. It pays well overall, is decently flexible, and both of those things allow me to currently be part-time while I work on my programming. Not only that, but I now have a unique perspective and experience, and am the "expert" in the optometry niche, so I know where there are good opportunities for new software AND intricacies about how the UX should be for the end user. The app(s) I’m currently working on are optometry-oriented, and having full control over building them feels very rewarding so far. Also, if I do make the transition to SWE and I end up not being able to find positions or settings that end up being satisfying enough to make the career change feel worth it ("the grass is always greener...", "you don't know what you don't know", reality checks, etc.), I can default back to optometry and continue doing my programming on the side either perpetually or until the right thing does come up.
Main points: if you became a doctor, you can (still) become a SWE. Your time becoming a doctor was highly unlikely to be completely wasteful. Just another fyi personal perspective/experience. I love programming.