20.06.2021

Why is the program code needed? Program code. HTML Program Code


Any program or online service, such as Word, Microsoft Windows, WhatsApp or the browser that hundreds of millions of people launch every day, one way or another, consist of special instructions. Or special program code that the machine understands tells it what to do or, conversely, not to do. Or how to properly respond to user actions. What is program code will be discussed in this article.

Description

Program code programs are text written in a special language that a machine can understand. It can be executed directly from the text using an interpreter or translated into a special form using a compiler.

The source code of a program can consist of several files. Moreover, they must all be of the same format. The text of the program contained in them must be written in the same language. However, there may be exceptions. For example, in web development, a page file can contain several different programming languages ​​and standards. Depending on the complexity of the project, there may be languages ​​and technologies such as PHP, HTML, and others.

Complex software packages when assembling, they can require a large number of files, which can number in the hundreds. To collaborate on such large projects, programmers very often use version control systems. They allow you to simultaneously work with several copies of the source code, which at a certain stage of development can be combined into one common one.

Code quality

The computer is not able to understand how the code for it is written, good or bad. If it is functional and contains no errors, then the machine will start it anyway. Bad code can complicate software maintenance tasks. This is especially true for large projects. Usually, a good code is characterized by several parameters:

  • Readability of the code. One glance at it should be enough to generally understand what is being implemented by a piece of code.
  • The presence of clear and succinct comments. This parameter greatly affects readability, ease of debugging, support testing, and elimination of program code errors.
  • Low complexity.
  • Optimization of the code. It should be organized in such a way that the program uses as little as possible system resources such as memory, processor time and hard disk space.
  • Lack of rubbish. That is, unused variables or blocks of code, in which program control never comes.

Malicious code

In addition to useful programs, there are some that can harm the system or even the hardware. Typically, this code is written by people who are interested in some benefit from the ongoing process. For example, programs that can steal personal data from users' computers. They can be payment card numbers, passport data, or any other confidential information. Others may simply interfere with the operation of the system, thereby causing crashes and interfering with full functionality.

Jeff Vogel, a highly experienced programmer, shared a few tips for teaching beginner developers the rules of good code.

In particular, he suggests that you always comment on your code. What is a comment? It is understandable and short description what happens in a given line of code or function. The fact is that the development of a certain program may take a month or even stop for a while. Returning to work on the project in a couple of months, even an experienced programmer will find it difficult to understand his own program. But detailed comments will be able to reconstruct the chain of events and the behavior of the code.

He further recommends that you use global variables as often as possible in your program. This is due to the fact that when changing the program code, you will have to adjust the value of the variable in just one place. In this case, all functions or procedures using the value will immediately know about this and will perform operations with new data.

Variable names and error detection

The correct name of the variables will also help to significantly reduce the time spent studying the source code of the program, even if the code is written with my own hands... That is good code such text is considered where variables and functions have names, by which you can understand what exactly they do or store. At the same time, one should try not to use long variable names.

It is very important to pay great attention to the timely elimination of errors. What is code that runs perfectly? This is code that has no errors. That is, any branching of the loop or changing a variable, or even any unforeseen user action, will always lead to the expected result. This is achieved by testing the finished product several times.

Identifying errors in program code, or rather, predicting them, is possible at the stage of program design. The presence in the code of various checks for conditions and possible exceptions will help to control the program at a certain rate.

Optimization is of tremendous importance for writing a workable program that will economically use computer resources while avoiding code execution errors. What is an optimized program? This is a product that is capable of performing all the declared functionality, while behaving "quietly" and economically.

Almost always, optimization for the stable operation of a program can be achieved only as a result of several tests on different platforms and in different conditions. If the program begins to behave unpredictably, you need to determine what caused it and, if possible, eliminate or intercept the process.

Conclusion

What is programming code? Speaking simple language, it is a set of instructions and concepts for a computer. It contains text that a compiler or interpreter can turn into a machine-readable language. That is, in fact, the program code is an intermediary between a person and a computer, which simplifies their relationship.

That can be read by humans. In a generalized sense, any input data for a translator. The source code is translated to executable code entirely before the program is run using the compiler, or can be executed immediately using the interpreter.

Collegiate YouTube

    1 / 3

    ✪ Science show. Issue 33. Scientific Bloopers 2

    ✪ Programming Basics: Source Code

    ✪ Answers to Questions 1: Source Code

    Subtitles

Appointment

The source code is either used to produce object code or is executed by the interpreter. Changes are made only to the original one, followed by re-conversion to object.

Another important purpose of source code is as a description of a program. Using the text of the program, you can restore the logic of its behavior. Comments are used to make the source code easier to understand. There are also tools that allow you to automatically retrieve documentation from source code — the so-called. documentation generators.

In addition, the source code has many other uses. It can be used as a teaching tool; Novice programmers may find it helpful to examine existing source code to learn programming techniques and methodologies. It is also used as a communication tool between experienced programmers due to its concise and unambiguous nature. Sharing code by developers is often cited as a contributing factor to improving the programming experience.

Programmers often transfer source code (as modules, as-is, or with adaptation) from one project to another, which is called code reuse.

Source code is an essential component in the process of porting software to other platforms. Porting is either too difficult or impossible without the source code of any piece of software.

Organization

The source code of some part of the software (module, component) may consist of one or several files. Program code is not necessarily written in just one programming language. For example, C programs often contain assembly language inserts for optimization reasons. Situations are also possible when some components or parts of a program are written in different languages, with subsequent assembly into a single executable module using a technology known as linking libraries ( library linking).

Difficult software requires dozens or even hundreds of source code files to build. In such cases, to simplify the build, project files are usually used, which describe the dependencies between the files with the source code and describe the build process. These files can also contain options for the compiler and the design environment. For different design environments, different project files may be used, and in some environments these files may be in a text format suitable for direct editing by a programmer using universal text editors, in other environments, special formats are supported, and files are created and modified using special tools. Project files are commonly referred to as source code. Source code often refers to resource files containing various data, such as graphics needed to build a program.

Version control systems are used to make it easier to work with source code and to collaborate on code by a team of programmers.

Quality

Unlike humans, there is no “well-written” or “poorly written” code for a computer. But the way the code is written can have a profound effect on the maintenance process. The quality of the source code can be judged by the following parameters:

  • readability of the code (including the presence

In order for the program to perform the actions prescribed for it, for example, calculate, display the result, react to user actions, for example, to press buttons, select lines from the list, it is necessary program code.

Program code is a set of words and symbols of a programming language.

Alphabet is a complete set of letters, numbers and symbols used in the language to denote data and actions on them.

The Visual Basic alphabet includes the following character set:

Uppercase (A - Z) and lowercase (a - z) letters of the Latin alphabet;

Numbers from 0 to 9;

Signs arithmetic operations(in ascending order of priority): +, -, *, /, |, ^;

Relation operation signs: =,<, >.

Punctuation marks and separators:,  . : ; ();

The alphabet of the language also includes reserved words that cannot be used as names variables or procedures. Examples of reserved words: Dim, Sub, Integer, etc. By default, a blue font is used to highlight keywords in the Visual Basic Code Editing window.

Words and symbols should be written strictly according to the rules of the language, without spelling and punctuation errors. It is the exact spelling that will allow the computer to unambiguously understand and execute the program.

Code window

The program code is written in the code window. Each form has such a window.

Open code window:

1 way - in the window Project Explorer right-click on the required form and select Show code.

Note: the code window may or may not be associated with the form. A separate window of code is called Module... Modules in the Project Explorer window are grouped into a group Modules... To open a window with the module code, you need in the window Project explorer double click on the module name.

2 way - double-click on a control on the form or on the form itself in the form window.

Note: this not only opens the code window, but also creates an event handling procedure (see below).

Code window structure:

Rice. 7. Window of the program code.

    List of controls

    List of control events

    Procedure (code)

Procedures

Since when the refrigerator is opened, the lamp lights up, and when the tap is opened, water flows out, we can say that when the refrigerator opening event occurs, one procedure is performed, and the valve opening event triggers another procedure. Similarly, the program code consists of separate procedures, each of which performs its own specific actions for it, for example, one procedure lights a lamp, the other turns on (pumps) water.

Visual Basic - procedural programming language. This means that you can create blocks of code in it, which can then be referenced by name. After the code block is named, it can be summoned and executed. It's like a program within a program. Small programs that "live" in large programs are called functions if they return some value, and subroutines, if they do not return values.

Subroutines and functions make programming easier and faster, and the generated code more reliable. Creating your own routines and functions is the first step to development encapsulated and reusable code. Encapsulation means hiding the implementation of properties and methods of an object behind its external interface.

Procedure (subroutine) is a separate piece of program code that usually solves a small problem; it is a logically constructed, small program block into which the entire program is divided.

If a procedure can be executed only within a given program block (for example, only in this form), and it cannot be called from another program block, then such a procedure is local. The local procedure is specified using the Private Sub keyword.

If the procedure can be called from other program blocks (for example, from another form), then such a procedure is global. The global procedure is specified using the Public Sub keyword.

By default, if before the Sub keyword, no keyword then this is a global procedure.

The procedures are:

    Event procedures... Executed when an event occurs in any control (or form). An event procedure is always associated with an object. To call the event procedure of an object, it is enough to make a double left click on this object.

    Arbitrary procedures... They are not event related and can be called from any other procedure and executed at any time. If the same program block occurs in a program in all forms, then it can be written only once and in one place, in the form of a global general program... The launch of a common program is not associated with an object or an event, but occurs when it is accessed from other program blocks. Calling a general procedure from the same form: ProcedureName (ParameterList)... Calling a general procedure from another form: AN OBJECT. ProcedureName (ParameterList)... The general procedure is both local Private and global Public.

Procedure structure

The procedure consists of the following elements:

    Procedure header - marks the beginning of the procedure, its type, purpose (event).

An example of the header of a procedure that is executed when the button named Command1 is clicked.

    Word Private means - closed, that is, the procedure belongs only to this form or module and cannot be used by other containers (forms, modules). If this word is omitted, then the procedure will be open to other containers.

    Sub- procedure.

Note: besides procedures there are functions - function. Functions are not associated with events and can additionally return the result of their work (calculations).

    Control element(or form name): this is the exact name of the element stored in the property Name.

    Event- the name of the event. Here are some of the events:

    Click - mouse click;

    DblClick - double mouse click;

    KeyPress - key press;

    UnLoad - unloading the form (when the form is closed, the program ends);

    Activate - activating the form (when clicking on the form, when its title is highlighted);

    Deactivate - deactivate the form (when clicking on another form).

    Initialize - when creating an object of type form.

    Resize - when resizing the form

    Terminate - at the moment of deleting the form

    Arguments is the initial data passed to the procedure for processing.

Custom procedures have the following heading:

Procedure name should be uniquely, must begin with a letter, and must not contain spaces or other characters other than the underscore. A procedure is called by name when it needs to be executed.

    End of procedure - ends the program code of the procedure: End Sub

Note: for functions: End Function

    Body procedure are the lines between the title and the end. Their number is unlimited. The lines contain instructions that must be executed when the procedure is called (an event occurs).

Subroutine (Sub) - is a procedure that executes program code within its block and does not return a value. The syntax for a simple subroutine is:

( Private | Public ) Sub SubMain ()

.. lines of code End Sub

The scope of the subroutine;

Sub-type of procedure (namely, a subroutine);

subMain the name assigned to the subroutine;

End Sub - the end of the subroutine code block.

Create procedure

To create a procedure, do the following:

    1 way - double-click on the required control or form. The code window will open, and the title and end of the procedure will appear in it. If another event is needed, then it is selected using the list in the upper right corner of the code window.

    2 way - open the code window, execute Tools → Add procedure → specify the name and parameters of the procedure → Ok.

    3 way - open the code window and enter the required lines from the keyboard.

The result should be:

Private Sub Command1_Click ()

Calling procedures for execution

    This event must have occurred for the event procedure to be executed.

    To execute an arbitrary procedure, the name of this procedure is specified in the body of another procedure.

Private Sub Command1_Click ()

Here, pressing the Command1 button raises the Click event and invokes and executes the Kvadrat procedure.

The procedure code is executed line by line and from top to bottom.

The function (Function) - it is a procedure that executes lines of its code and returns some value. The syntax for a simple function is as follows:

Function FunctionName () As Datatype

... stringscode

FunctionName = ReturnValueEnd Function

Function scope;

Function is a Visual Basic keyword indicating that this is a function;

FunctionName () - the name assigned to the function;

AS is a Visual Basic keyword that precedes the assignment of a data type;

DataType the data type of the return value;

ReturnValue the value that should be assigned to the function name (this is a very important point!);

End Function - the end of this block of code.

Some for the sake of a joke, someone to prove the existence or disprove a hypothesis, someone to warm up the brain (traveling on the surface of a Klein bottle or in four-dimensional space), but hundreds of people have created "esoteric" programming languages. I've flipped through about 150 of these languages ​​and I can never be the same again.

"Argh!", "Oof!", "2-ill", "Nhohnhehr", "Noit o" mnain gelb "," DZZZZ "," Ypsilax "," YABALL ", fuckfuck are spells, poetry only names ... katom - examples of code in the most tricky programming languages.

The rabbit hole is deep.

INTERCAL (Turing-complete)



Don Woods and Jim Lyon

One of the oldest esoteric programming languages. According to the creators, its name means Compiler Language With No Pronounceable Acronym. The language was created in 1972 by students Don Woods and James M. Lyon as a parody of existing programming languages ​​and mental gymnastics.

Hello, world

Each command of the program can be set the probability with which it will be executed when the program starts. In addition, there are commands that block the execution of subsequent commands. of a certain type or changing variables.

Hello world!

// "Hello World" by Stephen McGreal.
// Note that the views expressed in this source code do not necessarily coincide with those of the

Gr34t l33tN3 $$?
M3h ...
iT 41n "t s0 7rIckY.

L33t sP33k is U8er keWl 4nD eA5y wehn u 7hink 1t tHr0uGh.
1f u w4nn4be UB3R-l33t u d3f1n1t3lY w4nt in 0n a b4d4sS h4xX0r1ng s1tE !!! ; p
w4r3Z c0ll3cT10n2 r 7eh l3Et3r!

Qu4k3 cL4nS r 7eh bE5t tH1ng 1n teh 3nTIr3 w0rlD !!!
g4m3s wh3r3 u g3t to 5h00t ppl r 70tAl1_y w1cK1d !!!
I "M teh fr4GM4stEr aN I" lL t0t41_1Ly wIpE teh phr34k1ng fL00r *** j3d1 5tYlE *** wItH y0uR h1dE !!! L0L0L0L!
t3lEphR4gG1nG l4m3rs wit my m8tes r34lLy k1kK $ A $$

L33t hAxX0r $ CrE4t3 u8er- k3wL 5tUff lIkE n34t pR0gR4mm1nG lAnguidGe $ ...
s0m3tIm3 $ teh l4nGu4gES l00k jUst l1k3 rE41_ 0neS 7o mAkE ppl Th1nk th3y "r3 ju $ t n0rMal lEE7 5pEEk but th3y" re 5ecRetLy c0dE !!!
n080DY unDer5tAnD $ l33t SpEaK 4p4rT fr0m j3d1 !!!
50mE kId 0n A me $$ 4gEb04rD m1ghT 8E a r0xX0r1nG hAxX0r wH0 w4nT2 t0 bR34k 5tuFf, 0r mAyb3 ju5t sh0w 7eh wAy5 l33t ppl cAn 8E y0re lIk !!! hE i5 teh u8ER !!!
1t m1ght 8E 5omE v1rus 0r a Pl4ySt4tI0n ch34t c0dE.
1t 3v3n MiTe jUs7 s4y "H3LL0 W0RLD !!!" u ju5t cAn "T gu3s5.
tH3r3 "s n3v3r anY p0iNt l00KiNg sC3pT1c4l c0s th4t, be1_1Ev3 iT 0r n0t, 1s whAt th1s 1s !!!

5uxX0r5 !!! L0L0L0L0L !!!

ArnoldC

Terminator programming language.

Hello world!

Appointment

The source code is either used to produce object code or is executed by the interpreter. Changes are never made to the object code, only to the original one, followed by re-conversion to object code.

Another important purpose of source code is as a description of a program. Using the text of the program, you can restore the logic of its behavior. Comments are used to make the source code easier to understand. There are also tools that allow you to automatically retrieve documentation from source code — the so-called. documentation generators.

In addition, the source code has many other uses. It can be used as a teaching tool; Novice programmers may find it helpful to examine existing source code to learn programming techniques and methodologies. It is also used as a communication tool for experienced programmers due to its concise and unambiguous nature. Code sharing among developers is often cited as a contributing factor to improving the programming experience.

Programmers often transfer source code (as modules, as-is, or with adaptation) from one project to another, which is called code reuse.

Source code is an essential component in the process of porting software to other platforms. Without source code for any piece of software, porting is either too difficult or impossible.

Organization

The source code of some part of the software (module, component) may consist of one or several files. Program code is not necessarily written in just one programming language. For example, often programs written in C, for optimization purposes, contain insertions of assembly language code. Situations are also possible when some components or parts of a program are written in different languages, with subsequent assembly into a single executable module using a technology known as linking libraries ( library linking).

Complicated software requires dozens or even hundreds of source files to build. In such cases, to simplify the build, project files are usually used that describe the dependencies between the files with the source code and describe the build process. These files can also contain options for the compiler and the design environment. For different design environments, different project files can be used, and in some environments these files can be in a text format suitable for direct editing by a programmer using universal text editors, in other environments special formats are supported, and files are created and modified using special instrumental programs. Project files are commonly referred to as source code. In the vast majority of modern language environments, project files are necessarily used, regardless of the complexity of the other source code included in the project. Source code often refers to resource files containing various data, for example, graphics needed to build a program.

To facilitate the work with the source code, for joint work on the code by a team of programmers, version control systems are used.

Quality

Unlike humans, there is no “well-written” or “poorly written” code for a computer. But the way the code is written can have a profound effect on the maintenance process. The quality of the source code can be judged by the following parameters:

  • readability of the code (including the presence of comments on the code);
  • ease of support, testing, debugging and bug fixing, modification and porting;
  • economical use of resources - memory, processor, disk space;
  • no comments displayed by the compiler;
  • absence of "garbage" - unused variables, unreachable blocks of code, unnecessary obsolete comments, etc.;
  • adequate error handling;
  • portability - the ability to use a handler (compiler, interpreter, translator) different versions, or even different OS;
  • the ability to internationalize the interface.

Non-executable source code

Free software copyleft licenses require source code distribution. These licenses are also often used for non-software work such as documentation, images, data files for computer games.

In such cases, the source code is considered the preferred form of the work for editing. It may also be referred to as the "transparent" version in licenses for other than software. This could be, for example:

  • for a file compressed with data loss - lossless version;
  • for rendering a vector image or a three-dimensional model - the vector version and the model, respectively;
  • for text images - the same text in text format;
  • for music - a file in the internal format of the music editor;
  • and finally, the file itself, if it satisfies the specified conditions, or if a more convenient version simply did not exist.

see also


Wikimedia Foundation. 2010.

See what "Source Code" is in other dictionaries:

    Source materials film negative, countertype, control copy of the film, original magnetic soundtracks, re-recording of music, noises, master video recording, CD, etc. Synonyms: the text is either executed directly by the interpreter, or ... ... Financial vocabulary

    Human-written text of a computer program in any programming language Dictionary of business terms. Academic.ru. 2001 ... Business glossary

    source- - Topics telecommunications, basic concepts EN source code ... Technical translator's guide

    source- 3.1.13 source code: A computer program expressed in a human-readable form (programming language) that is translated into a machine-readable form (object code) before it can be tested with ... ... Dictionary-reference book of terms of normative and technical documentation

    source- the language of the source text ... Explanatory translation dictionary

    Source Code: The source code of a human-written text of a computer program. The source code of the technotriller directed by Duncan Jones ... Wikipedia

    This term has other meanings, see source code. Source Code ... Wikipedia

    This article is missing links to sources of information. Information must be verifiable, otherwise it can be questioned and removed. You can ... Wikipedia

    Open Source Initiative (OSI) logo Open source software is open source software. The source code of the created programs is open, that is, it is available for viewing and modification. This is ... ... Wikipedia

    Source program (source code)- 48) a source program (source code) a corresponding representation of one or more processes that can be converted by a programming system into a form that can be executed by equipment (object code or object language) (categories 6, 7 and 9); ... Official terminology


2021
maccase.ru - Android. Brands. Iron. news