I'm a beginner in programming and I don't have a good grasp on terminology. I'd like to know if source code written in a compiled language like C or C++ is considered a program? If not, can anyone explain why?

  • 1
    Yes, source code is considered a program. Programs can be distinguished by the type of code they contain, as in "source code," "object code," "machine code" and "executable code." – Robert Harvey Nov 25 '16 at 22:48
  • 6
    This question strikes me in the very much the same way "Is beef a cow?" would, for pretty much all the same reasons. – R.M. Nov 26 '16 at 3:44
  • 1
    Is flour and sugar a cake? – Bryan Oakley Nov 26 '16 at 4:00
  • 2
    thecodelesscode.com/case/70 – Kevin Nov 26 '16 at 5:37

See the Wikipedia entry for Program: (I've added the bold)

A computer program is a collection of instructions that performs a specific task when executed by a computer. A computer requires programs to function, and typically executes the program's instructions in a central processing unit.

A computer program is usually written by a computer programmer in a programming language. From the program in its human-readable form of source code, a compiler can derive machine code—a form consisting of instructions that the computer can directly execute

So, the "program" is the set of instructions that the computer executes, and the "source code" is the human-readable version of those instructions.

  • 1
    thank you for your answer. If I understand correctly, source code is a program because it defines a suite of instructions that performs a task when they are executed by a computer. But even if those instructions are not the ones that get executed by the CPU at the end the CPU executes instructions which are the translations of the instructions defined in a high level language? – Othman Nov 25 '16 at 23:11

I'd like to know if source code written in a compiled language like C or CPP is considered a program?

Yes , it is.


The danger with this line of thinking is arriving at: "the computer executes my program, I write my program in [eg] C, ergo that source code is instructions to the computer".

And this is what too many of us thought for too many decades in the 20th century. What we have learned in the last decade or so is that other programmers are the primary audience of source code. So yes, that source is the program, in the same way as you'd get a program at the theatre, that tells other people what's happening. The beauty of source code is that not only is it the program, it's also a set of instructions to the computer too...


Whether it is or isn't, depends on context. Think about it this way. I forget what the formal name for the concept is, but there is a theory of language that says words have meaning that describe not what something is, but what it isn't. A red apple isn't red because it's, well, red, but because it's not blue, not green, etc. Ignore whether that's true or not, but just assume it is for a second and think about the question in that context.

So when we think of that concept, we can compare our source code to a blueprint of a house. If you're looking at the blueprint out of a stack of other blueprints, and ask "is this a house", and the other blueprints are for commercial buildings, bridges, etc, the answer would be yes. Because the blueprint represents not all that other stuff, and the house aspect is what distinguishes it against the other blueprints.

However, obviously a blueprint of a house is not the same as an actual house made of wood and drywall that you can stand in. There are contexts where difference between the blueprint and the actual house is meaningful. There is a difference between the plan and the deliverable.

The same way the source code of a program in a compiled language is like the blueprint, if you're comparing it to libraries, kernel modules, etc, then the source code and the program are conceptually one and the same. But if you're looking at how software is compiled, designed, and deployed, the two are not the same. Just again, there is a difference between the plan and the deliverable.

tl;dr: Sometimes what something is, and what it represents, is considered the same thing, but other times they're not.


Source code is a general term for original lines of code (authored by humans). Other kinds of code that are not source may be created by translation or by another program.

Intellectual property is even broader, and can include both source code and other code or data.

A program is distinguished from other code (source or other) in its completeness. A program is code that is sufficiently complete that it can be run (or is intended to run). Not all code (source or otherwise) represents sufficient completeness to run. Libraries for example, are meant to be combined with and used by other code, and so wouldn't generally be considered a program as they can't (aren't meant to be) be run.

This completeness sometimes means having a main, which is used by an operating system as the entry point for the program

Generally speaking, when a program is running, that is called a process.

  • 1
    Please don't mention "intellectual property" as that is a term intentionally meant to confuse people. – whatsisname Nov 26 '16 at 3:08

The source code is the preferred form of the software on which human software developers are working. The insight is that software development is a social process, So source code is a social notion. You write source code mostly for humans (your fellow developers, or even yourself working in a few months on the same program), not for computers. For a program coded in C, it is often (but not always) .c C files and .h header files, but the Makefile is also source code. But sometimes, metaprogramming techniques are used: some program is generating C code, and then the input to that generator is considered source code (even if the output of that generator is C code). Two examples: you might use some parser generator (like GNU bison) for parsing problems, then the input .y file of that generator is source code. Or you might write a tiny awk or gawk script to extract from some sqlite database some data which would be transformed into e.g. a big enum declaration in some generated header; then that database would contain source code!

A computer program in contrast is related to computer running it. It is usually obtained by compiling some source code (written in some programming language, and these are specifications written in English in technical documents -see n1570 draft for C11-, not software tools!) into a binary executable.

Read also about free software. Dive into the source code of existing free software projects (see github or sourceforge to find some).

Not the answer you're looking for? Browse other questions tagged or ask your own question.