You also mention things going wrong in unanticipated ways - this may signal that the problematic code where errors bubble up is not problematic at all - it is called by code written by people who don't really understand what the functions do and who probably didn't write adequate tests for that - because the tests should catch the unanticipated parts. The problematic code is the one calling the parts where errors bubble up. The canary is not responsible for the gases in the mine.
While you may be right that, in order to deal with multi-million-line codebases you need static typing, I'd much rather split that codebase into smaller units that could be more easily managed.
Wearing a straitjacket is often a consequence of an underlying condition that can, sometimes, be corrected.
Sometimes software solves problems which provoke incidental complexity because of sheer size and my experience (albeit not above 500k) tells me that indeed, all bits help, also compiler enforced type checks. I would never bet my life on tests. As you write: "because the tests should catch the unanticipated parts", that's the point: tests never catch unanticipated parts by their very nature. Sometimes, by sheer luck, yes.
No, but calling a function with arguments of the wrong type is something tests would catch.
Or the compiler.
#include <stdio.h>
int main(int argc, char *argv[])
{
FILE *fp = fopen("outfile", "w");
fclose(fp);
do_something(fp);
return 0;
}
int do_something(FILE *f)
{
fprintf(f, "This should work if you know what you're doing");
}
And it won't work. struct WithOpenFile {
FILE *fp;
WithOpenFile(const char *fileName) : fp(fopen(fileName, "w")) {}
~WithOpenFile() { fclose(fp); }
};
int do_something(FILE *f)
{
fprintf(f, "This should work if you know what you're doing");
}
int main(int argc, char *argv[])
{
{
WithOpenFile file("outfile");
}
do_something(file.fp);
return 0;
}
But Lisps will happily accept this: (defun do-something (foo)
(1+ foo))
(with-open-file (file "outfile")
(do-something file))ps My hobby vaporware CL project will probably be called mudball, I'm trying to learn how to design systems with hackability and extreme flexibility in mind :)
Once the team gets big, or the code gets so big you can't hold it all in your head, any machine-enforced QC can have a major impact.
(I'm working on a very large Haskell code base now -- the parts that tend to cause trouble are the dynamically typed bits -- they can just go wrong in so many unanticipated ways, and the complexity means its almost unavoidable that devs miss things).
I'm increasingly convinced that to wrangle massive code bases, you need both heavy abstraction abilities (higher order functions, DSLs, algebraic data types, polymorphism), and very strong typing, to keep the complexity under control