📜 ⬆️ ⬇️

What do programmers do and how to explain it to the others?


Probably, every programmer had a situation when people completely unfamiliar with IT asked him to explain what his job was all about. It so happened that for most people the concept of a “programmer” is associated either with a closed geek with glasses and a sweater, or with some brilliant red-eyed teenage hacker — but no one knows what he does.

How to tell them about it without scaring with scary terms and code fragments?
Under the cut, I will reproduce such a story, as well as debunk a few myths about programming.

- What do programmers do? It’s not so easy to tell ... Answer me first: how can you briefly describe, for example, the essence of the surgeon's profession?
- The surgeon performs the operation.
- Yes, great description! Well, let's say a football player?
- Playing football!
- Yeah, and the surgeon "is engaged in surgery." And if without single words?
- Kicks the ball?
- That's for sure. And what does a programmer do, except for “developing programs”?
- ...
- The programmer writes the code . The source code of its program, compiled in a special programming language. More precisely, at first he thinks over the structures of his data, then he compiles algorithms for working with these structures - and then he already presents it in the form of code.
- What is the "data structure"? Does he not control the computer, does he press the buttons?
- Eh ...


Myth number 1: the programmer works with computers


Try to convey to people that a programmer doesn’t need a computer at all. It is needed only to verify the correctness of the code, to test it - but it is quite possible to write the code itself and draw up algorithms on paper (although, of course, it is more convenient to do this on the monitor screen). The developer simply writes on this paper a set of some instructions, commands or specific data (numbers, text). And who performs this set - a computer, telephone or a particularly intelligent robot, is not so important. The programmer works with data, not with machines.
')
- Well, okay?
- That is, the programmer simply informs the machine what he would like to do - and does she perform it?
- Well, yes, about.
- Just as the chief gives orders to subordinates?
- Something like that.
- And if the car wants to perform it somehow differently?
- In terms of?
“Well, she won't like something.” Or just do not want to perform.
- So, let's be clear once and for all that ...


Myth number 2: the car can think


For some reason, a considerable number of people really believe that the computer has some kind of intelligence. In fact, this is just a set of glands that cannot think. They can only store numeric data. Some part of such a piece of iron is demagnetized, which means it is zero. Magnetized - unit. Plus, they can also add and subtract these units, forming more complex numbers (it’s better not to mention the binary number system). More than the computer itself can not do anything, just keep the numbers and operate them. This is a thoughtless idiot who only performs the commands of the programmer.

- In general, the code of any program is a set of commands, and the computer stupidly executes them.
- That is, he does not understand the essence of the teams themselves? But how does he perceive the text that I enter on the screen?
- When you pedal on a bicycle - does he understand that he needs to go forward now?
- No, but it is going. As its chain converts the rotation of the pedals in the rotation of the wheel.
- Exactly! Also, the computer converts the text you entered into a set of numbers.
- How?
- Each character of the text has its own numerical code, which the computer knows. This is called encoding. For example, the English “a” is encoded with the number 97, and the equal sign with the number 61.
- Therefore, the machine and can understand the text that we tell her?
- No, she "understands" is not the point. And only how to store this text, and how to access it.
- So, first we enter the text, then the computer breaks it into characters, and each character is already represented as a number?
- Right. Complex structures are presented in the form of simpler ones , which the machine “understands”.

Tell me, what does a residential house consist of?
“Well ... from the floors.”
- And what are the floors? And so on.
- Floors - from the walls. And the walls are made of bricks. And the bricks ...
“The numbers for the computer are the same as the bricks for the house.” Symbols are walls. Separate offers - floors. And the books - the whole house! But programmers have an advantage over builders.
- What?
- The builder can not build whole floors, he is forced to always lay bricks. Even if a certain heavy-duty crane allows him to build finished floors, he will not be able to build whole houses or residential quarters for them. A programmer can! Once he had already “taught” the machine to understand the final text - then, in fact, he “trained” the crane to build a finished house in one operation.
- That is, the programmer can use more and more complex data structures?
- Yes. Therefore, the first component of his work is to present human-readable data (text, image, sound) as a combination of simpler data already understood by the computer. The developer practically from scratch constitutes a structure that should completely describe a thing that is understandable to man - and in such a way that this structure is easily expandable and changeable (after all, some new features often have to be introduced into the program).
- Heh! It turns out that he is building rubber houses from removable panels!
- Like that. However, he will also have to not only describe what he needs to build - but how to build it all. That is, to come up with an algorithm. This is the second component of his work.
- The programmer comes up with an algorithm for each action?
- Exactly. Therefore, there are a lot of algorithms. But his work is facilitated by the fact that some actions may contain others, already described by him before.
- And here comes the programming language to help him?
- Not really ...


Myth number 3: a programming language is needed to create algorithms


No, language is just a tool. Like a guitar for a musician. In itself, the ability to play the guitar does not guarantee fame - because people tend to admire the music itself, rather than the ability to quickly and clearly pull the strings. On the other hand, hardly anyone will come to see a bad guitarist, no matter how great a song he performs. Also with PL: the knowledge of its syntax and the nuances associated with it is very important, as well as the ability to write beautiful and clear code. However, if a person does not know how to compose algorithms and data structures, then he cannot be called a good programmer.

The computer does not understand the programming language directly. As before, he presents each command of the language as a set of “simplest” commands (save the number, zero the number, add one to it), which he is able to execute. The programmer "understands" the language, and the machine only executes it. In fact, any programming language is a set of commands that serve to communicate with it.

“True, many of the current programming languages ​​already contain“ in themselves ”a set of pre-compiled algorithms that the developer can use as ready-made ones. Therefore, the language still slightly simplifies the process of drawing up algorithms.
- That is, if one programmer has compiled an algorithm, then others can use it right there?
- Yes, and it happens all the time. This is one of the reasons why the IT industry is developing so fast. However, new algorithms have to be yourself.
- And make some right now!
- Easy. A classic example: you have a book, it has 1000 pages. You need to open it, for example, the 875th page. How would you do that?
- Well, I just ran from the first to the 875th, that's all.
- Yeah, and you'll have to look at the number of each page. And imagine, if all their corners are stuck together - how long will it take then? But it is enough for me to go through only 3 pages!
- How?
- First, I will choose a page that is in the middle of the book, that is, the 500th. Then I will look: in which of the formed halves should the desired page be placed?
- In the second. And then what?
- Same. The interval from the 500th to the 1000th will again be split in two by opening the central page. It will turn out the interval from the 750th page to the 1000th, in it I will again select the central one. What will be the number?
- 750 plus 125 ... So this is the 875!
- You see. Only 3 actions! Even if I am not quite accurate when choosing the central page, I will still find the one I need much faster than you. This algorithm is called the “dichotomy”. Although in reality, programmers use much more complex algorithms.
- And can you write it on paper?
- Of course. Where is my pen?

Pseudocode
 :
	
        ( , _);
	
         (_ = _)
                  ;
	
        
                 (_ < _)
                        ( ,      );
                
                        ( ,      );

— , ?
— … , .
— , .
— ?
— , «» (, ?). , «» «» . — .
— ?
— .
— ?
— !



№4: —


, , . , , . . — . , . , , ( ) — ().

, . , , . , . , , : - , . — , , …

— , - , .
— — ?
— , . , - , - . , …
— , !
— .
— , , ?
— , ! ...



:

, . , — , , ;)

Source: https://habr.com/ru/post/155429/


All Articles