📜 ⬆️ ⬇️

Time to tie

EXPANDTAB !!! Maybe it was worth writing in " I resent ." I do not know. While he was writing, he broke a cup of tea and thus reached composure.

I mean this: one and two .

There are also many wonderful themes for holivars: Windows or Linux, IE or FF, Canon and Nikon, Intel and AMD, “in Ukraine” or “in Ukraine”. Alien or Predator, finally!
')
But no, they are hooked out of the blue: spaces and tabs.



I will not pretend that the problem does not exist. The problem is still some. If the wrong symbols are used in the code, the indentation breaks, the cursor jumps in a strange way, sprawling silly diffs appear and the systolic volume of the heart increases. Something to do.

Conflicts

I'm not talking about merge conflicts (although they also exist), but about conflicts between employees.

Okay, just tabs. There is, say, such a special effect in vim 'e: if there was one completely empty line between indented lines between two lines (that is, two \n in a row in its place in the file), then vim did not save the cursor position when moving down and up.

And now you complain to me that I have committed empty lines. So empty that even without spaces. It's too tight for you, but I'm to blame.

When I wrote to vim, that was my problem. It seems that she even somehow decided.

Now you write in vim (and I in Komodo Edit ), but for some reason it remains my problem. Why? Because vim orthodox? Here it is not necessary. After all, I'm older and my legs are dirtier. We have a subordination and seniority.

Where are you going to be?

Let's not convince each other of something. You have your gaps, I have mine. We will not impose them. Everyone stays with his, and in order to remain comfortable, smart people have invented processing scripts (hooks) for events in version control systems.

Sapienti sat.

Are you programmers after all or where? What kind of nagging? Have you not analyzed the magic formula in the writings of the classics - how to count the number of tabulations by position in a line?

So, now during a job interview there will be a mandatory task - to write a filter that turns any text file into a candidate's favorite combination of whitespace characters for indents. Didn't do it in 20 minutes? Get out of the profession.

And diffs, by the way, from time immemorial could be shown without taking into account whitespace. And now diffs are generally smart, they will soon take over humanity.

What's next?

Well, let's say, we have dealt with indents, but there is still alignment. And jiggles. And rulers. Not counting more important pieces, such as Egyptian curly brackets, spaces around arguments and the sacred Naming of Functions and variables in a different_visibility area .

In general, we have somewhere lay style guide. We copied three pages and added two paragraphs; Then they got into a mess and shoved what they did into the corporate wiki. We are going there with the nose of newbies. When did he drop in? Well ... last year, it seems, watched. Yes, last year, for sure. In January. It is well written about how important comments are and when to use num in identifiers, and when to count .

Yes, it is useful to follow the style guide. But sometimes lazy.

So what's the problem? Quickly google: % your_loved language% tidy . Download, install, run the code through it and enjoy life.

What about oh For% your_loved language% nothing? And you also ask, why is it so ingenious to make the open source community happy in a free evening?

Take it and write. For example, you can take perltidy , it is perhaps the most powerful. In it stopitstsot pens and buttons; I am sure that even the author does not know them all. And with alignment, which is alignment, how it is controlled - it's just some kind of magic.

The answer to the main question

We decide once and for all. Decide, for example, like this:
With this all. This is done by a couple of the simplest regulars.

The second. Responsible for maintaining order in the repository is assigned system administrator Pupkin V.A. If there are files in the repository that do not comply with the specified rules, only he will be punished, not the committer. Let Pupkin set up processing hooks today. If a common opinion is reached about the style, in addition to the simple rules, the code will be run through xxxtidy with such and such options to bring the files in line with the corporate style of the program code.

Third. No complaints like “I'm used like this”, “I need this way here”, “my NoteWordMega +++ editor doesn’t understand your tabs”, “this fucking NoteWordMega +++ has piped into the code of whistles and perdeks” from now on and forevermore. The complainant will be punished with three days of refactoring of a code written on Whitespace and printed on toilet paper. Then he sits down to tune the hooks on his side. Now absolutely everything.

Immediately, grace is spreading around the office and the developers' complexion improves by 18%.

Officially declare

If suddenly I come to your workplace, or you come to my workplace, and try to present something about spaces and tabs - I will tear the shirt off on myself, the scream in a terrible voice and bite off your head. Well, okay, okay, I'll get into a corner, cry and call my mom.

Agreed?



1. Since the animal at the beginning of the topic, taken by me on Flickr, was licensed under CC BY-SA , I specify the author of the photo: Johnathan Nightingale .

2. Something I can not google the instructions for using num and count in identifiers, but the question is really interesting. And from the point of view of the English language, and for the purpose of establishing a total order. I remember, there was a very good article, if anyone finds, give the link, please.

3. In the first version of the post, the number of swears reached three on offer. Reluctantly, matyuki povybrasyval. And then the programmer now went gentle, from the tabs and spaces pales and withers where he has a strong vocabulary. Here smile.


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


All Articles