Source code: what is it?

Understand what is source code is, your appearance, its relationship to binary code and it's great importance for maintaining computer systems.

11/09/2023

youtube-thumb
algol-youtube-play

Source Code Definition

More simply and objectively, a source code is the fundamental part of a computer program. He is the computer program himself! It is the textual representation of the program, which was written by a programmer using a Programming Language.

If you do not know what a Programming Language is yet, click here and access an article where we explain in detail about it.

Here’s an example of a source code:

1.void mergeSort(int arr[], int l, int r) {
2. if (l < r) {
3. int m = l+(r-l)/2;
4. mergeSort(arr, l, m);
5. mergeSort(arr, m+1, r);
6. merge(arr, l, m, r);
7. }
8.}
9.
10.void printArray(int A[], int size) {
11. int i;
12. for (i=0; i < size; i++)
13. printf("%d ", A[i]);
14. printf("\n");
15.}
16.
17.int main() {
18. int arr[] = {12, 11, 13, 5, 6, 7};
19. int arr_size = sizeof(arr)/sizeof(arr[0]);
20. printf("Given array is \n");
21. printArray(arr, arr_size);
22. mergeSort(arr, 0, arr_size - 1);
23. printf("\nSorted array is \n");
24. printArray(arr, arr_size);
25. return 0;
26.}

Do not be alarmed if you do not understand the code above. The important thing is that you know that it consists of a set of words and symbols. These words are written, line after line, as if it were a recipe being followed step by step.

See the image below an example of a source code being read and executed by a computer. Notice how each line is made up of a set of symbols and words that are executed step by step from top to bottom.

source-code

These symbols represent certain meanings that are interpreted by the computer and converted into actions. These are actions such as reading a file, terminating an operating system process, drawing an image on the screen, saving information on a flash drive, running a program, and all the endless other actions a computer could perform.


Source vs Binary

If the source code represents the beginning of every computer program, the binary code represents its end. The binary code represents the final code converted from source code to be executed by the computer.

See the illustration below for how font conversion to binary code works.

source-code

Note in the illustration that it is sent to the compiler, a special program that will convert the written operations of the code and turn them into binary. This resulting binary code can then be executed by the computer.

It is clear that when you run a program you are actually running binary code, not source. A source code is just the word set that was written by the programmer. If the program subsequently needs to be modified, the programmer changes the source code and converts it back to binary code.

Here’s an example of a binary code:

1.01101001 01101110 01110100 00100000
2.01101101 01100001 01101001 01101110
3.00101000 00101001 01111011 00001101
4.00001010 00100000 00100000 00100000
5.00100000 01110000 01110010 01101001
6.01101110 01110100 01100110 00101000
7.00100010 01001000 01100101 01101100
8.01101100 01101111 00100000 01010111
9.01101111 01110010 01101100 01100100
10.00100010 00101001 00111011 00001101
11.00001010 00100000 00100000 00100000
12.00100000 01110010 01100101 01110100
13.01110101 01110010 01101110 00100000
14.00110000 00111011 00001101 00001010
15.01111101

To learn more about binary code, click here and visit an article where we explain you in detail about it.


The importance of Source Code

Surely you are a user of many computer programs. And we’re not talking about those modern games of yours, or those dozens of apps you have on your smartphone. We are talking about applications that are in all the many elements of your life that you don’t even realize.

If you live in a big city and drive, you make use of dozens of programs. They control your air conditioner, from the display of your vehicle’s dashboard to the electronic fuel injection system.

If you ride the bus, you also make use of many computer programs. Programs control everything. From complex systems that gather information via GPS to the internal systems that control the vehicle.

Therefore, source code is the basis of building computer programs that control all sectors of society and provide all kinds of benefits of modern life. For this reason, its correct maintenance is extremely important, because at all times the programs need modifications and adaptations.

autor

David Santiago

Master in Systems and Computing. Graduated in Information Systems. Professor of Programming Language, Algorithms, Data Structures and Development of Digital Games.

Other articles