G-code and M-code are the two types of code in CNC programming. G-code controls the machine's actions, for example, how it moves, when it moves, how fast it moves, the path it takes, etc. M-code controls other miscellaneous factors that surround the machine's capabilities.