Attic › Computer science › Source code

Source code is the text that programmers write to tell a computer what to do

Source code is the collection of instructions that a programmer writes to create a computer program. It is written as plain text in a programming language that humans can read and understand.

A computer's processor cannot read words. At the hardware level, it only responds to machine code, which is a stream of binary numbers—ones and zeros—that control its electronic switches. For example, to make a processor add two numbers together, the machine code might be a sequence like `000000 00001 00010 00011 00000 100000`.

Writing a whole program in binary numbers is slow, and a single wrong digit will break the program. Even a small program requires thousands of these instructions, which makes it almost impossible for a person to find mistakes or change how the program works later.

Because machine code is too difficult for people to manage, programmers write source code instead. Programming languages such as C or Python use English words, mathematical symbols, and strict grammar rules to represent instructions clearly. Instead of a string of ones and zeros, a programmer can write a line of source code like `total = price + tax`.

This makes it possible for people to design, read, and fix complex software. Programmers can also add notes, called comments, directly into the source code to explain how a part of the program works to other people who read the text later.

Fact-checked against Source code on Wikipedia

Part of the Computer science syllabus: Automata, Grammars, and Compilers

See it on the timeline of Computer science