While it's true that much more O.R. code could - and probably should, when public money paid for its development - be public, this is changing and nowadays it's increasingly more common to share the sources (e.g., on GitHub) and create a corresponding referenceable artefact (e.g., on Zenodo).
I think the main reason that hinders sharing is poor code quality.
Indeed, I had to work with code by colleagues and I wanted to carve my eyes out; surely, this feeling was reciprocated by colleagues who worked with my code.
It is sometimes easier to just re-implement some algorithm than try to understand, debug, or extend someone else's code.
Why is, then, code quality so low? Why do we have script-like write-only one-use code, rather than more curated libraries, as is the case in the ML community?
Here are a few plausible reasons:
- Few OR scientists are computer scientists and even fewer are software engineers. We don't have this training in our curricula. Not everyone collaborates on large software projects; rather, we mostly write for ourselves. We use our own conventions and guidelines, often based in myths and second-hand factoids, rather than in truth and measurable metrics. Worse, we perpetuate these legends teaching them to our students.
- We see code as a disposable tool, a temporary detour from the interesting scientific juice, a distraction from the publishable goodies, a necessary evil we have to cope with as quickly as possible. For many of us code is just a way to prove that some conjecture was true ("Doing X and Y should produce better results than the current literature"). We see limited future use for our code, even though we are often proven wrong in this respect.
- Even if we saw clearly the value of reusable, maintainable, well-documented, publicly-shared code, the publish-or-perish culture dominant in modern academia gives all the wrong incentives: every hour of time I spend to increase code quality, I could have spent working on one more publication and getting tenure.
I feel the last point is the most important: sharing code or producing widely used software libraries gives almost no benefit, and a lot of costs.
Until it will be considered as a service to the community and it will be taken into account for promotions and hiring, very few O.R. scientists will devote time to producing maintainable, well-structured, clear, performant, bug-free code which is worth being shared.