Syntax is the order words go in: which word may follow which, and where. The cat sat on the mat is fine; sat the on cat mat the has the same words and no syntax at all.
In a programming language, syntax is the exact punctuation and shape the machine demands, so a missing bracket or a stray comma gives you a syntax error and nothing runs until you fix it. Grammar is the bigger subject, taking in endings, agreement and tenses, and syntax is the arrangement part of it. Word order does heavy work in English, which is why the dog bit the man and the man bit the dog are built from one set of words and mean opposite things. The adjective is syntactic, and syntactically means as far as the arrangement goes, which is a way of saying a sentence is legal even when it is nonsense.
1noungrammarThe rules for how words are arranged into phrases and sentences.~20%
“German syntax puts the verb at the end of a subordinate clause.”
2nounsyntaxThe exact form a programming language requires code to be written in.~80%
“The build failed on a syntax error in line forty.”
Shares are an estimate: a language model read 12 sentences found in the wild and placed 10 of them on a sense (2 were unclear) — a count of our sample, not a measurement of English.
Syntax comes from Ancient Greek syntaxis, made of syn, together, and taxis, arrangement, from tasso, to arrange. It reached English partly through Latin syntaxis and partly straight from the Greek. Putting words in order is arranging them together, and the Greek says that and nothing more.
Proto-Indo-European
*teh₂g-
Ancient Greek
σύνταξις
Latin
syntaxis
English, today
syntax
Built from
Partly from Latin syntaxis and partly from its etymon, Ancient Greek σύνταξις, from σύν (“together”) + τάξις (“arrangement”), from τάσσω (“to arrange”). a doublet of syntaxis.
Etymology from Wiktionary, CC BY-SA