Safekipedia

Source code

Adapted from Wikipedia · Discoverer experience

In computing, source code, or simply code or source, is human readable plain text that can eventually result in controlling the behavior of a computer. It is the way people tell computers what to do using words and symbols we can understand.

To control a computer, this source code must be processed by a computer program. It can be used directly by an interpreter or changed into a form easier for computers to use by a compiler.

Sometimes, code is changed directly into machine code so it can run on a computer without any extra steps. But often, it is first changed into an intermediate representation such as bytecode. This bytecode can then either 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, a set of simple instructions the computer could follow directly. However, 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 outside files called libraries to work. A special tool called a compiler connects these files so the program can run on a computer.

Software builders use something called configuration management to watch changes in their code. This system also remembers which processed file matches which version of the original code.

Purposes

The number of lines in a program, called source lines of code, is often used to measure how productive programmers are, the value of a software project, and the effort 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 meant 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 describes how well a program works, including if it runs correctly and efficiently, can be used in different places, and is easy to change. It's usually smarter to build good quality into a program from the beginning rather than trying to fix it later. High-quality code saves money over time because it works better and is easier to update.

Maintainability means that software can be changed easily without causing problems. Using clear names for functions and variables, and writing code that only runs when needed, helps make software easier to understand. Some development teams forget about maintainability while building software, which can cost more in the long run. This happens when programmers choose quick fixes instead of better, cleaner code, often because they're trying to meet deadlines. Sometimes, courses teaching software engineering don’t focus enough on maintainability, and developers may not plan to maintain the software later, so they don’t build it in from the start.

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.