Programming languages let people express instructions and organise data in a form they can read, test and maintain. A language implementation turns those instructions into work the computer can carry out. That process may involve compilation, interpretation or a combination of both; there is no single assembly-language pipeline that every program follows.
Source code, machine code and the runtime
Source code is the human-readable code you write. Machine code contains instructions for a particular processor architecture. A runtime provides the environment and services a program needs while it executes, such as memory management or access to files and networking.
Digital computers represent information using bits, commonly described as 0 and 1. A byte is normally eight bits. Those bits can represent instructions, numbers, text or other data; a byte is not simply a group of eight transistors. Hardware performs the underlying operations, but programmers usually work with higher-level abstractions.
High-level and low-level languages
High-level languages provide concepts such as functions, collections and objects that let you describe a task without specifying every processor instruction. Low-level languages expose more machine-specific detail. Assembly language uses symbolic instructions closely related to a processor’s instruction set.
These labels describe levels of abstraction, not a universal ranking of difficulty or quality. The appropriate language depends on the task, platform, libraries, performance requirements and the people who will maintain the program. Many languages serve several purposes.
Compilation and interpretation can work together
A compiler translates code into another representation. Its output might be machine code, an intermediate representation, bytecode or another source language. An interpreter executes a program by processing its representation. Interpreters do not necessarily read the original source one line at a time.
Common execution approaches include:
- Ahead-of-time compilation: code is translated before the resulting program runs, often producing machine code that can be packaged into an executable.
- Bytecode execution: source is compiled into instructions for a virtual machine, which then executes them. The Python glossary describes this approach in CPython.
- Just-in-time compilation: some translation to machine code happens while a program is running. Engines may combine interpretation and compilation; see MDN’s JIT explanation.
It is more accurate to describe an implementation’s execution strategy than to insist that a language is always “compiled” or always “interpreted”. You also do not need to create a visible assembly-language file every time you run a program.
A language is not the same as its environment
JavaScript can run in a browser, where it can interact with a web page, or in other environments. Node.js, for example, runs JavaScript outside the browser. The available APIs differ, so browser code that expects a document object will not automatically work in every runtime.
PHP is commonly used for server-side web applications, but it can also run from the command line. The PHP manual documents that usage. Neither language is restricted to the single environment most often associated with it.
From a text file to a working program
Saving code in an editor creates a source file; it does not by itself install the required runtime, build dependencies or make the file executable. Follow the instructions for your chosen language and environment, then start with a small example whose result you can predict.
Before running a project, identify:
- The language and supported version.
- The runtime, compiler or build tool it requires.
- The command or application that starts it.
- Its dependencies, inputs and expected output.
If the result is wrong, distinguish a syntax problem, a runtime failure and a logic error. Our guide to common challenges for coding beginners provides a practical debugging routine.
Build your JavaScript foundations
To practise programming for interactive web pages, explore the Academy Class JavaScript Beginner course. Check its current prerequisites and syllabus against your experience before booking.