[proh-gram-ing, -gruh-ming]
programming: see computer; programming language.

Language in which a computer programmer writes instructions for a computer to execute. Some languages, such as COBOL, FORTRAN, Pascal, and C, are known as procedural languages because they use a sequence of commands to specify how the machine is to solve a problem. Others, such as LISP, are functional, in that programming is done by invoking procedures (sections of code executed within a program). Languages that support object-oriented programming take the data to be manipulated as their point of departure. Programming languages can also be classified as high-level or low-level. Low-level languages address the computer in a way that it can understand directly, but they are very far from human language. High-level languages deal in concepts that humans devise and can understand, but they must be translated by means of a compiler into language the computer understands.

Learn more about programming language with a free trial on

Set of ordered instructions that enable a computer to carry out a specific task. A program is prepared by first formulating the task and then expressing it in an appropriate programming language. Programmers may work in machine language or in assembly languages. But most applications programmers use one of the high-level languages (such as BASIC or C++) or fourth-generation languages that more closely resemble human communication. Other programs then translate the instructions into machine language for the computer to use. Programs are stored on permanent media (such as a hard disk), and loaded into RAM to be executed by the computer's processor, which executes each instruction in the program, one at a time. Programs are often divided into applications and system programs. Applications perform tasks such as word processing, database functions, or accessing the Internet. System programs control the functioning of the computer itself; an operating system is a very large program that controls the operations of the computer, the transfer of files, and the processing of other programs.

Learn more about program, computer with a free trial on

Application of mathematical and computer programming techniques to the construction of deterministic models, principally for business and economics. For models that only require linear algebraic equations, the techniques are called linear programming; for models that require more complex equations, it is called nonlinear programming. In either case, models frequently involve hundreds or thousands of equations. The discipline emerged during World War II to solve large-scale military logistics problems. Mathematical programming is also used in planning civilian production and transportation schedules and in calculating economic growth.

Learn more about mathematical programming with a free trial on

Mathematical modeling technique useful for guiding quantitative decisions in business, industrial engineering, and to a lesser extent the social and physical sciences. Solving a linear programming problem can be reduced to finding the optimum value (see optimization) of a linear equation (called an objective function), subject to a set of constraints expressed as inequalities. The number of inequalities and variables depends on the complexity of the problem, whose solution is found by solving the system of inequalities like a system of equations. The extensive use of linear programming during World War II to deal with transportation, scheduling and allocations of resources under constraints like cost and priority gave the subject an impetus that carried it into the postwar era. The number of equations and variables needed to model real-life situations accurately is large, and the solution process can be time-consuming even with computers. Seealso simplex method.

Learn more about linear programming with a free trial on

Templates are a feature of the C++ programming language that allow functions and classes to operate with generic types. This allows a function or class to work on many different data types without being rewritten for each one.

Templates are of great utility to programmers in C++, especially when combined with multiple inheritance and operator overloading. The C++ Standard Library provides many useful functions within a framework of connected templates.

Technical overview

There are two kinds of templates: function templates and class templates.

Function templates

A function template behaves like a function that can accept arguments of many different types. For example, the C++ Standard Template Library contains the function template maximum(x, y) which returns either x or y, whichever is larger. maximum() could be defined like this:

  1. include

template inline const T& maximum(const T& x,const T& y) {

  if(y > x)
     return y;
     return x;

int main(void) {

  using namespace std;
  //Calling template function
  cout << maximum(3,7) << endl;         //outputs 7
  cout << maximum(3, 7) << endl;             //same as above
  cout << maximum(3.0,7.0) << endl;  //outputs 7
  return 0;

Notice that the user can use the same function for many different data types.

Template functions can be defined for arguments of any type for which a concrete function can be created by the compiler. If the data type is a class, the < operator must be defined for this example template function to work.

Template functions, which support both primitive and class types, also allow the user to utilize standard template libraries such as STL. Template libraries can leverage template functions by allowing the user of the library to define types and operators for those types.

The Standard Template Library contains complex class, which is used to represent complex numbers. However, the complex class does not define the < operator because there is no strict ordering for complex numbers. Therefore, maximum(x, y) will fail with a compile error if x and y are complex values.

Template specialization

The programmer may decide to implement a special version of a function (or class) for a certain type which is called template specialization. If a template function (or class) is specialized by a subset of its parameters then it is called partial template specialization.

For example the programmer may want to apply an ordering on complex numbers based on their distance from (0,0):

template <> inline const complex& maximum(const complex& a, const complex& b) {

   if(abs(b) > abs(a))
       return b;
       return a;

Class templates

A class template extends the aforementioned template function concept to classes. Class templates are often used to define the methods and sub-types of generic containers. For example, the STL for C++ has a linked list container called list. The statement list<int> designates or instantiates a linked-list of type int. The statement list<string> designates or instantiates a linked-list of type string.

A class template usually defines a set of generic functions that operate on the type specified for each instance of the class (i.e., the parameter between the angle brackets, as shown above). The compiler will generate the appropriate function code at compile-time for the parameter type that appears between the brackets.

Advantages and disadvantages

Some uses of templates, such as the maximum() function, were previously fulfilled by function-like preprocessor macros. For example, the following is a C++ maximum() macro:

 #define maximum(a,b) ((a) < (b) ? (b) : (a))

Both macros and templates are expanded at compile-time. Macros are always expanded inline, whereas templates are only expanded inline when the compiler deems it appropriate. When expanded inline, macro functions and template functions have no extraneous run-time overhead. However, template functions will have run-time overhead when they are not expanded inline.

Templates are considered "type-safe", that is, they require type-checking at compile-time. Hence, the compiler can determine at compile-time whether or not the type associated with a template definition can perform all of the functions required by that template definition.

By design, templates can be utilized in very complex problem spaces, where as macros are substantially more limited.

There are three primary drawbacks to the use of templates:

  1. Historically, some compilers exhibited poor support for templates. So, the use of templates could decrease code portability.
  2. Many compilers lack clear instructions when they detect a template definition error. This can increase the effort of developing templates, and has prompted the inclusion of Concepts in the next C++ standard.
  3. Since the compiler generates additional code for each template type, indiscriminate use of templates can lead to code bloat, resulting in larger executables.

Additionally, the use of the "less-than" and "greater-than" signs as delimiters is problematic for tools (such as text editors) which analyse source code syntactically. It is difficult, or maybe impossible, for such tools to determine whether a use of these tokens is as comparison operators or template delimiters. For example, this line of code:

       foo (a < b, c > d) ;

may be a function call with two integer parameters, each a comparison expression. Alternatively, it could be a declaration of a constructor for class foo taking one parameter, "d", whose type is the parametrised "a < b, c>".

Generic programming features in other languages

Initially, the concept of templates was not included in some languages, such as Java and C# 1.0. Java's adoption of generics mimics the behavior of templates, but is technically different. C# added generics (parameterized types) in .NET 2.0. The generics in Ada predate C++ templates.

Although C++ templates, Java generics, and .NET generics are often considered similar, generics only mimic the basic behavior of C++ templates. Some of the advanced template features utilized by libraries such as Boost and STLSoft, and implementations of the STL itself, for template metaprogramming (explicit or partial specialization, default template arguments, template non-type arguments, template template arguments, ...) are not available with generics.

The D programming language attempts to build on C++ by creating an even more powerful template system. A significant addition is the inclusion of the static if statement, which allows conditional compilation of code based on any information known at compile time. For example:

template Factorial(ulong n) {

   static if(n <= 1 )
       const Factorial = 1;
       const Factorial = n * Factorial!(n-1);

Also note that the !() delimiters are used rather than the <> delimiters. This prevents ambiguity in the parsing of templates.

Other significant features include typesafe variadic template functions.

T[0] max(T...)(T args) { //Simple example, assumes all arguments are of the same type.

   static assert(args.length > 1, "Insufficient arguments.");
   T[0] max = args[0];  //T[0] is the the type of the first argument, args[0] is the first argument.
   foreach(arg; args[1..$]) {  //Tuple can be iterated over and sliced like an array.
       if(arg > max) {
           max = arg;
} }
   return max;

This function will work for any number of arguments, with the foreach iteration over the tuple of arguments expanded at compile time.


Search another word or see programmingon Dictionary | Thesaurus |Spanish
Copyright © 2015, LLC. All rights reserved.
  • Please Login or Sign Up to use the Recent Searches feature