Vasya as a compiler
Vasily Viktorovich (further simply Vasya) worked in the office for the third year. He is a programmer by education, he was in good standing with the director Alexander Ivanovich, he did not doubt his professional skills at all and was ready to entrust him with any important task. The director often recruited new employees to help Vasya, but they all didn’t stop for a long time - Vasya complained that the programmers who were bad with them didn’t want to work, they wrote code in which he would break his leg, and besides, he would stuff his OOP everywhere and patterns.
- Vasya, so maybe you can work yourself? Already ten people have been fired ... I understand that nowadays there is no way to find specialists, I understand that it’s hard to work alone, but you can still try, eh?
- Ivanovitch, I would love to, but then who will deal with small matters? I write the most important things, and getting distracted by nothing is always very difficult. Find me a good man, Ivanovitch! I believe one day I will come across the one that can work like me, or even better!
- Why are you, Vasya, I’ve already made sure - I’d better not find anyone. I will try, Vasya, I will try!
The director patted him on the shoulder and left the office. And Vasya pressed Alt + Tab and continued to read the tape.
- Vasya, get acquainted, this is Andrey. Two years ago I graduated from the university, worked for seven months at Yandex, the recommendations are good, I think you’ll work together, ”the director winked.
Vasya looked disapprovingly at the recruit, wondered how many days later he would fly out of here, and smiling slyly, extended his hand to the smiling boy.
“Vasily Viktorovich,” he muttered.
“Very nice,” the boy continued to smile, which only angered Vasya.
- Well, you will familiarize Andrey with his duties, and I will go.
When the door behind the director slammed, Vasya pointed the new one at the computer and threw him a couple of “simple tasks”, which, to be honest, he had been working on for more than a month.
Andrei opened the project and was horrified: there was not a single comment in the code, there was simply no formatting, the names of variables and methods did not correspond to reality. Andrei knew that this day would come. Even from university, he was preparing for the worst case scenario, but he was not ready for what he saw - the boy’s smile disappeared without a trace, and tears came to his eyes. “Hold on, Andreyka, hold on,” the boy encouraged himself day after day. For ten days of work in this terrible office, Andrei realized that Vasily Viktorovich is the most bydlokoder. Of course, he had some knowledge, otherwise Alexander Ivanovich would have immediately suspected the incompetence of this "specialist", but otherwise he did not want to program normally.
Andrei realized that he would not last so long. He had one ability that no one knew about - he was well versed in the art of hypnosis. And then one day, after a hard working day, he went up to Vasya, snapped his fingers and whispered a few phrases ...
Vasya did not immediately wake up. At first there was a kind of ominous muffled sound in my ears, then the blackness in my eyes gradually turned into a dull ripple, and then again - and he was standing in some strange room. Around nothing, only a white floor and a gray ceiling. No noise. It seemed that Vasya could hear his own heartbeat. From somewhere, a click of a mouse was heard, and the silence began to acquire some kind of intense shades, as if before a storm.
- Hey, hurry up, you need to read these source code files.
- hhhh? What fa ...
“Well, lively, I said,” came a lash, accompanied by a scream from Vasya. - You read these files, put all the information in the table of tokens. If something incomprehensible occurs, press the stop crane with the corresponding error message. HURRY UP!
Vasya unfolded a long scroll with the name “main” and began to read it. An inconvenient formatting immediately struck, the letters kept merging together, forming a mess, the names of the variables contained no more than three letters - it is difficult to remember whether a variable was declared or not. The same story was with the names of the methods. It seemed to Vasya that he was familiar with this code, but there was no time for reflection - he was so often beaten with rods that he could hardly read normally what was written.
Having finished with one file, Vasya sat down to rest and immediately received a series of new blows. Having realized that, he unfolded another scroll with the name “Krname” and started all over again. Then there were the files “qwerty”, “MegaUtils”, “dList”, etc. Vasya’s eyes began to get tired, his back ached from endless lashes and bangs, his hands shook from constantly writing tokens to the table - Vasya went to hell.
After a very large amount of time, Vasya still managed to view all the files and enter the information in the token table. “Well, finally,” he wiped sweat from his forehead.
- What fell apart? Take tokens tables, check their syntactic correctness and build the parse tree on this data! If you miss something, you will redo everything all over again. To work!
Vasya began to check the data in the table with the Book of Rules and draw a tree of operators and operands on a huge sheet of paper. Line by line, token after token, he checked notes. Top by top, rib by rib, he painted a tree. Symbols loomed in his eyes, many symbols, they had no end. And then Vasya got a line not specified in the rules. Without thinking twice, he jerked the lever with the inscription "Syntax error". Immediately, the work stopped, the lashes ended, the sheet in which the tree was drawn was cleaned, an ominous silence fell in the room again. Vasya fell to the floor, exhausted. He did not have to rest for a long time, only two minutes later the work began ... again. Vasya shouted “No” in desperation, but his back was burned by a couple of new blows, I had to read all the files on a new one.
For some fraction of eternity, in any case, it seemed to Vasya, he sorted through the scrolls with the source code and checked the table of tokens. Fortunately, there were no more syntax errors, but this didn’t ease Vasya’s fate, there was a new test ahead.
“Hey, take the syntax tree and mark the typing,” the voice commanded, lashing at the poor man.
Vasya’s fatigue made itself felt, he kept getting confused during type checking, but the feeling that he would redo everything all over again if he made a mistake added a little enthusiasm to his work.
“Now generate what you have in the intermediate language.” And do not forget to optimize the result !!!
Vasya started; he had never done any optimizations before. He did not like to enclose repeating pieces of code in a separate method, he did not often use loops, he even called variables as short as possible, because he believed that all these little things distracted from the main occupation - programming. Why think about optimization if the operation of the program is important? But no matter how critical Vasya’s opinion was, a couple of lashes did the trick - he began to optimize. He examined individual lines of code and tried to find the best option for them. He unrolled loops, assembled sequences of lines into a pair of shorter ones, rewrote some fragments.
Vasya's head was buzzing. It seemed that the devil himself was punishing him for years of writing bad code. Optimizing the last remaining line, Vasya fell to his knees and squeezed out:
- I can not take it anymore.
- How can you not? And who will generate the machine code? Incidentally, I do this hundreds of times a day and do not complain. Every day I read your terrible code, study the types of your meaningless variables, optimize all your mediocre work to get a program that doesn't even start because you forgot to register a module call! I am forced to do this again and again, until you bother to prescribe it all the same. And I do not receive a single word of gratitude, on the contrary, I constantly hear "Compile faster, you infection!", "What kind of mistake is this? Everything is correct in my code! ” I do not have the opportunity to say what I think about you, because I do not have leverage with the right phrases. But if they were, you would be afraid to click Compile ... Now get up and generate machine code!
Vasya obeyed and began to replace instructions of the intermediate language with instructions of machine code. Hands were barely raised, it was dull in the eyes, a whistle was heard in the ears, the legs gave way, the back burned with new blows, the neck barely kept the head boiling from an endless stream of information. Yes, Vasya went to the hell of a bydcoder. He knew that for sure. If he ever succeeds in getting out of here, he will stop writing bad code, format the sources, give meaningful names to variables and methods, start optimizing his programs and never, never again scold the compiler!
... Vasya opened his eyes. There was no one in the office. The development environment was opened on the monitor screen. A cursor blinked on one of the unformatted lines. Vasya reached for the keyboard and held Ctrl + Backspace. The cursor ran, taking with it everything that had been written in the last months of work. Leaving a clean source file, Vasya got up, looked at the compiler output console and said: “Thank you”.
- Vasya, so maybe you can work yourself? Already ten people have been fired ... I understand that nowadays there is no way to find specialists, I understand that it’s hard to work alone, but you can still try, eh?
- Ivanovitch, I would love to, but then who will deal with small matters? I write the most important things, and getting distracted by nothing is always very difficult. Find me a good man, Ivanovitch! I believe one day I will come across the one that can work like me, or even better!
- Why are you, Vasya, I’ve already made sure - I’d better not find anyone. I will try, Vasya, I will try!
The director patted him on the shoulder and left the office. And Vasya pressed Alt + Tab and continued to read the tape.
- Vasya, get acquainted, this is Andrey. Two years ago I graduated from the university, worked for seven months at Yandex, the recommendations are good, I think you’ll work together, ”the director winked.
Vasya looked disapprovingly at the recruit, wondered how many days later he would fly out of here, and smiling slyly, extended his hand to the smiling boy.
“Vasily Viktorovich,” he muttered.
“Very nice,” the boy continued to smile, which only angered Vasya.
- Well, you will familiarize Andrey with his duties, and I will go.
When the door behind the director slammed, Vasya pointed the new one at the computer and threw him a couple of “simple tasks”, which, to be honest, he had been working on for more than a month.
Andrei opened the project and was horrified: there was not a single comment in the code, there was simply no formatting, the names of variables and methods did not correspond to reality. Andrei knew that this day would come. Even from university, he was preparing for the worst case scenario, but he was not ready for what he saw - the boy’s smile disappeared without a trace, and tears came to his eyes. “Hold on, Andreyka, hold on,” the boy encouraged himself day after day. For ten days of work in this terrible office, Andrei realized that Vasily Viktorovich is the most bydlokoder. Of course, he had some knowledge, otherwise Alexander Ivanovich would have immediately suspected the incompetence of this "specialist", but otherwise he did not want to program normally.
Andrei realized that he would not last so long. He had one ability that no one knew about - he was well versed in the art of hypnosis. And then one day, after a hard working day, he went up to Vasya, snapped his fingers and whispered a few phrases ...
Vasya did not immediately wake up. At first there was a kind of ominous muffled sound in my ears, then the blackness in my eyes gradually turned into a dull ripple, and then again - and he was standing in some strange room. Around nothing, only a white floor and a gray ceiling. No noise. It seemed that Vasya could hear his own heartbeat. From somewhere, a click of a mouse was heard, and the silence began to acquire some kind of intense shades, as if before a storm.
Build started.- Hey, hurry up, you need to read these source code files.
- hhhh? What fa ...
“Well, lively, I said,” came a lash, accompanied by a scream from Vasya. - You read these files, put all the information in the table of tokens. If something incomprehensible occurs, press the stop crane with the corresponding error message. HURRY UP!
Vasya unfolded a long scroll with the name “main” and began to read it. An inconvenient formatting immediately struck, the letters kept merging together, forming a mess, the names of the variables contained no more than three letters - it is difficult to remember whether a variable was declared or not. The same story was with the names of the methods. It seemed to Vasya that he was familiar with this code, but there was no time for reflection - he was so often beaten with rods that he could hardly read normally what was written.
Having finished with one file, Vasya sat down to rest and immediately received a series of new blows. Having realized that, he unfolded another scroll with the name “Krname” and started all over again. Then there were the files “qwerty”, “MegaUtils”, “dList”, etc. Vasya’s eyes began to get tired, his back ached from endless lashes and bangs, his hands shook from constantly writing tokens to the table - Vasya went to hell.
After a very large amount of time, Vasya still managed to view all the files and enter the information in the token table. “Well, finally,” he wiped sweat from his forehead.
- What fell apart? Take tokens tables, check their syntactic correctness and build the parse tree on this data! If you miss something, you will redo everything all over again. To work!
Vasya began to check the data in the table with the Book of Rules and draw a tree of operators and operands on a huge sheet of paper. Line by line, token after token, he checked notes. Top by top, rib by rib, he painted a tree. Symbols loomed in his eyes, many symbols, they had no end. And then Vasya got a line not specified in the rules. Without thinking twice, he jerked the lever with the inscription "Syntax error". Immediately, the work stopped, the lashes ended, the sheet in which the tree was drawn was cleaned, an ominous silence fell in the room again. Vasya fell to the floor, exhausted. He did not have to rest for a long time, only two minutes later the work began ... again. Vasya shouted “No” in desperation, but his back was burned by a couple of new blows, I had to read all the files on a new one.
For some fraction of eternity, in any case, it seemed to Vasya, he sorted through the scrolls with the source code and checked the table of tokens. Fortunately, there were no more syntax errors, but this didn’t ease Vasya’s fate, there was a new test ahead.
“Hey, take the syntax tree and mark the typing,” the voice commanded, lashing at the poor man.
Vasya’s fatigue made itself felt, he kept getting confused during type checking, but the feeling that he would redo everything all over again if he made a mistake added a little enthusiasm to his work.
“Now generate what you have in the intermediate language.” And do not forget to optimize the result !!!
Vasya started; he had never done any optimizations before. He did not like to enclose repeating pieces of code in a separate method, he did not often use loops, he even called variables as short as possible, because he believed that all these little things distracted from the main occupation - programming. Why think about optimization if the operation of the program is important? But no matter how critical Vasya’s opinion was, a couple of lashes did the trick - he began to optimize. He examined individual lines of code and tried to find the best option for them. He unrolled loops, assembled sequences of lines into a pair of shorter ones, rewrote some fragments.
Vasya's head was buzzing. It seemed that the devil himself was punishing him for years of writing bad code. Optimizing the last remaining line, Vasya fell to his knees and squeezed out:
- I can not take it anymore.
- How can you not? And who will generate the machine code? Incidentally, I do this hundreds of times a day and do not complain. Every day I read your terrible code, study the types of your meaningless variables, optimize all your mediocre work to get a program that doesn't even start because you forgot to register a module call! I am forced to do this again and again, until you bother to prescribe it all the same. And I do not receive a single word of gratitude, on the contrary, I constantly hear "Compile faster, you infection!", "What kind of mistake is this? Everything is correct in my code! ” I do not have the opportunity to say what I think about you, because I do not have leverage with the right phrases. But if they were, you would be afraid to click Compile ... Now get up and generate machine code!
Vasya obeyed and began to replace instructions of the intermediate language with instructions of machine code. Hands were barely raised, it was dull in the eyes, a whistle was heard in the ears, the legs gave way, the back burned with new blows, the neck barely kept the head boiling from an endless stream of information. Yes, Vasya went to the hell of a bydcoder. He knew that for sure. If he ever succeeds in getting out of here, he will stop writing bad code, format the sources, give meaningful names to variables and methods, start optimizing his programs and never, never again scold the compiler!
Build successfull. Elapsed time: 00:01:19.... Vasya opened his eyes. There was no one in the office. The development environment was opened on the monitor screen. A cursor blinked on one of the unformatted lines. Vasya reached for the keyboard and held Ctrl + Backspace. The cursor ran, taking with it everything that had been written in the last months of work. Leaving a clean source file, Vasya got up, looked at the compiler output console and said: “Thank you”.