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?
closed as unclear what you're asking by gnat, Robert Harvey♦, BlueRaja - Danny Pflughoeft, Thomas Owens♦ Nov 26 '16 at 12:54
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
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.
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.
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.