A code is a type of legislation that purports to exhaustively cover a complete system of laws or a particular area of law as it existed at the time the code was enacted, by a process of codification. Though the process and motivations for codification are similar in different common law and civil law systems, their usage is different. In a civil law country, a Code typically exhaustively covers the complete system of law, such as civil law or criminal law. By contrast, in a common law country with legislative practices in the English tradition, a Code is a less common form of legislation, which differs from usual legislation that, when enacted, modify the existing common law only to the extent of its express or implicit provision, but otherwise leaves the common law intact. By contrast, a code entirely replaces the common law in a particular area, leaving the common law inoperative unless and until the code is repealed. In a third case of slightly different usage, in the United States and other common law countries that have adopted similar legislative practices, a Code is a standing body of statute law on a particular area, which is added to, subtracted from, or otherwise modified by individual legislative enactments.
The legal code was a common feature of the legal systems of the ancient Middle East. The Sumerian Code of Ur-Nammu (c. 2100-2050 BC), then the Babylonian Code of Hammurabi (c. 1760 BC), are amongst the earliest and best preserved legal codes, originating in the Fertile Crescent.
The Hebrew Written Torah and Oral Torah (200–220 CE) comprise the whole body of Jewish legal code and constitute the earliest and best preserved ethical code at the same time. Adopted to every field of actual day-to-day life since thousands of years, Jewish Halakha is the oldest collective body of religious laws, laws and jurisdictions still in use.
In the Roman empire, a number of codifications were developed, such as the Twelve Tables of Roman law (first compiled in 450 BC) and the Corpus Juris Civilis of Justinian, also known as the Justinian Code (429 - 534 AD). However, these codes did not exhaustively describe the Roman legal system. The Twelve Tables were limited in scope, and most legal doctrines were developed by the pontifices, who "interpreted" the tables to deal with situations far beyond what is contained therein. The Justinian Code collected together existing legal material at the time. However, it was authoritative only in the Eastern Roman Empire, and never became a contemporary legal tradition in the West.
In ancient China, the first comprehensive criminal code was the Tang Code, created in 624 AD in the Tang Dynasty. This, and subsequent imperial codes, formed the basis for the penal system of both China and other East Asian states under its cultural influence. The last and best preserved imperial code is the Great Qing Legal Code, created in 1644 upon the founding of the Qing Dynasty. This code was the exclusive and exhaustive statement of Chinese law between 1644 and 1912. Though it was in form a criminal code, large parts of the code dealt with civil law matters and the settlement of civil disputes. The Code ceased its operation upon the fall of the Qing dynasty in 1912, but significant provisions remained in operation in Hong Kong until well into the 1970s due to a peculiar interaction between it and the British common law system.
In Europe, Roman law, especially the Corpus Juris Civilis, became the basis of the legal systems of many countries. Roman law was either adopted by legislation (becoming positive law), or through processing by jurists. The accepted Roman law is usually then codified and forms part of the central Code. The codification movement gathered pace after the rise of nation-states after the Treaty of Westphalia. Prominent national civil codes include the Napoleonic Code (code civil) of 1804, the German civil code (Bürgerliches Gesetzbuch) of 1900 and the Swiss codes. The European codifications of the 1800s influenced the codification of Catholic canon law resulting in the 1917 Code of Canon Law which was replaced by the 1983 Code of Canon Law and whose Eastern counterpart is the Code of Canons of the Eastern Churches.
Meanwhile, African civilizations developed their own legal traditions, sometimes codifying them through consistent oral tradition, as illustrated e.g. by the Kouroukan Fouga, a charter proclaimed by the Mali Empire in 1222-1236, enumerating regulations in both constitutional and civil matters, and transmitted to this day by griots under oath.
The Continental civil law tradition spread around the world along with European cultural and military dominance in recent centuries. During the Meiji Restoration, Japan adopted a new Civil Code (1898), based primarily on the French civil code and influenced by the German code. After the Xinhai Revolution of 1911 in China, the new Republic of China government abandoned the imperial code tradition and instead adopted a new civil code strongly influenced by the German Bürgerliches Gesetzbuch, and also influenced by the Japanese code. This new tradition has been largely maintained in the legal system of the People's Republic of China since 1949.
Meanwhile, codifications also became more common in common law systems. For example, a criminal code is found in a number of common law jurisdictions in Australia and the Americas, and continues to be debated in England.
In the Americas, the influence of Continental legal codes has manifest itself in two ways. In civil law jurisdictions, legal codes in the Continental tradition are common. In common law jurisdictions, however, there has been a strong trend towards codification. The result of such codification, however, is not always a legal code as found in civil law jurisdictions. For example, the California Civil Code largely codifies common law doctrine and is very different in form and content from all other civil codes.
Civil codes are sometimes also found in common law systems, especially in the United States of America. However, such civil codes are often collections of common law rules and a variety of ad hoc statutes; that is, they do not aspire to complete logical coherence.