Browse Definitions :
Definition

primitive (programming)

What is a primitive in computer programming?

In computer programming, a primitive is one of a set of fundamental language elements that serve as the foundation for a programming language. Each language supports a core set of primitives that provide the basic building blocks for instructing a processor on how to carry out specific operations. Primitives vary between languages and platforms based on factors such as processor architecture, programming language, and the programmatic level (e.g., machine code versus a high-level language such as Java).

How are primitives used in programming?

Computer processors do not understand source code, whether an assembly language or high-level programming language. They can only understand machine language (binary code consisting of 0s and 1s), and the machine code must conform to the processor's instruction set architecture (ISA), which is part of the processor's microarchitecture. The ISA defines the primitives that are supported by the processor, as well as how to build instructions for that processor. In effect, the primitives indicate what the processor is capable of doing, such as adding data or loading it into a specific location in memory.

Each primitive is associated with a specific operation code (opcode). An opcode is the binary equivalent of the primitive that tells the processor what operation to carry out. The opcode is typically accompanied by operands, which represent the data to be manipulated by the primitive. Operands are defined as part of an instruction in which primitives serve as the operator. As with ISAs, opcodes are specific to the processor architecture. For example, an add primitive might translate to an operand such as 0011, 0100, 0110 or another set of bits, depending on the underlying architecture.

Primitives also have their counterparts in assembly languages, which are also specific to the processor architecture. An assembly language is a type of source code that, like high-level programming languages, is written in plain text and is human readable.

Assembly languages and primitives

An assembly language uses mnemonics to represent an ISA's primitives. Mnemonics are short descriptive words that serve as a foundation for building instructions for the processor. In the x86 assembly language, for example, the term add is a mnemonic that means add, while sub means subtract and inc means increase by one. An assembler translates the mnemonic-based instructions to machine code, according to the ISA's specifications.

Microcode and primitives

Some processors use microcode to carry out their operations. Microcode is integrated into the microarchitecture and is considered an even lower-level language than machine code. As such, it might break down primitive operations defined in the machine code into smaller instructions. Some sources consider these smaller instructions to be microcode primitives. However, there is no real consensus as to whether these operations qualify as their own types of primitives. As with many aspects of technology, the term primitive is sometimes used in different ways to describe similar or dissimilar concepts.

High-level programming languages and primitives

High-level programming languages are sometimes discussed in terms of having their own primitives. In this case, primitives represent the smallest units of programming logic available to a specific language. The term primitive in this context is usually discussed in relationship to data types. For example, the Java data types int, char and Boolean are all considered primitive types. Other Java types are built on the primitive types.

Table showing Java's primitive types
Table highlighting Java's primitive types in order of descending upper range limit.

The term primitive might also be used in other ways in a high-level programming language. For example, it might refer to operators, expressions, procedures or other language elements. Regardless of how it's used, a primitive in a high-level language does not necessarily have a direct counterpart in machine language. For example, adding two numbers in a high-level language might represent a single primitive operation in that language, but when translated to machine code, that operation will likely require multiple lower-level primitive operations.

The term primitive is also used in computer graphics to refer to an image element -- such as an arc, a square or a cone -- from which more complicated images can be constructed.

Learn about in-demand programming languages developers should get to know.

This was last updated in April 2023

Continue Reading About primitive (programming)

Networking
  • local area network (LAN)

    A local area network (LAN) is a group of computers and peripheral devices that are connected together within a distinct ...

  • TCP/IP

    TCP/IP stands for Transmission Control Protocol/Internet Protocol and is a suite of communication protocols used to interconnect ...

  • firewall as a service (FWaaS)

    Firewall as a service (FWaaS), also known as a cloud firewall, is a service that provides cloud-based network traffic analysis ...

Security
  • identity management (ID management)

    Identity management (ID management) is the organizational process for ensuring individuals have the appropriate access to ...

  • fraud detection

    Fraud detection is a set of activities undertaken to prevent money or property from being obtained through false pretenses.

  • single sign-on (SSO)

    Single sign-on (SSO) is a session and user authentication service that permits a user to use one set of login credentials -- for ...

CIO
  • IT budget

    IT budget is the amount of money spent on an organization's information technology systems and services. It includes compensation...

  • project scope

    Project scope is the part of project planning that involves determining and documenting a list of specific project goals, ...

  • core competencies

    For any organization, its core competencies refer to the capabilities, knowledge, skills and resources that constitute its '...

HRSoftware
  • recruitment management system (RMS)

    A recruitment management system (RMS) is a set of tools designed to manage the employee recruiting and hiring process. It might ...

  • core HR (core human resources)

    Core HR (core human resources) is an umbrella term that refers to the basic tasks and functions of an HR department as it manages...

  • HR service delivery

    HR service delivery is a term used to explain how an organization's human resources department offers services to and interacts ...

Customer Experience
  • martech (marketing technology)

    Martech (marketing technology) refers to the integration of software tools, platforms, and applications designed to streamline ...

  • transactional marketing

    Transactional marketing is a business strategy that focuses on single, point-of-sale transactions.

  • customer profiling

    Customer profiling is the detailed and systematic process of constructing a clear portrait of a company's ideal customer by ...

Close