Resource encoder and manager for programs written in D2