Discounting an entire field of science like this, based on a second-hand observations, is exactly the kind of hubris the parent comment was talking about: There’s something about psychiatry and neuroscience that makes a lot of people who are good at engineering/software think that they are qualified to also be experts on the field of psychiatry.
You’re right that psychiatry and medication is a lot of trial and error, but that’s the most efficient and accurate way to determine which medications work with a patient. In a hypothetical perfect world we’d have more tools to predict ahead of time and this is an active field of study. However, nothing comes close to the speed and efficiency of just trying medications based on what has worked for many other patients with similar conditions.
Note they practitioners aren’t just guessing and hoping for the best. They are using a large body of research, clinical experience, and shared knowledge of their peers.