An idiom (Latin: idiomī, "special property", from Greek: ἰδίωμα – idíōma, "special feature, special phrasing, a peculiarity", f. Greek: ἴδιος – ídios, "one's own") is a phrase or an expression that has a figurative, or sometimes literal, meaning. Categorized as formulaic language, an idiom's figurative meaning is different from the literal meaning. There are thousands of idioms, occurring frequently in all languages. It is estimated that there are at least twenty-five thousand idiomatic expressions in the English language.
Many idiomatic expressions, in their original use, were not figurative but had literal meaning. Also, sometimes the attribution of a literal meaning can change as the phrase becomes disconnected from its original roots, leading to a folk etymology. For instance, spill the beans (meaning to reveal a secret) has been said to originate from an ancient method of democratic voting, wherein a voter would put a bean into one of several cups to indicate which candidate he wanted to cast his vote for. If the jars were spilled before the counting of votes was complete, anyone would be able to see which jar had more beans, and therefore which candidate was the winner. Over time, the practice was discontinued and the idiom became figurative.
However, this etymology for spill the beans has been questioned by linguists. The earliest known written accounts come from the USA and involve horse racing around 1902–1903, and the one who "spilled the beans" was an unlikely horse who won a race, thus causing the favorites to lose. By 1907 the term was being used in baseball, but the subject who "spilled the beans" shifted to players who made mistakes, allowing the other team to win. By 1908 the term was starting to be applied to politics, in the sense that crossing the floor in a vote was "spilling the beans". However, in all these early usages the term "spill" was used in the sense of "upset" rather than "divulge". A stackexchange discussion provided a large number of links to historic newspapers covering the usage of the term from 1902 onwards.