What is the origin of the "eye for an eye"/lex talionis principle?

by Monkeyavelli

I've read that, though it may seem harsh and cruel by modern standards, the legal concept of an "eye for an eye" was actually a way to limit violence by creating a mechanism that ensured that a punishment would be no greater than the crime.

Is this correct? What do we know about the origin of this principle? Also, is this idea something only found in Western traditions descended from Babylonian jurisprudence, or do you find expressions of the idea in early Eastern societies?

Abastado

The Hammurabi Code is the earliest example we have of this method of justice.