The gist of the advice, as I understand it, is that it is more
efficient to embed Mata functions in an ado file rather than
precompile them and access them through .mo files or .mlib
libraries. Now, I am probably older than Bill and I learned to
program in Fortran on large IBM mainframes, so this advice caused my
eyebrows to head skywards since it runs completely counter to
traditional good practice.
There are many reasons for developing libraries of separate
subroutines that can be re-used or maintained more easily as discrete
bits of code rather than being embedded in one large and perhaps
poorly-documented program file. So, I assume that this advice does
not apply to the process of developing new programs. On the other
hand, I can understand that a big advantage of embedding Mata
functions in the ado file which calls them is that all of the
function names are private, thus avoiding potential conflicts with
functions with the same name that do something different.
However, I understand the advice as suggesting that Stata will
execute a program more efficiently if the production version takes
the form of a single - or small number - of ado-files with embedded
Mata functions and no associated .mo or .mlib files.
Is my understanding correct? And, if so, why? Is it just that
just-in-time compilation of Mata code is so fast that the overhead of
compiling the functions when they are first called is very small
relative to the overhead of searching for the routines in the .mo or
.mlib files? Finally, if this is best way of producing production
versions of programs, then it might be helpful to publicise the
advice as I cannot recall having seen it previously in any Stata
manual or, for exampling, in Kit Baum's book on Stata Programming.