Source code
Adapted from Wikipedia · Adventurer experience
What is source code?
In computing, source code, or simply code or source, is human readable plain text. It tells computers what to do using words and symbols we can understand.
To make a computer follow these instructions, source code needs to be processed by a computer program. It can be used right away by an interpreter or changed into a form easier for computers by a compiler.
Sometimes, code is changed into machine code so it can run on a computer right away. Often, it is first changed into an intermediate representation like bytecode. This bytecode can then be run by an interpreter or changed into machine code when needed using just-in-time compilation.
Source code is important because it lets people create and control the programs and apps we use every day.
Background
The earliest computers, which appeared in the late 1940s, were programmed using machine language. This was a set of simple instructions the computer could follow directly. But machine language was hard to work with and could not easily move between different computers.
As computers grew more complex, programmers needed better tools. This led to the creation of high-level programming languages like Fortran in the mid-1950s. These languages made it easier for people to write instructions for computers by hiding the complex details of the computer’s hardware.
Source code is the set of instructions written by people in these high-level languages. It needs to be changed into a form the computer can use, called object code, often using a special program called a compiler. While object code works only on one type of computer, source code can be used on many different computers by being compiled for each one.
Organization
Further information: Software configuration management
Many programs need help from files called libraries to work. A tool called a compiler connects these files so the program can run on a computer.
Software builders use a system to watch changes in their code. This system remembers which file goes with which version of the original code.
Purposes
The number of lines in a program, called source lines of code, is often used to see how well programmers work, how valuable a software project is, and how much effort is needed to build or maintain it.
Source code helps people share ideas about how computers work. Programmers read existing code to learn new ways to write programs. Sharing code helps programmers improve their skills. Source code often includes comments — notes for people reading the code, not for the computer to use. Companies may keep their source code secret to protect special methods they use, especially for important tasks like criminal justice. This secret code can make it hard for others to check how the program works.
Having the source code makes it possible to change a program. Understanding existing code is important before changing it. Experienced programmers find this easier. Special tools help programmers write and check their code. Changing code can introduce new problems, so other programmers often review the new code to make sure it works correctly. Tests and tools help find issues in the code before it runs.
Source code needs to be turned into a form the computer can use before it can do anything. Some programs are turned into this form ahead of time, while others are turned during running. Using source code lets programs run on many different types of computers, unlike prepared programs that only work on specific machines. This was important for early versions of the Unix operating system and for programs written in languages like JavaScript.
Quality
Further information: Software quality
Software quality is about how well a program works. It means the program runs correctly, works well, and can be used in many places. It's best to make a program good from the start rather than fixing it later. High-quality code saves money because it works better and is easier to update.
Maintainability means that software can be changed easily without causing problems. Using clear names for parts of the program helps make it easier to understand. Some teams forget about maintainability when building software, which can cost more later. This happens when programmers use quick fixes instead of cleaner code, often because they need to finish fast. Sometimes, courses teaching software engineering don’t spend enough time on maintainability, so developers might not plan to update the software later.
Copyright and licensing
Further information: Software copyright and Software license
See also: History of free and open-source software
Before 1974, in the United States, software and its source code was not protected by copyright and was freely available for anyone to use. In 1974, it was decided that computer programs could be protected because they show the unique ideas of the person who created them.
Some software is kept private and not shared as source code. Open-source software means that anyone can see the source code, but it also has rules: it must be free to share, change, and use for any purpose, including business. This freedom to reuse open-source software helps developers work faster.
Related articles
This article is a child-friendly adaptation of the Wikipedia article on Source code, available under CC BY-SA 4.0.
Safekipedia