Code Source — Wikipedia

before-content-x4

Paper copy of a Fortran Sourran Code from the 1970s, printed on continuous paper (in) , dedicated to text files.

In computer science, the code source is a text that presents the instructions making up a program in a readable form, as they have been written in a programming language. The source code generally materializes in the form of a set of text files.

The source code is often translated – by an assembler or a compiler – in binary code composed of instructions executable by the processor. It can otherwise be directly interpreted in the execution of the program. In this second case, it is sometimes translated beforehand into an intermediate code whose interpretation is faster.

Expression is a translation of English source code . Expressions omitting the term of code are common: the sources , the source .

after-content-x4

In the very early days of IT, the programs had entered the computer memory through the switches of the control desk, in the form of the binary coding of machine instructions. Which was only suitable for very small programs. They were then loaded from perforated bands, then perforated cards.

Very quickly, the programs were written in a symbolic language, assembly language or evolved language like Fortran, Cobol, then automatically translated by a program (assembler, compiler).

With the appearance of magnetic discs and interactive consoles, editors of lines and then text editors were used to type and modify the source code.

The limited possibilities of computers of the time often required the printing of the source code on continuous paper (in) with Carol bands.

Today, there are development environments, so -called integrated development environment (IDE, Integrated Development Environment ), which include publishing and compilation tasks.

Types de code sources [ modifier | Modifier and code ]

Software is a series of instructions given to a machine. A processor can only perform instructions represented in a particular binary form. Except experimental mechanisms, it is not possible for a human being to directly grasp a binary code in the representation that the processor is waiting for: a human being cannot directly write bits with expected addresses. He is obliged to go through a separate code called source code, and which is subsequently translated into the binary representation expected by the machine then charged and executed by the target.

However, writing a code in binary form, even in a separate file, poses many problems of understanding to human beings. It is a representation only made up of an uninterrupted suite of 0 and 1 which is difficult to read, write and maintain without technical assistance. The diversity of microprocessors and components present in a computer or automaton, implies that a binary code generated for a system cannot be first the same as on a separate machine. Also, there are as many binary codes as configurations and increased complexity excluding that humans can simply design a large -scale binary code.

To avoid these pitfalls, and since a translation is always necessary, the human being writes a textual code so that it is more readable, more understandable and easier to maintain: it is the written source code in a programming language . It is, in most cases, more readable, easier to write and independent of the target system. A third -party program (compiler, interpreter or virtual machine) takes care of the translation of the source code into binary code executable by the target.

Screen copy of a source code in Java.

The code generated by humans is called code source ; The way this is written code source is called programming language; The translator of this code in its binary representation is called a compiler, interpreter or virtual machine according to the methods of translation.

In most languages, we can distinguish different elements in a source code:

  • The elements describing the algorithm and the data (the source code itself):
    • symbols identifying variables, keywords denoting instructions, data representations;
    • literal constants.
  • The comments, which document the source code most often in natural language, intended for rereaders of the source code. They are not necessary for the production of the executable code but can be used by the compiler to, for example, automatically produce documentation.

Syntactic coloring [ modifier | Modifier and code ]

A code is easier to read and write with an editor providing syntactic coloring to distinguish the different elements of the source code. Comments can for example be put in green.

Example of code in Ruby:

a  =  " n This is a double quoted string n "  a  =  %Q{ n This is a double quoted string n }  a  =  << BLOCK  This is a double quoted string  This is a double quoted string  BLOCK  a  =  %/tThis is a double quoted stringn/  

Another example of Ruby code:

hash  =  {  :water  =>  'wet' ,  :fire  =>  'hot'  }  puts  hash [ :fire ]  # Prints: hot  hash . each_pair  do  | key ,  value |  # Ή:  hash.each do |key, value|  puts  " #{ key } is #{ value } "  end  # Prints: water is wet  #          fire is hot  hash . delete  :water  # Off: water => 'wet'  hash . delete_if  { | key , value |  value == 'hot' }  # Off: Fire => 'hot'  

Another example of Ruby code:

 File . open ( 'file.txt' ,  'In' )  { | file |  # Opening the File.txt file for recording ("W" - Write)  file . puts  'Wrote some text.'  }  # The design eliminates the uncertainty with the closure of the file: closes here with any outcome  

The analogy of the source code and the cooking recipe is often used in a desire for popularization. A recipe is an organized list of ingredients whose quantities and functions are defined. The goal is to obtain the result wanted by the cook, according to a technique and a series of determined operations.

Thus the source code can be related to a cooking recipe.

Thus, a person tasting a dish is able to guess the ingredients that make it up and imagine how to make it. Nevertheless, for a very refined and subtle dish (as a program could be), it is very likely that it ignores the operating mode of the cook. To know it, a detailed recipe would be necessary (for a program, the recipe can count several million lines of code). The alternative solution to this would be to buy prepared dishes is a bit of what you do when you buy software.

The source code can be public or private (see free software and owner software). However, the binary code being only a translation of the source code, it is always possible to study software from its binary code. The legality of the techniques used for these purposes depends on the country and the time. It can notably be implemented to unravel the secrets of a machine like ES3B.

On other Wikimedia projects:

Related articles [ modifier | Modifier and code ]

after-content-x4