> Likewise when I look at the code for well respected open source projects. It's good code in terms following accepted practices, but hard to read because there's too much of it to see where the actual "working" code is.
> A lot of the code is "defensive," i.e., type and bounds checking, trapping error conditions, etc. When I've looked at the unit tests, most of them test the defensive code.
> I tell my engineering friends: "Engineers like to over-complicate things."
I took your message to be in a half-joking tone and I mean mine in the friendliest spirit, from someone who's been where you are, in response to the half-serious part :)
I used to be an "amateur scientific" programmer like you, learned Pascal ~35 years ago, used Fortran and Delphi extensively (my field was experimental physics). At some point, I switched careers and become a "professional" programmer, working on operating systems and embedded software.
Your code simply has (more) bugs. All those unchecked bounds, uncaught error conditions, etc. Your short functions probably work fine on most inputs you give them and, if they occasionally don't, with some luck you notice and you're there to fix them (or if you're less lucky, it propagates into some calculations and results unnoticed...)
I had a hard time accepting it the first time I was told. "But that's not a bug, it's "just" an uncaught memory allocation error." Yeah, that's a bug.
That defensive code probably has bugs too, but fewer bugs. It really depends on the field and the application, and the ease of update / consequence of failure, how fewer bugs you need. For production code, that runs unattended, where uncaught errors can have bad consequences, the 10x extra code is there. That's also why most of the tests focus on those edge cases (the main path will get tested heavily every time you're running the program anyway).
I don't mean your approach is wrong for you, it may very well be best for your use cases. But that "over-complication" is there for very good reasons.
No offense taken at all. What I realized at some point is that I really didn't want to do software development, and am at a place where I have the luxury of saying that the professional devs will take my ball of crap and turn it into something that they can ship. The ball of crap only has to express and test the theory of operation well enough to guide actual product development.