Blog

Ryan Moscoe

Software Engineer | AI Prompt Engineer | Ninja

The Programming Language Spectrum

Oops! Something went wrong. Please try again later.

February 15, 2023

You may have heard the terms high level and low level in reference to programming languages. These terms refer to the level of abstraction of a programming language. Essentially, high-level languages can be understood by humans; low-level languages can be understood by machines. To understand the difference, you need to know a little bit about how a computer works. If you’re already familar with this topic, feel free to skip ahead.

Computer hardware is essentially a collection of circuits. It operates on the concept that a circuit can be open or closed, and the state of the circuit (open or closed) serves as information. If a circuit is closed, electricity flows through the circuit, but if it is open, electricity cannot flow. These circuits are controlled by a series of gates that represent logical operators (AND, OR, etc.). At any given time, each circuit can be open or closed; the electricity can be on or off, which is a binary choice — unless you’re dealing with quantum computers, but we’ll get to that later.

Low Level Languages

Only two programming languages are classified as low-level: Machine Language and Assembly Language. Machine Language consists entirely of zeroes and ones. This is the only language a machine can actually understand, because it corresponds directly to the state of a circuit — 0 for off (open) or 1 for on (closed). All other languages exist as a convenience for the humans who program computers. Programs written in any other language must be translated into Machine Language before they can be executed.

Assembly Language is usually — though not always — classified as a low level language. It uses abbreviated commands such as LDA for “Load,” STO for “Store,” and ADD for “Add.” It is typically used for interacting with hardware directly and can therefore be found in boot code such as BIOS, as well as operating system kernels. In order for the computer to understand Assembly Language, it must first be translated by an assembler. The assembler takes the source code as input and outputs an entire machine language program — essentially an executable file — as output. The computer can then execute the program very quickly, without having to pause for translation.

High Level Languages

Everything else, from C to JavaScript, is considered a high level language. High level languages must either be compiled or interpreted before a computer can execute them. Although high level languages are commonly classified as either compiled or interpreted languages. For example, Java would be considered a compiled language, whereas JavaScript would be considered an interpreted language. In reality, however, most languages can have both compiled and interpreted implementations.

A compiler works like an assembler, taking in the entire source code and outputting what amounts to an executable file. After writing a program, the programmer must take the extra step of compiling the code. After making any changes, the programmer must compile the code again; the output is an entirely separate file from the code itself.

An interpreter, by contrast, is built into the runtime environment and translates each line of code as it is received. The programmer need not take any extra steps to run the code. Traditionally, compiled code is considered much faster than interpreted code (providing better performance). However, recent advances in processor technology have made this difference hardly noticeable in most cases.

A False Dichotomy

The idea of classifying programming languages as high-level or low-level might be appealing because of its simplicity — and perhaps becuase it mimics the binary nature of computer circuitry itself. However, this schema oversimplifies the differences among programming languages and is not universally accepted. Even a cursory Google search yields models with three, four, and even more levels.

A three-tiered system separates Machine Language from Assembly Language on the basis that only Machine Language can be directly understood by computer hardware. Similarly, C is difficult to classify. In many ways, it acts like a high level language, but it also allows programmers to interact with hardware (e.g., memory) directly. It also allows programmers to embed Assembly Language within it. Some people therefore classify C as a middle level language (neither high nor low).

Similarly, a particular set of languages was classified as “very high-level” for a period of time, adding another tier to the classification system. However, this title fell out of favor when even higher-level languages were invented.

Perhaps a better approach would be to think of the abstraction of programming languages as a spectrum, rather than a binary choice or even a multi-tiered model. As the meme below illustrates, some people are already thinking along these lines.

Meme: Is python a real programming language? Depends on the context. Compared to C++? No. Compared to HTML? Yes.Courtesy of https://br.ifunny.co

Tim Statler makes a more serious attempt to rank programming languages according to level of abstraction without the use of levels in his article Programming Language Levels (Lowest to Highest):

  • Machine Code (Binary)
  • Machine Code (Hexidecimal)
  • Assembly Language
  • FORTRAN
  • BASIC
  • C
  • C++
  • Perl
  • Java
  • JavaScript
  • PHP
  • C#
  • Python
  • SQL
  • Prolog

Quantum Languages

Quantum computing introduces a breaking change to the two-level classification system for programming languages. The principle of superpositon, expressed most famously by Schrodinger’s cat, means that for quantum computers, logic is not binary. At any given moment, a qubit (quantum binary digit) could hold a value of zero, one, or both. These machines thus “speak” an entirely different language from classical computers. Quantum computing languages still vary in their degree of abstraction, but the traditional high and low level categories do not apply.

February 15, 2023

Oops! Something went wrong. Please try again later.