G-code is the common name for the most widely used numerical control program language. G-codes are also called as preparatory codes, and are any word in a CNC program that begins with the letter “G”. G-code’s programming environments have evolved in parallel with those of general programming from the earliest environments like writing a program with a pencil or typing it into a tape puncher to the latest environment that stack CAD, CAM and richly featured G-code editors.
Generally it is a code telling the machine tool what type of action to perform, such as:
• Rapid Move
• Controlled feed move in a straight line or arc
• Series of controlled feed moves that would result in a hole being bored, a work piece cut(routed) to a specific dimension, or decorative profile shape added to the edge of a work piece
• Set tool information such as offset
G-code began as a limited type of language that lacked constructs such as loops, conditional operators, and programmer-declared variables with natural-word-including names (or the expressions in which to use them). It was thus unable to encode logic; it was essentially just a way to “connect the dots” where many of the dots’ locations were figured out longhand by the programmer. The latest implementations of G-code include such constructs, creating a language somewhat closer to a high-level programming language. The more a programmer can tell the machine what end result is desired, and leave the intermediate calculations to the machine, the more s/he uses the machine’s computational power to full advantage.