Programming language
A programming language is a language people create to write computer programs. It helps people write software in a way that others can read and understand.
Before a program can run, it needs an implementation. There are two main ways to do this. In compilation, a program is changed into machine code before it runs. In interpretation, a program is run step by step, right away. Some systems mix these two ideas, using methods such as just-in-time compilation and bytecode interpreters.
The way programming languages are designed has been strongly shaped by computer architecture. Most imperative languages were built around the common von Neumann architecture. Early programming languages were closely tied to the hardware of the computer. Modern languages often hide these hardware details through abstraction. This makes it easier for people to make good software without as much effort. Languages like this are called high-level languages.
Relation to natural languages
Programming languages are a bit like natural languages because both help people share ideas. Programs are usually easy for people to read and can express complex ideas, but these ideas only work within the world of computing. The term computer language is sometimes used in place of "programming language," though some people say they are different. Some say programming languages are part of computer languages. Others use "computer language" for any language used in computing that is not a programming language. Some think of a programming language as a plan for programming an abstract machine, and a computer language as the part that runs on a real computer with limited hardware.
John C. Reynolds says that a formal specification language is a programming language, just like any language meant to be run by a computer. He argues that some text and picture inputs that control how a computer behaves are also programming languages. He adds that many mistakes in these inputs happen because people do not understand programming language ideas.
History
Main article: History of programming languages
The first programmable computers were built in the 1940s, and the first programming languages came with them. The earliest computers were programmed in first-generation programming languages (1GLs), called machine language. It was very hard to find and fix mistakes in machine language. Programs written in it were not portable between computer systems. Assembly languages (or second-generation programming languages, or 2GLs) were made to be easier for people to understand, but they did not make programs more portable. At first, computers were rare and expensive, while people's work was cheaper, so languages close to the hardware were preferred. Later, high-level programming languages (third-generation programming languages, or 3GLs) hid many of the hardware details. This let algorithms be written in a way that people could understand more easily. In 1957, Fortran was created. It is often seen as the first compiled high-level programming language, and it is still used in the twenty-first century.
Around 1960, the first mainframes were built. Only specialists could use them, and they cost a great deal. Data and instructions were entered using punch cards. After the microprocessor was invented, computers became much cheaper in the 1970s, and newer languages let people interact with computers more easily. Lisp, created in 1958, was the first functional programming language. It was widely used for artificial intelligence work for many years. Prolog, designed in 1972, was the first logic programming language.
In the 1980s, the personal computer changed how programming languages were used. C++, a superset of C, was introduced. In the 1990s, the fast growth of the Internet and the World Wide Web led to new languages for web pages and networking. Java became very successful. Python, JavaScript, PHP, and Ruby became popular scripting languages. After 2010, new languages such as Rust, Go, Swift, Zig, and Carbon appeared. Some languages, like Scratch and LabVIEW, are visual programming languages. Blockly by Google helps developers build new visual languages. Many game engines, like Unreal and Unity, support visual scripting.
Definition
A language can be defined by its syntax (form) and semantics (meaning). It is often defined with a formal language specification.
Main article: Syntax (programming languages)
A programming language's form is its syntax. Most programming languages are text. They use words, numbers, and punctuation, much like written languages. Some languages are graphical and use pictures and connections between symbols instead. The syntax tells us which combinations of symbols make a correctly written program. It is usually described with patterns and grammar rules.
The meaning of a combination of symbols is called semantics. A program can be written correctly and still have no clear meaning. It can also cause an error or undefined behavior. Even a well-defined program may do something its writer did not plan. Static semantics checks rules before a program runs, such as making sure names are declared before they are used. Dynamic semantics describes how a program's parts should act when it runs.
Main article: Semantics (programming languages)
Features
Main articles: Data type, Type system, and Type safety
See also: Primitive data type
See also: Concurrent computing
Main article: Exception handling
A language gives a programmer tools to build software. A type system decides which kinds of data exist and what type each expression has. It also sets how type equivalence and type compatibility work. A data type is a group of allowed values and the actions you can do with them. In type theory, a language is fully typed when every action says what data it works on. An untyped language, like most assembly languages, lets any action work on any data. Few languages are fully typed, but most have some typing. Mixing up types can cause unexpected results. So type checking often finds these type errors when the program is built, at compile time. With strong typing, these errors can almost always be found, unless a variable is cast to another type on purpose. Weak typing allows automatic changes between types, called type coercion. Because of this, fewer errors get caught. Common types include integers, floating point numbers for real numbers that are not whole, and Boolean, which is true or false. A character is usually one byte, which is enough for all ASCII characters. Some languages use a primitive type. Storing a number that is too big for its type causes integer overflow. Negative numbers are often shown with twos complement, though ones complement is also used. Other types include arrays, strings, lists, associative (unordered) arrays, records, tuples, and pointers. Pointers store memory addresses on the heap. The simplest user-defined type is an ordinal type, often called an enumeration. Since the mid-1980s, most languages also support abstract data types. In these, the details are hidden from the user behind an interface. This data abstraction can make code more reliable and less complex. It can also reduce name collision and let the data structure change without the user's code changing.
In static typing, types are decided before a program runs. Many languages require programmers to write the types out. Some can infer them from context instead. This implicit typing can let errors go unnoticed. Full type inference has mostly been linked with functional languages such as Haskell and ML. With dynamic typing, the type belongs to the value, not the variable. This means one variable can hold different types. This is flexible, but it is less reliable. Some languages allow a union type that can hold any kind of value. Many languages can run several instructions at once, which is called concurrency. Languages such as Python and Ruby are interpreted languages. They do not support using several processors at the same time. Other languages manage shared data with semaphores, a monitor, or message passing between parts of a program. Many languages also have exception handlers. These respond to runtime errors. They can stop the program and hand control to the operating system, or they can let the program continue near the error. Handling errors well can slow a program down, so some languages, like C, skip certain checks.
Design and implementation
Computer design has strongly shaped how programming languages are built. Imperative languages are the most commonly used type. They were designed to work well on von Neumann architecture, the most common type of computer architecture. In this design, the memory stores both data and instructions. The CPU that carries out instructions is separate, so data must move back and forth. The main parts of these languages are variables, assignment, and iteration. Iteration works better than recursion on these machines. Many languages have been made from scratch, changed to meet new needs, or combined with other languages. Many have also fallen out of use. In the 1950s, people wanted one language for all machines and uses. By the early 1960s, this idea was dropped because different purposes needed different things.
Good languages are easy to read, easy to write, and reliable. Early languages focused more on efficiency than on readability. Since the 1970s, readability has become more important. Having several ways to get the same result can make code harder to read. Overloading operators, where one symbol has many meanings, can also make code harder to read. Keeping the number of things to learn small is called orthogonality. Easy syntax and clear special words also help. Writing code is easier with abstraction, which hides details. Expressivity allows shorter programs. Most languages also come with a standard library of common functions. For reliability, Type checking, exception handling, and limited aliasing can help. Aliasing means several names point to the same memory. Good design often involves tradeoffs. For example, some reliability features can slow programs down. Natural-language programming has been suggested as a way to avoid special programming languages, but this goal is still far off. Edsger W. Dijkstra believed a formal language is essential to prevent meaningless constructs. Alan Perlis also had doubts about the idea.
A language's specification is a document that users and implementors use to agree on whether a piece of source code is a valid program and what it should do. A specification can take several forms. It may clearly define the language's rules, written in natural language, as in the C language. It may also use a formal semantics, as in Standard ML and Scheme. It may describe how a translator for the language behaves, as in the C++ and Fortran specifications. Or it may be a reference or model implementation, sometimes written in the language being specified, such as Prolog or ANSI REXX.
Implementing a language means turning a program into machine code that the hardware can run. This often needs help from the operating system. The most common approach in production code is a compiler. A compiler translates source code through an intermediate language into machine code called an executable. Compiled programs run faster than programs made with other methods. Some compilers provide optimization to reduce memory or computing use when the executable runs, though this makes compiling take longer. Another method is an interpreter, which translates each line into machine code just before it runs. This can make debugging easier. However, interpreted programs run 10 to 100 times slower than compiled ones. Hybrid methods combine some benefits of both. For example, just-in-time compilation compiles software ahead of time into an intermediate language, and then into machine code just before it runs.
Proprietary languages
Most of the commonly used programming languages have open rules and free tools. Many others are proprietary. This means that only one company provides the tool for using them, and that company may claim the language as its own property. These languages are often domain-specific languages or internal scripting languages for a single product. Some are used only inside a company, while others are available to outside users.
Some languages are part open and part proprietary. For example, Oracle Corporation claims proprietary rights to some parts of the Java (programming language) language. Microsoft's C# language has open versions of most of its parts, but its Common Language Runtime (CLR) is closed. Many proprietary languages are still widely used, such as MATLAB, VBScript, and Wolfram Language. Some languages have changed from closed to open. Erlang, for example, was first the internal programming language of Ericsson. Open source programming languages are especially helpful for open science work, because they support replication and the sharing of code.
Use
Thousands of programming languages have been made, mostly for computers. Single software projects often use five or more. Programming languages must be much more exact than everyday speech. People can make small mistakes and still be understood, but computers "do exactly what they are told to do." They cannot guess what a programmer meant. The language, the program, and its inputs must together describe exactly how the program will work when it runs. To share an idea with people without that exactness, pseudocode mixes everyday language with code. A programming language gives a clear way to describe data and the actions that can be done with it automatically. A programmer uses the abstractions in a language to show ideas. These are built from the simplest available parts, called primitives. Programming means joining these parts together to make new programs or change existing ones. Programs may be executed in a batch process with no person involved. Or a user may type commands in an interactive session of an interpreter. A language that runs its commands through an interpreter, such as a Unix shell or other command-line interface, without compiling, is called a scripting language.
It is hard to say which programming language is used the most. "Usage" can be measured in different ways, such as programmer hours, lines of code, or CPU time. Some languages are good for certain jobs. For example, COBOL is still used in company data centers, often on large mainframes. Fortran is used in science and engineering. Ada is used in aerospace, transportation, the military, real-time, and embedded systems. C is used in embedded systems and operating systems. Popularity has been measured by counting job ads, books sold, lines of code, and web searches. Each way of measuring has its own limits. Stackify.com listed the ten most popular languages as Java, C, C++, Python, C#, JavaScript, VB .NET, R, PHP, and MATLAB. As of June 2024, the top five languages on the TIOBE index were Python, C++, C, Java, and C#. According to staff at IEEE Spectrum, today's most popular languages may stay on top because of how AI works. This makes it harder for new languages to become popular.
Dialects, flavors and implementations
A dialect of a programming language or a data exchange language is a small change or addition to the language that does not change its basic nature. Some languages, such as Scheme and Forth, have standards that some builders feel are not good enough, so they change the rules and make a new dialect. Sometimes a dialect is made for a domain-specific language, which is often a smaller version of the language.
In the Lisp family, most languages that use basic S-expression writing and Lisp-like meaning are called Lisp dialects. They can be very different from each other, such as Racket and Clojure. Because one language often has many dialects, it can be hard for a beginner to find the right guides. The BASIC language has many dialects.
Classifications
Further information: Categorical list of programming languages
Programming languages can be grouped into types, though the groups sometimes overlap. Imperative programming languages follow a sequence of steps in order, and most of the popular languages are this type. Functional programming languages work by applying functions to the inputs they are given. Many researchers like them for being simple and elegant, but they have not been widely used because they can be slow.
In a logic programming language, the software decides the order in which the instructions run, not the programmer. Object-oriented programming (OOP) has features such as data abstraction, inheritance, and dynamic dispatch. Most popular imperative languages and some functional languages support OOP. A markup language is not a programming language on its own, but it may work together with one. Some special-purpose languages are hard to compare with other programming languages.

Quiz time!
4 questions about Programming language
What is a programming language?
Pictures
Keep exploring
This article is a child-friendly adaptation of the Wikipedia article on Programming language, available under CC BY-SA 4.0.
Images from Wikimedia Commons. Tap any image to view credits and license.
