Menu
Coddy logo textTech

What Is Source Code?

Source code is the human-readable text of a program, written by a programmer in a language such as Python, Java or C and saved as plain text files, which a compiler or interpreter turns into instructions a computer can run.

By Kevin Spektor, Co-founder & CTO

Updated September 24, 2026

Open any file ending in .py, .c or .java in a plain text editor and you are reading source code. It is the same kind of file as a shopping list: letters, digits, spaces and line breaks. What makes it a program is that the text follows the rules of a programming language, so a tool can turn it into instructions for the processor.

What source code looks like

Here is a complete Python program. Every line is source code, including the comment, which the computer ignores and the next programmer reads.

Total: 12

The same program in C is also source code, just in a different language with different rules:

#include <stdio.h>

int main(void) {
    int price = 4;
    printf("Total: %d\n", price * 3);
    return 0;
}

A real application is thousands of files like these. The Linux kernel has more than 30 million lines of source code, and a small web app can easily have a few hundred files. Each file is named with an extension that tells tools which language it holds:

ExtensionLanguage
.pyPython
.c, .hC
.cpp, .hppC++
.javaJava
.jsJavaScript
.goGo
.rsRust

Source code is plain text

Source code has no fonts, colors or hidden formatting. The colors you see in an editor are added by the editor for reading; they are not stored in the file. This is why you write code in a code editor such as VS Code and never in Microsoft Word: a word processor saves formatting data and "smart" quotes, and the result is a file the language cannot read, usually rejected with a syntax error.

Because it is only text, a program can even hold another program's source in a string and run it:

<class 'str'>
3 lines of text
Total: 12

Until the last line, source is an ordinary string. exec hands it to Python, which reads the text and carries it out. That is the whole life of source code in miniature: text first, instructions second.

How source code becomes a running program

The processor in your computer cannot read Python or C. It only runs machine code, which is binary instructions specific to one kind of CPU (x86-64 in most laptops and servers, ARM in phones and Apple Silicon Macs). Something has to translate. There are two main ways:

  1. A compiler translates the whole program ahead of time. Running gcc hello.c -o hello reads the C source and writes a new file, hello, full of machine code. You can delete hello.c afterwards and hello still runs.
  2. An interpreter runs the source directly. Running python3 hello.py starts the Python interpreter, which reads hello.py and carries out its instructions. No separate program file is produced, so the source must be there every time.

Many languages mix the two. Java source is compiled by javac into bytecode (.class files), and the Java Virtual Machine runs that bytecode. The full comparison is on the compiler vs interpreter page.

Source code, object code and machine code

These three terms describe the same program at different stages:

TermWho reads itExample
Source codePeople and compilerstotal = price * 3 in app.py
Object codeThe linkerhello.o, produced by gcc -c hello.c
Machine code (executable)The CPUhello on Linux or macOS, hello.exe on Windows

If you open a compiled executable in a text editor you see unreadable symbols, because it is binary, not text. On a Mac, the first four bytes of the hello program above are cf fa ed fe in hexadecimal, the marker of a Mach-O executable. You can look at raw values like these with the number base converter.

Open source and closed source

Who can read the source code is a legal question as much as a technical one. Open source software publishes its source under a license that lets anyone read, change and share it. Python, Linux and Firefox are open source. Closed source (proprietary) software ships only the compiled program. Microsoft Windows and Adobe Photoshop are closed source, and their source code is a trade secret.

Source code is also covered by copyright, like a book. Finding code on the internet does not mean you may reuse it: check the license file, often named LICENSE, before you copy anything into your own project.

Common misconceptions

  • "View Page Source shows a website's source code." It shows the HTML, CSS and JavaScript your browser received. The server side of the site (written in Python, Java, PHP or another language) never leaves the server, so you cannot see it.
  • "A decompiler gives you back the original source." A decompiler rebuilds readable code from a compiled program, but comments are gone and names are often lost, so the result is a guess at the source, not the file the authors wrote.
  • "Code and source code mean the same thing." Source code is the version written by people. "Code" is broader and also covers machine code, bytecode and generated code.
  • "Source code must be in English." Keywords such as if and print are English words, but variable names, comments and strings can be in any language. Python 3 source files are UTF-8 by default, so prix = 4 and # 合計を計算する are both valid.

Where to go next

Source code gets checked before it runs, and the first thing most beginners meet is the syntax error. To see how the two ways of running source code differ, read what a compiler is and then compiler vs interpreter. You can write and run your own source code in the browser in the Python playground or start the Python course.

Frequently Asked Questions

What is an example of source code?
Any file a programmer writes in a programming language is source code: a Python script such as app.py, a C file such as main.c, or the JavaScript in a web page. Even one line like print("Hello") saved in a .py file counts. Programs such as Firefox or Linux are built from millions of lines of it.
What is the difference between code and source code?
Source code is the human-written version of a program, in a programming language. "Code" is a wider word that also covers what tools produce from it, such as machine code, bytecode or code generated automatically. In everyday conversation programmers use "code" for source code, and the context makes it clear.
How do I get the source code of a program?
For your own projects, the source code is the set of files you wrote, usually kept in a Git repository. For open source software, the source is published, often on GitHub or GitLab. For a closed source program you normally cannot get it: you only have the compiled executable, and a decompiler gives at best an approximation without the original comments and names.
Is HTML source code?
Yes. HTML is a markup language rather than a programming language, but the .html files a developer writes are the source of a web page, and browsers call the view of them "View Page Source". The same is true of CSS files and of the JavaScript files a page loads.
What is source code management?
Source code management, also called version control, is the practice of recording every change to a project's source files so you can see who changed what, go back to an earlier version and combine work from several people. Git is the most widely used tool for it, and services such as GitHub and GitLab host Git repositories online.
Coddy programming languages illustration

Learn to code with Coddy

GET STARTED