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
  • SD-WAN security

    SD-WAN security refers to the practices, protocols and technologies protecting data and resources transmitted across ...

  • net neutrality

    Net neutrality is the concept of an open, equal internet for everyone, regardless of content consumed or the device, application ...

  • network scanning

    Network scanning is a procedure for identifying active devices on a network by employing a feature or features in the network ...

Security
CIO
  • strategic management

    Strategic management is the ongoing planning, monitoring, analysis and assessment of all necessities an organization needs to ...

  • 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, ...

HRSoftware
  • director of employee engagement

    Director of employee engagement is one of the job titles for a human resources (HR) manager who is responsible for an ...

  • digital HR

    Digital HR is the digital transformation of HR services and processes through the use of social, mobile, analytics and cloud (...

  • employee onboarding and offboarding

    Employee onboarding involves all the steps needed to get a new employee successfully deployed and productive, while offboarding ...

Customer Experience
  • chatbot

    A chatbot is a software or computer program that simulates human conversation or "chatter" through text or voice interactions.

  • 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.

Close