c. 1300, "systematic compilation of laws," from Old French code "system of laws, law-book" (13c.), from Latin codex"systematic classification of statutory law," earlier caudex "book," literally "tree trunk," hence, book made up of wooden tablets covered with wax for writing. De Vaan traces this through Proto-Italic *kaud-ek- to PIE *kehu-d- "cleaved, separate," which he also sees as the root of cauda "tail" (see coda).
Meaning "cipher, system of signals and the rules which govern their use" (the sense in secret code) is from 1808. Code-name is from 1879 (in telegraphy). Meaning "system of expressing information and instructions in a form usable by a computer" is from 1946.
"to put into code," 1815, from code (n.). Specifically "to put into computer code" from 1947. Intransitive sense "write computer code" is by 1987. Related: Coded; coding.