How does classic code completion work?
Visual Studio Code groups these features under the name IntelliSense and notes that the same idea also goes by "code completion", "content assist" and "code hinting" [1]. A list of suggestions appears as you type, narrows as you keep typing, and Tab or Enter inserts the selected item. Pick a method and its parameters appear; hover over it and its documentation shows up [1].
A language service drives these suggestions. It understands the language's semantics and analyses your source code to work out which variables, methods and fields are valid at that point [1]. The suggestions come from names that actually exist in the project.
What changed with AI code completion?
Tools built on language models go beyond a single name and suggest whole lines or functions. GitHub Copilot shows a suggestion as dimmed "ghost text"; Tab accepts it and Esc dismisses it [2]. Describe what you want in a code comment and Copilot can suggest code that does it. It may offer several alternatives for the same input, and you can accept just the next word or line of a suggestion [2].
Underneath sit language models trained on code. Codex was a GPT model fine-tuned on public code from GitHub, and a production version of it powered GitHub Copilot [3]. On HumanEval, a set of programming problems, Codex solved 28.8% of them while GPT-3 solved none [3].
How do the two approaches differ?
A language service suggests what is defined in your project. A language model produces code that looks likely, which may not compile or may call an API that does not exist. AI suggestions should be read and tested before they are kept.