When I launch kdb with a directory, what exactly happens on start up and in what order?

The short answer is, q initializes itself, loads data, then code.

The exact sequence is as follows:

  1. load $QHOME/q.k
  2. load $QINIT/q.q or $QHOME/q.q
  3. load tables contained in /directorypath
  4. load scripts /directorypath/*.q (and *.k or .s) in alphabetical order