Q:

Where does "open -b bundle_indentifier" get path to program from?

For example i run in console "open -b com.apple.dt.Xcode", how does open determine what program to launch?

A:

If you want  path to program, you can use applescript.   
  osascript -e "POSIX path of (path to application id \"com.apple.dt.Xcode\")"

