The Source Code: What Is It And How Is It Written?
If you’re not a programmer or web designer, you’ve probably never considered what’s behind the programs and web pages you use every day. These are based in part on long and very complex instructions given to the computer. The text that includes all the commands is called source code, source text, or source code in English. Based on a specific programming language, programmers set all the rules for computer-executable applications. If the author inserts an imperceptible error in his work and this contravenes the rules of the programming language, the program does not work or is blocked when performing certain processes.
What is the source code?
Computers, whether domestic PCs, modern mobiles, or computers for industry or science, work with a binary system: on / off, loaded/unloaded, 1/0. A sequence of states (bits) tells the computer what to do. While in the early days of computer technology, commands were created with these two conditions, it has been a long time since writing applications in a human-readable programming language. This may sound a bit weird a priori because for the layman in the matter a source code is more gibberish than anything else.
In this context, “readable by humans” is an antonym to “readable by machines “. While computers only work with numerical values, people use words to communicate. Like foreign languages, programming languages also have to be learned before being used.
Various programming languages
There are hundreds of different programming languages and you cannot say per se that some are better than others, because this depends on the context of the project and the application for which the source code is used. Among the most popular programming languages are:
- C ++
In order for computers to understand them, they must be translated into machine code.
Structure of the source text
When writing programs, certain conventions must be met regardless of the programming language used. Very few languages are created from nothing, but the majority is developed from the others, hence there are certain elements that appear repeatedly in different programming codes:
Commands: the instructions are probably the basis of all applications. With them, the programmers indicate to their future programs what they have to do. Such commands can, for example, trigger certain calculation processes or even display a text.
Variables: variables are spaces in which data is inserted. Within the source code, these are referenced again and again by assigning a name.
Comparisons: especially decisive for the structure of most programs are queries that work according to a cause-effect scheme that is, following the principle of propositional logic. The introduction of a certain logical value triggers an event; if not, a different one is produced.
Loops: queries can also form the basis for loops in the source text. A command is repeated until a certain value has been reached, after which the program will leave the loop and execute the rest of the code.
Comments: all the current programming languages allow to comment lines within the code, with which it is possible to write text in the source code that the program does not take into account. The author can thus enter comments in the source text so that he or another developer can understand the different parts of the code in the future.
The creation of source code is always linked to a problem. The website developers in London write programs to offer solutions, but it is not established what the way to do it is. When two programmers deal with the same problem, it can happen that both source texts differ significantly from one another, even though they work in the same language.
Although in many cases there is no single solution, all programming tasks have something in common: a good source text must dispense with unnecessary code since this makes the program more complex, slow, and prone to errors. The unclear source code that even professionals cannot understand is called spaghetti code because its structure is as confusing as a bunch of spaghetti on a plate.
Creation of the source code
To write a source text you only need a simple text editor, such as Editor (whose original name is Notepad) in Windows or TextEdit in Mac. The source code is saved as plain text (for example in ASCII code or as UTF-8) from the extension of the correct file name for the programming language. If you find a file with the ending “.cpp” on your hard drive, it is a text file that contains code in the C ++ programming language.
In addition to the standard programs of the operating systems, there are also improved text editors that facilitate work with source code with various functions:
Highlight the syntax: every programming language uses its own syntax. In many text editors, the programming language with which the source code is written can be selected and the program automatically highlights the fundamental elements. Likewise, the program is also capable of creating the bleed, which highlights the structure of the source text.
Autocomplete: Many text editors for programmers know the commands of programming languages, complete them automatically, and are able to close open keys by themselves.
The highlight of keys: the programming languages work with keys to group elements. To keep an overview even in large code documents, some text editors mark the keys in which they work.
Code folding: in most cases, the source code is constructed hierarchically and is presented by means of indentation and keys. To have a more general vision when programming, in some text editors the source text, which is at deeper levels, can be folded. This can hide the parts of the code that are not relevant.
Integration of a compiler: in some text editors compilers can be integrated by means of plugins. Thus it is possible to test the written program directly.
Multi-line editing: Writing source code by hand can be a very expensive task, hence programmers rejoice when they can perform as many steps as possible simultaneously. The same modifications are made in several parts of the document through the multi-line edition, which saves time.
Read: Must Have Software for Windows 10 for Daily Use