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
  • subnet (subnetwork)

    A subnet, or subnetwork, is a segmented piece of a larger network. More specifically, subnets are a logical partition of an IP ...

  • Transmission Control Protocol (TCP)

    Transmission Control Protocol (TCP) is a standard protocol on the internet that ensures the reliable transmission of data between...

  • secure access service edge (SASE)

    Secure access service edge (SASE), pronounced sassy, is a cloud architecture model that bundles together network and cloud-native...

Security
  • cyber attack

    A cyber attack is any malicious attempt to gain unauthorized access to a computer, computing system or computer network with the ...

  • digital signature

    A digital signature is a mathematical technique used to validate the authenticity and integrity of a digital document, message or...

  • What is security information and event management (SIEM)?

    Security information and event management (SIEM) is an approach to security management that combines security information ...

CIO
  • product development (new product development)

    Product development -- also called new product management -- is a series of steps that includes the conceptualization, design, ...

  • innovation culture

    Innovation culture is the work environment that leaders cultivate to nurture unorthodox thinking and its application.

  • technology addiction

    Technology addiction is an impulse control disorder that involves the obsessive use of mobile devices, the internet or video ...

HRSoftware
  • organizational network analysis (ONA)

    Organizational network analysis (ONA) is a quantitative method for modeling and analyzing how communications, information, ...

  • HireVue

    HireVue is an enterprise video interviewing technology provider of a platform that lets recruiters and hiring managers screen ...

  • Human Resource Certification Institute (HRCI)

    Human Resource Certification Institute (HRCI) is a U.S.-based credentialing organization offering certifications to HR ...

Customer Experience
  • contact center agent (call center agent)

    A contact center agent is a person who handles incoming or outgoing customer communications for an organization.

  • contact center management

    Contact center management is the process of overseeing contact center operations with the goal of providing an outstanding ...

  • digital marketing

    Digital marketing is the promotion and marketing of goods and services to consumers through digital channels and electronic ...

Close