Computer science uses source code as both the primary artifact for expressing computation and the central object of study: programmers write source code to specify what a computer should do, and computer scientists analyze, transform, execute, and verify that code to understand what computation is and how to make it reliable. The qualification is that "using source code" means different things at different layers. A working developer uses it as an instruction manual for hardware; a compiler uses it as input to a translation process; a researcher uses it as a formal object that can be reasoned about mathematically. The same text plays all these roles at once, which is why source code sits at the center of the discipline rather than at its periphery.
Source code is the human-readable specification of a computation
At its most basic, source code is text written in a programming language that humans can read and that a machine can process. It exists because raw machine instructions—binary opcodes and memory addresses—are nearly impossible for people to write correctly at scale. Source code introduces names for values, structure for control flow, and syntax that maps onto how people reason about problems.
That readable form is not what the processor executes. Between the source and the running program sits a translation step: a compiler converts source into machine code ahead of time, an interpreter executes it directly or through an intermediate representation, and a hybrid approach such as a just-in-time compiler does both. This distinction matters for the question because it explains why source code is useful in two directions. To the programmer, it is the editable, comprehensible record of intent. To the machine, it is raw material for a transformation that produces something executable.
A short example makes the gap concrete. The line
is meaningful to a human reader: it names a computation and its inputs. The processor never sees total, price, or quantity; the compiler maps those names to registers or memory locations and emits arithmetic instructions. The source code is the specification; the machine code is one valid implementation of it.
How computer science is organized around that artifact
Computer science as a discipline is often described as the study of computation and information. Source code is where that study becomes tangible, because it is a precise, checkable description of a process. Unlike a natural-language procedure ("sort the list"), a program can be executed, tested, and reasoned about formally. That precision is what lets the field make claims rather than assertions.
The field's subareas each engage source code differently, and the differences are instructive:
| Area | Relationship to source code |
|---|---|
| Programming languages | Designs notations, defines their meaning, and builds translators |
| Compilers | Treats source as input to a staged transformation into executable form |
| Software engineering | Studies how code is written, tested, maintained, and organized across teams |
| Algorithms and theory | Uses code-like pseudocode to express and analyze procedures |
| Operating systems and systems | Writes the low-level code that manages hardware and resources |
| Software verification and analysis | Proves or checks properties of code without running it, or monitors it while running |
None of these areas treats source code as merely clerical. Each asks a different question about the same text.
Programming languages: defining what source code means
A programming language is a formal notation with a syntax (which strings are valid programs) and a semantics (what a valid program means). Computer science builds both. Language designers decide whether evaluation is eager or lazy, whether types are checked before or during execution, how memory is managed, and what abstractions programmers can express directly.
The semantics part is where the discipline becomes scientific rather than merely practical. Operational semantics defines meaning by describing execution steps; denotational semantics maps programs to mathematical objects; axiomatic approaches such as Hoare logic describe what can be proven about a program's state before and after it runs. These are not academic decoration. They are the reason a language specification can be precise enough for independent implementations to agree, and they underlie tools that check programs mechanically.
This is also where the answer to the search question sharpens. Computer science does not just use source code the way a carpenter uses lumber. It studies the notation itself, asking which notations make certain kinds of correctness easy or hard to establish.
Compilers and interpreters: source code as input to a pipeline
A compiler is a program that reads source code and produces another representation, usually machine code or an intermediate form. The classic pipeline has recognizable stages, and each stage illustrates a way computer science processes source text:
1: Lexing breaks the character stream into tokens—identifiers, keywords, operators, literals. 2: Parsing assembles tokens into a syntax tree according to the language grammar. 3: Semantic analysis resolves names, checks types, and enforces rules the grammar alone cannot express. 4: Intermediate representation lowers the program to a simpler, machine-independent form suitable for analysis and optimization. 5: Optimization rewrites the program while preserving its meaning—removing redundant work, simplifying control flow, improving memory access. 6: Code generation emits target instructions, often followed by register allocation and instruction scheduling.
The optimization stage is a particularly clear case of computer science using source code as a formal object. An optimizer must prove that a rewrite preserves observable behavior; otherwise the "optimized" program is a different program. This is where the discipline's theoretical side and its engineering side meet: graph algorithms for control-flow analysis, lattice theory for dataflow problems, and type theory for program transformations all enter the compiler.
Interpreters skip ahead-of-time code generation but still parse and analyze. A just-in-time compiler defers some of this work until runtime, using information about which code paths are actually hot. All of these are ways of consuming the same source text for different purposes.
Software engineering: source code as a long-lived team artifact
Most source code in the world is not written once and discarded. It is read, modified, reviewed, and debugged by many people over years. Software engineering studies that reality, and its findings shape how source code is structured and managed.
Version control systems such as Git record the history of source files as a graph of commits, enabling branching, merging, and blame—who changed which line, and when. Code review treats source code as something to be examined by peers before it enters the main line. Issue trackers link code changes to the problems they address. Continuous integration runs automated builds and tests whenever source code changes, so that a defect is caught near the moment it is introduced rather than months later.
Testing deserves separate mention because it shows source code being used as evidence. A unit test is itself source code that exercises another piece of source code and asserts expected outcomes. Test suites are executable specifications: they describe behavior in a form the machine can check repeatedly. Property-based testing goes further, generating many inputs and checking that a stated invariant holds across all of them.
Refactoring is the disciplined practice of changing source code's structure without changing its observable behavior, precisely so that the code remains maintainable as requirements evolve. Metrics such as cyclomatic complexity attempt to quantify aspects of code that correlate with difficulty of understanding and testing—useful heuristics, not laws.
Algorithms and theory: pseudocode as a bridge
Computer science's theoretical core often expresses procedures in pseudocode rather than any specific language. Pseudocode is source code stripped to its essential structure: loops, conditionals, assignments, and abstract data operations, with implementation details omitted. This lets a proof about an algorithm's running time or correctness apply across implementations.
That practice reveals something important about how the field uses code. The idea of an algorithm is independent of any particular syntax; the source code is one concrete realization. A sorting algorithm described in pseudocode can be implemented in Python, C, or Rust, and its asymptotic complexity—its growth rate as input size increases—is a property of the procedure, not the notation. Computer science uses code-like notation here as a precise language for stating claims that can then be proven.
Verification, analysis, and the limits of testing
Because source code is a formal object, it can be analyzed without being run. Static analysis examines code for patterns that suggest bugs—uninitialized variables, unreachable branches, potential null dereferences, security weaknesses such as injection flaws. Type systems are a form of static analysis built into the language: they reject programs whose operations don't match the types of their values.
Formal verification goes further, attempting to prove that a program satisfies a specification for all possible inputs. Model checking explores the states a system can reach. Proof assistants such as Coq and Isabelle let researchers machine-check mathematical proofs, including proofs about programs. These techniques are demanding and not universally applied, but they exist because the field treats source code as something that can be reasoned about rigorously.
The counterexample worth stating is that testing cannot establish correctness in general. A test suite exercises finitely many inputs; a program's input space is typically vast or infinite. This is not a flaw in testing but a boundary of what it can prove. Understanding that boundary is part of what computer science contributes to the practice of writing code.
Where source code stops being the whole story
Three distinctions keep the answer accurate.
First, source code is not the only representation a computer scientist works with. Bytecode, intermediate representations, assembly, and machine code are all legitimate objects of study, and some analyses operate on binaries rather than source. Decompilation attempts to recover source-like structure from compiled output, which is itself a research area.
Second, not all source code is executed directly. Configuration languages, domain-specific languages for queries or hardware description, and markup such as HTML describe structure or intent rather than a sequence of instructions. They are code-adjacent, and the boundary is a matter of definition rather than a sharp line.
Third, the relationship between source and behavior is mediated by the entire toolchain—compiler version, libraries, operating system, and hardware. The same source text can behave differently across environments. This is why reproducible builds and pinned dependencies matter, and why "it works on my machine" is a recognizable failure mode rather than a joke.
Why the answer matters
Understanding how computer science uses source code explains several things that otherwise look arbitrary. It explains why programming languages are studied as formal systems rather than mere conveniences. It explains why compilers have distinct phases and why optimization requires correctness arguments. It explains why software engineering invests heavily in version control, review, and automated testing. And it explains why verification research exists despite the practical dominance of testing.
The short version: source code is the point where human intent becomes precise enough to be checked, transformed, and executed. Computer science uses it as a specification language for people, an input format for tools, and a mathematical object for analysis—often all three at once. That triple role is why the discipline is organized so heavily around the act of writing code, and why the study of code itself remains a live research frontier rather than a solved problem.