📜 ⬆️ ⬇️

Koans about programming

From the translator: The Codeless Code is a collection of fables about the philosophy of programming. The little ones in the collection are different - some are very bloodthirsty, some are rather hardcore from a technical point of view (the author's native language is Java), but there are very capacious ones. I present to you the translation of the seven most beloved stories to me, the remaining 30+ (new ones are added every week) can be found on the site.

Trifle


For three days and three nights the master did not appear from his cell. On the fourth day, the monks sent a novice to visit him.
')
The master was busy contemplating a data flow diagram. The novice recognized in her a minor detail of an extensive system, the support of which the monks were engaged in. Bowing, the novice asked what the master was working on.

The master replied: “There is a flaw here, and I’m thinking how best to fix it.”

The novice exclaimed: “But you preach the importance of prioritization, how can you dwell on something so shallow and insignificant?”

Without a word, the master raised the staff and with a force lowered it onto the novice’s bare foot, breaking that little finger. The novice screamed in pain and stalked out of his cell. At that moment he achieved enlightenment.

Encapsulation


The young monk declared open not only all the methods of the classes, but also all the attributes. The abbot of the monastery was tired of making comments to him and turned to the master for advice.

The next day, the master invited the monk to have breakfast with him. A luxurious meal was served at the conference table in the master's office. The master told the monk to lie on the floor. The monk obeyed, and the master opened his robe and pulled out a large knife. He pressed the point of the knife to the monk's chest so that blood appeared under him. The monk cried out in horror and asked the master what he was going to do.

“Break your belly,” replied the master, “to put rice there and pour tea. I have a tight schedule today, and it seems to me that this method of treating guests will be very effective. ”

After that, the monk did not need to make comments on this matter.

Infinity


Two monks from the Web clan argued about whether the program entered into an infinite loop.

“How much is it already being done?” Asked the abbot of the monastery.

"Not more than half an hour," replied the thin, pale monk.

"But not less than that," said the full swarthy monk.

“And all this time you have been idle, waiting until it is completed?” Said the abbot. The monks bowed shamefully.

The abbot told about this to the master. He said, “A thin monk believes that the cycle is not infinite. Give him the fur of wine for wisdom - no cycle can be endless. One day there will be a power failure, or the server will crumble into dust, or the sun will swallow the Earth. ”

The abbot asked, "But what about the fat monk, who believes that the cycle is endless?"

“Give him two furs of wine, for he is wiser. A user who waits behind his browser seems agony for ten seconds, a minute is a billion years, and everything that is even longer is an eternity. When a tiger torments an antelope, it doesn’t matter if it uses eight claws or a million. ”

Evolution


The novice studied the master code and followed his style exactly: the design patterns, the naming methods, the indentation layout were the same, even the comments seemed like a master's voice.

During the next review of the code, the novice was surprised to see that the master was extremely dissatisfied.

“But master,” he protested, “I followed your example to the last semicolon. Here is your class written that month - doesn't it look like mine, like two eggs from the same laying? ”

“That's the problem,” the master frowned. “Yesterday I was a fool, last week I was an idiot, and a month ago I was an imbecile. Do not show me the code that I could write yesterday, show me the code that I could write tomorrow. ”

Weeds


The temple needed a new monk, and two potential adepts claimed the place. The master ordered the monk to conduct an interview with both. That same evening, the monk reported:

“They were completely equal in all respects — age, weight, appearance, manners, sword handling, and preferences for caffeinated beverages. Then I gave them the same logical task; one of them decided it, the second - no. "

Then the master ordered the monk to take him to the rooms where the interviews were held. At first they went to the room of the candidate who did not cope with the task. His sketches of the problem still remained on the board: painfully neat numbers lined up in even lines and columns. The master quickly found an error in the candidate's reasoning and said, “Here are pea shoots trying to break through the winter snow. If we grow them, we will have a nice lunch in the spring. ”

Then they went to the room of the candidate who solved the problem. His notes also remained on the board, spreading along it without noticeable order. Hastily scribbled scrawl zigzags, sometimes crawling on each other - the web of nonsense. The master shook his head: “You say that there is fragrant dill and lemon grass, but I cannot find them among the weeds.”

Tea river


Only the master settled in her favorite tea house, as a young novice approached her to find out her opinion about the code he wrote.

The master examined the listing and found that every method in it is carefully documented. For the setName method of the Person class, it was specified that it sets the name of the person; The getName method confirmed that it returns the name set by setName; and even the toString method swore that it would return a string.

The master dropped the listing and sat in silence. After some time, a novice asked her if she was unhappy.

“An interesting question,” answered the master and pointed to the code, “This is the paper lying on the tatami. On paper ink. Ink is a lot of words. A bird sits on a cypress tree outside. The bird has two wings with feathers and two eyes ... "

She continued that way until the novice reddened. He collected his code and left, ashamed but enlightened.

Garbage


Master studied the program, written in a remote monastery. On her monitor, large fragments of code glowed not black, but green — they were commented out.

“Curious,” said the master, “I opened the exact clock and found the peel of an orange and fish bones inside.”

The abbot explained that the inactive code was unnecessary, but he ordered the monks to leave it: if one day you need to restore the logic, the code can simply be uncommented and not rewritten from the very beginning.

“This can be understood,” the master nodded.

The next day, the monks gathered for a meeting with the master. They were worried that the abbot could not be found anywhere. The master pointed them up to the rafters where the abbot's body hung.

“The services of your abbot are no longer required,” said the master. “But leave his body to decompose above you.” In the end, one day his methods may again be required, and it would be wasteful to teach a new person from scratch. ”

In her report, the master noted the rapid change in the clan's working methods. She attributed this to the good example of the late abbot and wrote “We should consider the possibility of his reinstatement.”

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


All Articles